The introspection.py module#
Summary#
Return the Mechanical script that searches the Outline tree. |
|
Return the Mechanical script that describes one object. |
|
Return the Mechanical script that searches the API of the connected release. |
|
Return the Mechanical script that validates a property change without applying it. |
|
Return the Mechanical script that applies a previewed property change. |
|
Return the Mechanical script that compiles a script and resolves its API names. |
|
Return the candidates closest to |
|
Collect attribute chains rooted in names the script does not define itself. |
|
Record a valid preview and return its single-use token. |
|
Consume a preview token, checking that it matches this session and change. |
Description#
Object discovery, property change previews, and script checks.
The Mechanical-side scripts here inspect the connected session itself, so the results always match the connected release instead of a bundled API snapshot. They run in the Mechanical scripting engine, which is IronPython 2.7 for remote sessions, so they avoid f-strings and annotations. Tool arguments reach them as a base64-encoded JSON payload, which cannot break out of the script text.
Module detail#
- introspection.find_objects_script(args: dict[str, Any]) str#
Return the Mechanical script that searches the Outline tree.
- introspection.describe_object_script(args: dict[str, Any]) str#
Return the Mechanical script that describes one object.
- introspection.search_api_script(args: dict[str, Any]) str#
Return the Mechanical script that searches the API of the connected release.
- introspection.preview_change_script(args: dict[str, Any]) str#
Return the Mechanical script that validates a property change without applying it.
- introspection.apply_change_script(args: dict[str, Any]) str#
Return the Mechanical script that applies a previewed property change.
- introspection.check_script_script(args: dict[str, Any]) str#
Return the Mechanical script that compiles a script and resolves its API names.
- introspection.close_matches(word: str, candidates: list[str], limit: int = 3) list[str]#
Return the candidates closest to
word, preferring a case-insensitive match.
- introspection.extract_api_chains(script: str) tuple[list[dict[str, Any]], dict[str, Any] | None, bool]#
Collect attribute chains rooted in names the script does not define itself.
- introspection.store_preview(store: dict[str, dict[str, Any]], mechanical: Any, object_id: int, property_name: str, value: Any, fingerprint: str) str#
Record a valid preview and return its single-use token.
- introspection.take_preview(store: dict[str, dict[str, Any]], token: str, mechanical: Any, object_id: int, property_name: str, value: Any) dict[str, Any]#
Consume a preview token, checking that it matches this session and change.
- Raises:
StalePreviewErrorIf the token is unknown, already used, expired, or from another session.
InvalidArgumentsErrorIf the token was issued for a different object, property, or value.
- introspection.PREVIEW_TTL_SECONDS = 600#
- introspection.MAX_PENDING_PREVIEWS = 100#
- introspection.MAX_CHECKED_CHAINS = 300#