commandagi 0.6.2__tar.gz → 0.6.4__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 (86) hide show
  1. {commandagi-0.6.2 → commandagi-0.6.4}/CHANGELOG.md +115 -0
  2. {commandagi-0.6.2 → commandagi-0.6.4}/PKG-INFO +8 -2
  3. {commandagi-0.6.2 → commandagi-0.6.4}/README.md +7 -1
  4. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/__init__.py +1 -1
  5. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/client.py +5 -2
  6. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/__init__.py +18 -1
  7. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/fab.py +8 -3
  8. commandagi-0.6.4/commandagi/design/flows.py +155 -0
  9. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/part_fields.py +13 -7
  10. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/pcb.py +15 -4
  11. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/standards.py +7 -2
  12. commandagi-0.6.4/commandagi/design/standards_data.py +14 -0
  13. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/study.py +2 -2
  14. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/systems.py +17 -4
  15. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/threed.py +158 -141
  16. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/threed_elements.py +53 -17
  17. commandagi-0.6.4/commandagi/design/threed_schema.py +4 -0
  18. commandagi-0.6.4/commandagi/design/tolerances.py +206 -0
  19. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/kernel.py +5 -1
  20. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_fab.py +7 -0
  21. commandagi-0.6.4/tests/test_flows.py +55 -0
  22. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_kernel.py +22 -0
  23. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_logistics.py +5 -3
  24. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_pcb.py +12 -0
  25. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_standards.py +7 -0
  26. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_study.py +5 -1
  27. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_systems.py +5 -1
  28. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_threed.py +38 -2
  29. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_tolerances.py +8 -2
  30. commandagi-0.6.2/commandagi/design/standards_data.py +0 -14
  31. commandagi-0.6.2/commandagi/design/threed_schema.py +0 -4
  32. commandagi-0.6.2/commandagi/design/tolerances.py +0 -119
  33. {commandagi-0.6.2 → commandagi-0.6.4}/.gitignore +0 -0
  34. {commandagi-0.6.2 → commandagi-0.6.4}/LICENSE +0 -0
  35. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/_generated.py +0 -0
  36. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/agents.py +0 -0
  37. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/business.py +0 -0
  38. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/cad.py +0 -0
  39. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/cadquery.py +0 -0
  40. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/circuit_checks.py +0 -0
  41. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/documents.py +0 -0
  42. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/eda.py +0 -0
  43. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/element.py +0 -0
  44. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/firmware.py +0 -0
  45. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/graph.py +0 -0
  46. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/ir.py +0 -0
  47. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/media.py +0 -0
  48. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/monitors.py +0 -0
  49. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/office.py +0 -0
  50. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/ontology.py +0 -0
  51. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/pdf.py +0 -0
  52. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/postal.py +0 -0
  53. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/records.py +0 -0
  54. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/schema.py +0 -0
  55. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/schematic.py +0 -0
  56. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/solids.py +0 -0
  57. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/source.py +0 -0
  58. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/tasks.py +0 -0
  59. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/testplans.py +0 -0
  60. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/tsx.py +0 -0
  61. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/twod.py +0 -0
  62. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/twod_schema.py +0 -0
  63. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/design/workbook_schema.py +0 -0
  64. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/gym_env.py +0 -0
  65. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi/lerobot.py +0 -0
  66. {commandagi-0.6.2 → commandagi-0.6.4}/commandagi-sdk.schema.json +0 -0
  67. {commandagi-0.6.2 → commandagi-0.6.4}/examples/drive_a_sim.py +0 -0
  68. {commandagi-0.6.2 → commandagi-0.6.4}/pyproject.toml +0 -0
  69. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_agents.py +0 -0
  70. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_business.py +0 -0
  71. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_design.py +0 -0
  72. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_media.py +0 -0
  73. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_monitors.py +0 -0
  74. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_office.py +0 -0
  75. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_ontology.py +0 -0
  76. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_pdf.py +0 -0
  77. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_postal.py +0 -0
  78. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_records.py +0 -0
  79. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_schematic.py +0 -0
  80. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_sdk.py +0 -0
  81. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_source.py +0 -0
  82. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_tasks.py +0 -0
  83. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_testplans.py +0 -0
  84. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_tsx.py +0 -0
  85. {commandagi-0.6.2 → commandagi-0.6.4}/tests/test_twod.py +0 -0
  86. {commandagi-0.6.2 → commandagi-0.6.4}/uv.lock +0 -0
@@ -4,6 +4,121 @@ 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.4 (2026-10-22)
8
+
9
+ 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
10
+ is the same in the three SDKs, in each language's spelling; `@commandagi/host` 0.6.4 carries the checks.
11
+
12
+ Changed (a document written for 0.6.3 may need an edit)
13
+
14
+ - A placed assembly keeps its own `<permitted>`, `<library>`, `<accept>` (`body` and `other`) and names under the
15
+ placement: a dock that passes alone passes where it is placed. A placement's id selects its members in `bodies`,
16
+ `against` and `pair` (`dock`, `dock/MF-SH-VEE-20`) (CORE-51, CORE-52, CORE-54). A placed file of several parts keeps
17
+ each as `<placement>/<id>`.
18
+ - Every file resolves its imports from its own folder, in every command; the folder a run reads is `--folder`, else the
19
+ file's git repository (CORE-48, CORE-50). A `<part>` or `<assembly>` inside another document says to place its file.
20
+ - `commandagi diff` prints its lines; `--json` or `--out FILE` gives the JSON (CORE-45).
21
+ - An accept of a check that ran and covers nothing warns (`accept-unused`); a whole-part finding (`mill.material`) has
22
+ no place, so a body + rule accept covers it (CORE-47). `--only` leaves out the other checks' accepts (IC2-18).
23
+ - One finding per hole, cup or region, each with its own size (CORE-46). A washer is what bears on a clamped part
24
+ (IC2-14).
25
+ - A bill line of fastener pieces is named by its designation, a roll-up line by its part number (CORE-29).
26
+ - `route` says `complete: false` while a net has islands, pours counted (EDA-23); `route`/`layout` `--out` names the
27
+ board written, the input is left (EDA-22); copper too near the edge is an error (EDA-25); a part with no sheet
28
+ position is in ERC (EDA-21).
29
+
30
+ Added
31
+
32
+ - `<check sweep={{ joint, samples | step }}>`: interference and clearance over a joint's limits, each finding at its
33
+ joint value with where it starts and ends (PCBC-14); `<accept maxVolume>` (PCBC-18).
34
+ - `<externalPart omit moves>`: one placed file with parts left out or moved; a frame placed in every station (IC1-19,
35
+ IC1-14, PCBC-20).
36
+ - `engineering.envelope` and `mountingHoles` for a bought part drawn as its envelope (IC2-13); `<library sizes>`, one
37
+ table of sizes, part numbers and prices (CORE-29); a library screw's mass (CORE-44).
38
+ - STEP files hold one product per part used N times, nested sub-assemblies, and the library's part numbers (CORE-20,
39
+ CORE-53, IC2-19); `threed observe` names bodies as the checks do (CORE-39).
40
+ - `<slice device>`: a resin setup names its printer (CORE-42). A through hole is drilled from both declared setups
41
+ (CORE-40). A run of primitive cuts is one boolean: 473 cut cylinders check in 2.7 s, not 21 s (IC2-15).
42
+ - Studies: results are streamed (a 2.18M-node study, 1.2 GB of results, runs to its verdict: CORE-55); a container
43
+ ends with its host; stress beside a converging re-entrant edge is read (CORE-56); `spring` and `pin` supports
44
+ (IC1-15); `--keep field` (PCBC-19); `study check` refuses what `study run` refuses (CORE-41).
45
+ - `COMMANDAGI_THREED=cloud` on the command line, and every report says where its kernel ran (CORE-43, IC1-18,
46
+ IC2-16). Times per check and per feature (IC1-09, PCBC-15). A long hole table continues on further sheets
47
+ (IC1-17); a misplaced view is named (IC2-17). A wrong bracket is reported at its token (IC1-16).
48
+ - `diff`, `release status --diff` and a task's check read flows, systems, requirements and interfaces (LABS-21); a
49
+ release checks its flows (LABS-22); `make.ratePerHourHigh` (LABS-23); `<visit tool minutes>` in a flow step
50
+ (LABS-24); `commandagi task propose | approve | decline` offline (LABS-13); `live-miss` (LABS-14); `"unknown"` for
51
+ HS code, origin, hazmat, ECCN and datasheet (PCBC-16).
52
+ - Boards: pours read KiCad's own fill settings (EDA-27, in part); plane vias from the router (EDA-23); `pins
53
+ --install-hook` (EDA-26); RXD0/TXD0 GPIO numbers (EDA-12); `.3d.py` relative imports (PCBC-17).
54
+
55
+ ## 0.6.3 (2026-10-21)
56
+
57
+ The fixes for the microfab team's report on 0.6.2 (110 issues; the ids in brackets are theirs). The vocabulary below
58
+ is the same in the three SDKs, in each language's spelling; `@commandagi/host` 0.6.3 carries the checks.
59
+
60
+ Changed (a document written for 0.6.2 may need an edit)
61
+
62
+ - One face query for 3D documents, checks and studies: a study's `type` is `geometry`, `nearest` is `farthest` with
63
+ the direction reversed, `radius` and `area` take `{ min, max }`; `at` names the face that holds a point (CORE-24,
64
+ PCBC-12, IC2-08).
65
+ - A finding names a body by the id the document gives it (`<body id>`, else the feature that made it); the rebuild's
66
+ `body_0` is `rebuildId` (CORE-13). A covered finding's `severity` is `suppressed`, its own in `coveredSeverity`
67
+ (PCBC-03).
68
+ - `commandagi check` prints a compact report (verdict, each check, findings grouped by rule); `--json` or `--out FILE`
69
+ gives the whole report (IC2-12, PCBC-04).
70
+ - A `bodies` entry that names no body is an `unknown-body` error: a check of nothing never passes (LABS-02).
71
+ - Copper joins where it is drawn, and a pour joins the pads and vias of its net it covers; `from`/`to` are optional
72
+ (EDA-03, EDA-06). A part on the bottom flips its pads, paste, mask, silk and courtyard as KiCad does (EDA-04). An
73
+ unrouted net on a board with copper is an error (EDA-05).
74
+ - An unknown material is a warning of the process check (CORE-11).
75
+
76
+ Added
77
+
78
+ - Placed parts carry what their file states: engineering, mass, part number, fasteners; a placed assembly keeps its
79
+ members as `<placement>/<id>`. Check, `threed bom`, `threed observe`, STEP and `diff` agree (CORE-01 to -04, -09,
80
+ -20, -26, -27). Bill lines and logistics findings are one per part number with a quantity (LABS-16, IC1-11).
81
+ - A `.3d.tsx` imports sibling `.ts`, `.tsx` and `.json` files; a `.3d.py` reads its folder and imports sibling modules
82
+ (CORE-05, CORE-06). Syntax errors name the author's line and column (IC1-01); every refused element in one run
83
+ (IC1-02).
84
+ - `commandagi --version` with no key; `check --only ID`, `--timeout S` and a timeout that says so; `release --dry-run`
85
+ and `.releaseignore`; a release also holds the folder's requirements, systems and interfaces (SETUP-01, IC1-09,
86
+ LABS-19, LABS-20, CORE-28). `commandagi layout | route | fabricate <board>` run on this computer (EDA-17).
87
+ - Faces: a hole on a face split in two, a pick by a point on the face, a pick among the bodies a feature consumes, an
88
+ ambiguous pick that names its faces (CORE-08, IC2-02, IC2-03, LABS-05). A counterbore deeper than its size's
89
+ (CORE-10); `m2.5` threads (IC2-04); a clearance pair the kernel cannot measure is its own finding (CORE-19).
90
+ - Every ISO 286 class (IT01 to IT18, A to ZC) to 3150 mm, and ISO 2768-1 (IC2-05, CORE-17, IC1-06); a fit between two
91
+ sizes of different nominals (CORE-16); a fit's `pair` covers its press fit's clash (CORE-18); `against` on
92
+ interference and clearance (CORE-25, LABS-03); `<accept other>` for a part modelled inside another, an accept sized
93
+ to its finding (PCBC-09, IC1-10); `<hole spare>` and `<permitted diameter>` (IC1-04).
94
+ - The mill check judges each face from the setup that reaches it (`make.setups`, or the fewest sides), drilled holes as
95
+ drilled, a plate turned on the table, the machine's materials (CORE-07, -12, -14, -15, -21, -34). The resin printer
96
+ prints: SLA printability (drain, cups) and slicing (CORE-32); `commandagi slicer slice X.slice.tsx` (CORE-33).
97
+ - Drawing sheets: hole callouts from the hole features (depth, blind, FAR SIDE), a hole table from a datum corner, no
98
+ overlapping callouts, the release's REV (CORE-22, -31, -36, PCBC-10).
99
+ - Studies: inverted elements straightened, each level's reason on its line, `<solver timeout>`, `--keep finest`, a
100
+ fixture on a region (CORE-37, IC2-10, PCBC-11, IC1-15).
101
+ - Budgets of any quantity and unit (flow, area, volume …), a priced `<item ref>` to a design with its lead-time path,
102
+ a diff that names every logistics change, process flows (`.flow.tsx`), cost ranges, µm and nm, `other` processes,
103
+ `<library>` data for fastener pieces, `<fastener material partNumber>`, a `chemicals` check (LABS-06 to -12, IC1-03,
104
+ IC1-05, IC1-12, IC2-11, PCBC-13). HFS5-2060 and HFS5-2080 in the T-slot table (CORE-35).
105
+ - Boards: pinless parts (EDA-02), four-layer net-class rules (EDA-07), KiCad parity on no-connect pins, datasheets and
106
+ back-side text (EDA-08 to -10), interface sides that read a sheet, a board or a `.sch.py` (EDA-14), a fabrication
107
+ BOM by part number (EDA-19), `near` as a hard rule of the placer (EDA-20).
108
+ - Speed: a 1136-hole plate checks in about 5 s (was 4 min 54 s); a 206-body assembly in 45 s (was 4 min 41 s)
109
+ (LABS-04, IC2-06).
110
+
111
+ In this SDK
112
+
113
+ - `netclass(...)` states the rules a four-layer board needs: `min_width` (the narrowest track; `width` is what the
114
+ router lays), `edge_clearance` and `hole_clearance` (the least gaps to the board edge and to a hole),
115
+ `inner={"clearance": …, "width": …, "minWidth": …}` (the rules on inner copper layers) and `min_spokes` (the fewest
116
+ thermal spokes a pad needs to a pour). `commandagi check` holds the board to them and `commandagi export kicad`
117
+ writes them into the project and its `.kicad_dru` (microfab EDA-07).
118
+ - Every request (the client, a session's frames and its WebSocket, the 3D kernel's cloud and local calls) sends
119
+ `User-Agent: commandagi-python/<version>`. The platform's CDN refused the kernel's standard-library requests with
120
+ `error code: 1010` (microfab CORE-30).
121
+
7
122
  ## 0.6.2 (2026-10-16)
8
123
 
9
124
  No change in this SDK's code. The release carries `@commandagi/host` 0.6.2, which `commandagi check` and the local 3D
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: commandagi
3
- Version: 0.6.2
3
+ Version: 0.6.4
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,6 +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
+ # a virtual environment uv made has no pip: uv pip install --python .venv/bin/python commandagi (a uv project: uv add commandagi)
36
37
  export COMMANDAGI_API_KEY=cagi_... # Settings → API keys
37
38
  ```
38
39
 
@@ -279,7 +280,12 @@ graph (`run_module(...)["graph"]`) or the graph's JSON text. An entity is `{"bod
279
280
  ## Versions
280
281
 
281
282
  - A release is the tag `v<version>` in this repository and the same version on PyPI. Pin an exact version:
282
- `commandagi==0.6.2`. A range (`^`, `~=`, `>=`) takes the next release without asking you.
283
+ `pip install commandagi==0.6.4`, or in a virtual environment uv made (it has no pip)
284
+ `uv pip install --python .venv/bin/python commandagi==0.6.4`. 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.4`). The two
288
+ are upgraded apart, and a kernel of another version may read a document differently.
283
289
  - The three SDKs (Python, TypeScript, Rust) carry one version number. A vocabulary at version X in one language is
284
290
  the vocabulary at version X in the others.
285
291
  - A version promises nothing about the next one. CommandAGI keeps no compatibility layers: a release may rename or
@@ -5,6 +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
+ # a virtual environment uv made has no pip: uv pip install --python .venv/bin/python commandagi (a uv project: uv add commandagi)
8
9
  export COMMANDAGI_API_KEY=cagi_... # Settings → API keys
9
10
  ```
10
11
 
@@ -251,7 +252,12 @@ graph (`run_module(...)["graph"]`) or the graph's JSON text. An entity is `{"bod
251
252
  ## Versions
252
253
 
253
254
  - A release is the tag `v<version>` in this repository and the same version on PyPI. Pin an exact version:
254
- `commandagi==0.6.2`. A range (`^`, `~=`, `>=`) takes the next release without asking you.
255
+ `pip install commandagi==0.6.4`, or in a virtual environment uv made (it has no pip)
256
+ `uv pip install --python .venv/bin/python commandagi==0.6.4`. 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.4`). The two
260
+ are upgraded apart, and a kernel of another version may read a document differently.
255
261
  - The three SDKs (Python, TypeScript, Rust) carry one version number. A vocabulary at version X in one language is
256
262
  the vocabulary at version X in the others.
257
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.2"
63
+ __version__ = "0.6.4"
@@ -28,6 +28,8 @@ from typing import Any, Dict, Iterator, List, Optional
28
28
  import requests
29
29
  import websocket # from the `websocket-client` package
30
30
 
31
+ from .kernel import USER_AGENT
32
+
31
33
  from ._generated import (
32
34
  DEFAULT_BASE_URL,
33
35
  ENV_API_KEY,
@@ -90,6 +92,7 @@ class CommandAGI(GeneratedClient):
90
92
  "authorization": f"Bearer {self.api_key}",
91
93
  "content-type": "application/json",
92
94
  "mcp-protocol-version": "2025-06-18",
95
+ "user-agent": USER_AGENT,
93
96
  },
94
97
  data=json.dumps({
95
98
  "jsonrpc": "2.0",
@@ -222,7 +225,7 @@ class Session:
222
225
  }
223
226
  self._lock.notify_all()
224
227
 
225
- self._ws = websocket.WebSocketApp(url, on_message=on_message)
228
+ self._ws = websocket.WebSocketApp(url, header={"user-agent": USER_AGENT}, on_message=on_message)
226
229
  threading.Thread(
227
230
  target=lambda: self._ws.run_forever(ping_interval=20, ping_timeout=10, reconnect=3),
228
231
  daemon=True,
@@ -247,7 +250,7 @@ class Session:
247
250
  url = self.frame(fresh=fresh, timeout=timeout)["url"]
248
251
  if url.startswith("data:"):
249
252
  return base64.b64decode(url.split(",", 1)[1])
250
- r = self._client._http.get(url, headers={"authorization": f"Bearer {self._client.api_key}"}, timeout=60)
253
+ r = self._client._http.get(url, headers={"authorization": f"Bearer {self._client.api_key}", "user-agent": USER_AGENT}, timeout=60)
251
254
  r.raise_for_status()
252
255
  return r.content
253
256
 
@@ -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
@@ -32,7 +35,7 @@ from .element import Element, declarer_of
32
35
  from .tsx import to_tsx
33
36
  # The document vocabularies, one module each (``from commandagi.design.twod import drawing, rect``). Importing them
34
37
  # registers what each root element declares.
35
- from . import agents, business, fab, firmware, media, monitors, office, ontology, pcb, pdf, postal, records, schematic, standards, study, systems, tasks, testplans, threed, tolerances, twod # noqa: F401
38
+ from . import agents, business, fab, firmware, media, monitors, office, ontology, pcb, pdf, postal, records, schematic, standards, study, systems, flows, tasks, testplans, threed, tolerances, twod # noqa: F401
36
39
 
37
40
  __all__ = [
38
41
  "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},
@@ -0,0 +1,155 @@
1
+ """A process flow, declared in Python (``<name>.flow.py``): the ordered steps that make one thing, each with the tool it
2
+ visits, its recipe parameters with their units, its time and who does it, and the measurements taken in the process,
3
+ the same document and the same elements as the TypeScript SDK's JSX (``commandagi/design`` ``flows.ts``)::
4
+
5
+ from commandagi.design.flows import flow, tool, step, param, measure, visit
6
+
7
+ result = flow(
8
+ tool(id="coater", ref="stage1.bom.3d.py#coater", rate_per_hour=40, currency="USD"),
9
+ step(id="why", kind="note", instruction="Marks first: every later layer aligns to them."),
10
+ step(
11
+ param(name="speed", value=3000, unit="rpm"),
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"),
14
+ id="coat", order=1, tool="coater", by="in-house", minutes=6,
15
+ ),
16
+ name="Alignment marks", of="stage1.bom.3d.py#wafer",
17
+ )
18
+
19
+ A record is an element and its fields are the element's attributes (snake_case keywords: ``rate_per_hour`` is
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``).
22
+ """
23
+ from __future__ import annotations
24
+
25
+ import json
26
+ import math
27
+ import re
28
+ from typing import Any, Dict
29
+
30
+ from .documents import DocTree, Vocabulary, register_vocabulary
31
+ from .element import define
32
+
33
+ FLOW_STEP_KINDS = ["work", "note"]
34
+ FLOW_FIELDS = ["name", "description", "of"]
35
+ FLOW_TOOL_FIELDS = ["id", "ref", "name", "ratePerHour", "currency", "description"]
36
+ FLOW_STEP_FIELDS = ["id", "order", "kind", "tool", "fixture", "by", "minutes", "setupMinutes", "ratePerHour", "currency", "instruction",
37
+ "note"]
38
+ FLOW_PARAM_FIELDS = ["name", "value", "unit", "description"]
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"]
41
+
42
+ _CHILDREN = {"holds": "children"}
43
+ #: Every tag and what it holds (the TypeScript SDK's ``SIGNATURES``).
44
+ SIGNATURES: Dict[str, Dict[str, Any]] = {"flow": _CHILDREN, "tool": {}, "step": _CHILDREN, "param": {}, "measure": {}, "visit": {}}
45
+
46
+ __all__ = ["FLOW_STEP_KINDS", "SIGNATURES", "FLOW_VOCABULARY", *define(globals(), "flows", SIGNATURES)]
47
+
48
+ _ID = re.compile(r"[A-Za-z0-9][A-Za-z0-9._-]*")
49
+
50
+
51
+ def _where(tag: str, key: str, a: Dict[str, Any]) -> str:
52
+ return f"<{tag} {key}={json.dumps(a[key], ensure_ascii=False)}>" if key in a else f"<{tag}>"
53
+
54
+
55
+ def _num(v: Any) -> bool:
56
+ return isinstance(v, (int, float)) and not isinstance(v, bool) and math.isfinite(v)
57
+
58
+
59
+ def _check(cond: Any, message: str) -> None:
60
+ if not cond:
61
+ raise ValueError(message)
62
+
63
+
64
+ def _money(a: Dict[str, Any], at: str) -> None:
65
+ _check("ratePerHour" not in a or (_num(a["ratePerHour"]) and a["ratePerHour"] >= 0), f"{at}: ratePerHour is a number of at least 0 (money an hour)")
66
+ _check("currency" not in a or (isinstance(a["currency"], str) and re.fullmatch(r"[A-Z]{3}", a["currency"])),
67
+ f"{at}: currency is an ISO 4217 code (USD)")
68
+
69
+
70
+ def _tool(a: Dict[str, Any]) -> None:
71
+ at = _where("tool", "id", a)
72
+ _check(isinstance(a.get("id"), str) and _ID.fullmatch(a["id"]), f'{at}: id is letters, digits, ".", "_" and "-"')
73
+ _check("ref" not in a or (isinstance(a["ref"], str) and a["ref"].strip()),
74
+ f"{at}: ref is a device definition, or an item or body of a 3D document (<file>#<id>)")
75
+ _money(a, at)
76
+
77
+
78
+ def _step(t: DocTree) -> None:
79
+ a = t["attrs"]
80
+ at = _where("step", "id", a)
81
+ _check(isinstance(a.get("id"), str) and _ID.fullmatch(a["id"]), f'{at}: id is letters, digits, ".", "_" and "-"')
82
+ o = a.get("order")
83
+ _check("order" not in a or (isinstance(o, int) and not isinstance(o, bool) and o >= 1) or (isinstance(o, float) and o.is_integer() and o >= 1),
84
+ f"{at}: order is a whole number from 1")
85
+ _check("kind" not in a or a["kind"] in FLOW_STEP_KINDS, f"{at}: kind must be one of {', '.join(FLOW_STEP_KINDS)} (got {json.dumps(a.get('kind'))})")
86
+ for k in ("minutes", "setupMinutes"):
87
+ _check(k not in a or (_num(a[k]) and a[k] >= 0), f"{at}: {k} is a number of at least 0")
88
+ _money(a, at)
89
+ if a.get("kind") == "note":
90
+ _check("tool" not in a and a.get("minutes", 0) == 0 and not t["children"],
91
+ f"{at}: a note step names no tool, takes no time (minutes 0 or absent) and holds no param, measure or visit")
92
+ names = [c["attrs"].get("name") for c in t["children"] if c["tag"] == "param"]
93
+ twice = next((n for i, n in enumerate(names) if n in names[:i]), None)
94
+ _check(twice is None, f"{at}: two params are named {json.dumps(twice, ensure_ascii=False)}")
95
+ for c in t["children"]:
96
+ b = c["attrs"]
97
+ if c["tag"] == "param":
98
+ pat = _where("param", "name", b)
99
+ _check(isinstance(b.get("name"), str) and b["name"].strip(), f"{pat}: name says what the parameter is")
100
+ v = b.get("value")
101
+ _check(_num(v) or isinstance(v, (str, bool)), f"{pat}: value is a number, a text or true/false")
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)
109
+ else:
110
+ mat = _where("measure", "id", b)
111
+ _check(isinstance(b.get("id"), str) and _ID.fullmatch(b["id"]), f'{mat}: id is letters, digits, ".", "_" and "-"')
112
+ for k in ("nominal", "min", "max", "plus", "minus"):
113
+ _check(k not in b or _num(b[k]), f"{mat}: {k} is a number")
114
+ for k in ("plus", "minus"):
115
+ _check(k not in b or b[k] >= 0, f"{mat}: {k} is a number of at least 0")
116
+ _check(("plus" not in b and "minus" not in b) or "nominal" in b, f"{mat}: plus and minus are tolerances of the nominal: give nominal")
117
+ _check("min" not in b or "max" not in b or b["min"] <= b["max"], f"{mat}: min is at most max")
118
+
119
+
120
+ def _step_record(t: DocTree) -> Dict[str, Any]:
121
+ params = [dict(c["attrs"]) for c in t["children"] if c["tag"] == "param"]
122
+ measures = [dict(c["attrs"]) for c in t["children"] if c["tag"] == "measure"]
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 {})}
125
+
126
+
127
+ def _flow(t: DocTree) -> Dict[str, Any]:
128
+ _check("of" not in t["attrs"] or isinstance(t["attrs"]["of"], str),
129
+ "<flow>: of is a ref to what the flow makes (a 3D document, or <file>#<item or body>)")
130
+ for c in t["children"]:
131
+ _tool(c["attrs"]) if c["tag"] == "tool" else _step(c)
132
+ measures = [m["attrs"].get("id") for c in t["children"] for m in c["children"] if m["tag"] == "measure"]
133
+ again = next((m for i, m in enumerate(measures) if m in measures[:i]), None)
134
+ _check(again is None, f"<measure id={json.dumps(again, ensure_ascii=False)}>: two measures have this id (a ref names it as <file>#<id>)")
135
+ tools = [dict(c["attrs"]) for c in t["children"] if c["tag"] == "tool"]
136
+ steps = [_step_record(c) for c in t["children"] if c["tag"] == "step"]
137
+ own = {k: t["attrs"][k] for k in FLOW_FIELDS if k in t["attrs"]}
138
+ return {**own, **({"tools": tools} if tools else {}), **({"steps": steps} if steps else {})}
139
+
140
+
141
+ def _never(_: Any) -> DocTree:
142
+ raise NotImplementedError("the editor makes the tree from a document (the TypeScript SDK's toTree)")
143
+
144
+
145
+ FLOW_VOCABULARY = Vocabulary("flow", "a process flow", "flow", {
146
+ "flow": {"parents": [], "attrs": FLOW_FIELDS},
147
+ "tool": {"parents": ["flow"], "key": "id", "required": ["id"], "attrs": FLOW_TOOL_FIELDS},
148
+ "step": {"parents": ["flow"], "key": "id", "required": ["id"], "attrs": FLOW_STEP_FIELDS},
149
+ "param": {"parents": ["step"], "required": ["name", "value"], "attrs": FLOW_PARAM_FIELDS},
150
+ "measure": {"parents": ["step"], "key": "id", "required": ["id"], "attrs": FLOW_MEASURE_FIELDS},
151
+ "visit": {"parents": ["step"], "required": ["tool"], "attrs": FLOW_VISIT_FIELDS},
152
+ }, _flow, _never, lambda name: {"name": name})
153
+
154
+ register_vocabulary(FLOW_VOCABULARY, "flows")
155
+
@@ -18,7 +18,8 @@ form the board editor writes), so the BOM, the KiCad board and a 3D body's join
18
18
 
19
19
  The keys inside these dicts are the data's own (camelCase, as the JSON holds them); only the arguments are snake_case.
20
20
  A supplier is two properties: ``<name> Part`` (its sku; ``LCSC Part`` is what JLCPCB's assembly BOM reads) and
21
- ``<name> Terms`` (the rest as compact JSON, a price break as [quantity, unitPrice]). ``Datasheet`` is KiCad's own field;
21
+ ``<name> Terms`` (the rest as compact JSON, a price break as [quantity, unitPrice], or [quantity, unitPrice,
22
+ unitPriceHigh] for an estimate range). ``Datasheet`` is KiCad's own field;
22
23
  ``Alternates`` is JSON; a facet's fields are one property each (``Lifecycle``, ``RoHS``, ``HS Code`` …).
23
24
 
24
25
  ``datasheet`` says where the part's datasheet is (KiCad's ``Datasheet`` field); it claims nothing. ``pinout_verified``
@@ -191,10 +192,13 @@ def check_offers(where: str, v: Any) -> List[Dict[str, Any]]:
191
192
  breaks = s.get("priceBreaks")
192
193
  if breaks is not None:
193
194
  ok = isinstance(breaks, (list, tuple)) and all(
194
- isinstance(b, dict) and len(b) == 2 and _whole(b.get("quantity"), 1) and _number(b.get("unitPrice")) and b["unitPrice"] >= 0
195
+ isinstance(b, dict) and set(b) <= {"quantity", "unitPrice", "unitPriceHigh"} and _whole(b.get("quantity"), 1)
196
+ and _number(b.get("unitPrice")) and b["unitPrice"] >= 0
197
+ and ("unitPriceHigh" not in b or (_number(b["unitPriceHigh"]) and b["unitPriceHigh"] >= b["unitPrice"]))
195
198
  for b in breaks)
196
199
  if not ok:
197
- raise ValueError(f"{at}: priceBreaks is a list of {{ quantity, unitPrice }} (quantity a whole number from 1, unitPrice 0 or more)")
200
+ raise ValueError(f"{at}: priceBreaks is a list of {{ quantity, unitPrice, unitPriceHigh? }} (quantity a whole number from 1, "
201
+ "unitPrice 0 or more, unitPriceHigh not under it)")
198
202
  out.append({k: copy.deepcopy(x) for k, x in s.items() if x is not None})
199
203
  return out
200
204
 
@@ -205,7 +209,8 @@ def _offer_forms(where: str, v: Any) -> List[Dict[str, Any]]:
205
209
  terms: Dict[str, Any] = {}
206
210
  for k in _OFFER_TERMS:
207
211
  if s.get(k) is not None:
208
- terms[k] = [[b["quantity"], b["unitPrice"]] for b in s[k]] if k == "priceBreaks" else s[k]
212
+ terms[k] = [[b["quantity"], b["unitPrice"], *([b["unitPriceHigh"]] if "unitPriceHigh" in b else [])] for b in s[k]] \
213
+ if k == "priceBreaks" else s[k]
209
214
  if s.get("sku") is not None:
210
215
  forms.append(field_form(f"{s['name']} Part", s["sku"]))
211
216
  if terms or s.get("sku") is None:
@@ -241,8 +246,8 @@ def check_facet(where: str, arg: str, v: Any) -> Dict[str, Any]:
241
246
  raise ValueError(f'{where}: {key} is one of {", ".join(_CHOICES[key])} (got "{x}")')
242
247
  if key in _DATES and not _DAY.match(x):
243
248
  raise ValueError(f"{where}: {key} is YYYY-MM-DD")
244
- if key == "shipping.origin" and not re.match(r"^[A-Z]{2}$", x):
245
- 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"')
246
251
  return {k: copy.deepcopy(x) for k, x in v.items() if x is not None}
247
252
 
248
253
 
@@ -324,7 +329,8 @@ def part_fields(inputs: Mapping[str, Any]) -> Dict[str, Any]:
324
329
  s = supplier(name[:-6])
325
330
  for k in _OFFER_TERMS:
326
331
  if terms.get(k) is not None:
327
- s[k] = [{"quantity": q, "unitPrice": p} for q, p in terms[k]] if k == "priceBreaks" else terms[k]
332
+ s[k] = [{"quantity": b[0], "unitPrice": b[1], **({"unitPriceHigh": b[2]} if len(b) > 2 else {})} for b in terms[k]] \
333
+ if k == "priceBreaks" else terms[k]
328
334
  elif arg == "alternates":
329
335
  out["alternates"] = json.loads(value)
330
336
  elif arg == "datasheet":
@@ -47,8 +47,12 @@ The calls (children are positional; every attribute is a keyword):
47
47
 
48
48
  The layout's constraints (the board's design intent: the placer, the router, the layout score and the checks read
49
49
  them; the editor and the layout operations write each one back):
50
- netclass(name, nets, kind, width, clearance, via_diameter, via_drill, current, criticality, max_length, max_vias, impedance)
51
- the rules of the nets named ("FIN*" matches by prefix).
50
+ netclass(name, nets, kind, width, min_width, clearance, edge_clearance, hole_clearance, inner, min_spokes,
51
+ via_diameter, via_drill, current, criticality, max_length, max_vias, impedance)
52
+ the rules of the nets named ("FIN*" matches by prefix): the width the router
53
+ lays and the narrowest allowed (``min_width``), the gaps to copper, to the
54
+ board edge and to a hole, the rules on inner layers (``inner``: {"clearance",
55
+ "width", "minWidth"}), the fewest thermal spokes a pad needs to a pour.
52
56
  diffpair(name, positive, negative, gap, width, impedance, max_skew)
53
57
  group(name, parts, region, near, max_distance, conviction, side)
54
58
  parts placed together: in the box ``region`` [x0, y0, x1, y1], within
@@ -256,7 +260,7 @@ def _constraint_fact(el: Element) -> Dict[str, Any]:
256
260
  return v
257
261
 
258
262
  if el.tag == "netclass":
259
- _refuse_unknown(el, ["name", "nets", "kind", "width", "clearance", "viaDiameter", "viaDrill", "current", "criticality", "maxLength", "maxVias", "impedance"])
263
+ _refuse_unknown(el, ["name", "nets", "kind", "width", "minWidth", "clearance", "edgeClearance", "holeClearance", "inner", "minSpokes", "viaDiameter", "viaDrill", "current", "criticality", "maxLength", "maxVias", "impedance"])
260
264
  kind = _text(el, "kind")
261
265
  if kind is not None and kind not in _NET_KINDS:
262
266
  raise ValueError(f"{_where(el)}: kind is {', '.join(_NET_KINDS)}")
@@ -266,10 +270,17 @@ def _constraint_fact(el: Element) -> Dict[str, Any]:
266
270
  put("name", _text(el, "name", True))
267
271
  put("nets", names("nets", True))
268
272
  put("kind", kind)
269
- for k in ("width", "clearance", "viaDiameter", "viaDrill", "current", "maxLength", "impedance"):
273
+ for k in ("width", "minWidth", "clearance", "edgeClearance", "holeClearance", "viaDiameter", "viaDrill", "current", "maxLength", "impedance"):
270
274
  put(k, _positive(el, k))
271
275
  put("criticality", unit("criticality"))
272
276
  put("maxVias", max_vias)
277
+ if out.get("minWidth") is not None and out.get("width") is not None and out["minWidth"] > out["width"]:
278
+ raise ValueError(f"{_where(el)}: minWidth is at most width")
279
+ put("inner", _plain(el, "inner", lambda v: _is_object(v) and len(v) > 0 and all(k in ("clearance", "width", "minWidth") and _is_num(x) and x > 0 for k, x in v.items()), "the rules on inner copper layers: { clearance, width, minWidth } (mm)"))
280
+ spokes = _num(el, "minSpokes")
281
+ if spokes is not None and not (float(spokes).is_integer() and 0 <= spokes <= 4):
282
+ raise ValueError(f"{_where(el)}: minSpokes is a whole number from 0 to 4")
283
+ put("minSpokes", spokes)
273
284
  if out.get("viaDiameter") is not None and out.get("viaDrill") is not None and out["viaDiameter"] <= out["viaDrill"]:
274
285
  raise ValueError(f"{_where(el)}: viaDiameter is more than viaDrill")
275
286
  elif el.tag == "diffpair":
@@ -88,7 +88,8 @@ def sized_hole(hole: Dict[str, Any]) -> Dict[str, Any]:
88
88
  tables give for that thread (a counterbore for a hexagon socket head cap screw, DIN 974-1; a countersink for a
89
89
  countersunk screw, DIN 74 form F, its depth from its diameter and angle). The size wins: a ``diameter``,
90
90
  ``headDiameter`` or ``headDepth`` that differs from the size's is refused. Leave it out, or clear ``size`` to give
91
- your own."""
91
+ your own. One choice stays yours: a counterbore deeper than the size's (``headDepth`` more than the table's) sinks
92
+ the head below the face."""
92
93
  if not isinstance(hole.get("size"), str):
93
94
  return hole
94
95
  named = hole_size(hole["size"])
@@ -102,10 +103,14 @@ def sized_hole(hole: Dict[str, Any]) -> Dict[str, Any]:
102
103
  says["headDiameter"] = sink["diameter"]
103
104
  depth = (sink["diameter"] - named["diameter"]) / 2 / math.tan(sink["angleDeg"] * math.pi / 360)
104
105
  says["headDepth"] = math.floor(depth * 1e4 + 0.5) / 1e4
106
+ depth = hole.get("headDepth")
107
+ if hole.get("style") == "counterbore" and "headDepth" in says and _is_number(depth) and depth > says["headDepth"]:
108
+ says["headDepth"] = depth
105
109
  for field, value in says.items():
106
110
  written = hole.get(field)
107
111
  if _is_number(written) and abs(written - value) > 1e-9:
108
- raise ValueError(f'{field}: "{hole["size"]}" is {_number(value)} mm (got {_number(written)}); leave {field} out, or clear size')
112
+ deeper = " (a counterbore may be deeper than the size's, not shallower)" if field == "headDepth" and hole.get("style") == "counterbore" else ""
113
+ raise ValueError(f'{field}: "{hole["size"]}" is {_number(value)} mm (got {_number(written)}); leave {field} out, or clear size{deeper}')
109
114
  return {**hole, **says}
110
115
 
111
116