Skip to content

Feat/rpa harness#20

Open
3338682145 wants to merge 4 commits intoEinsia:mainfrom
3338682145:feat/rpa-harness
Open

Feat/rpa harness#20
3338682145 wants to merge 4 commits intoEinsia:mainfrom
3338682145:feat/rpa-harness

Conversation

@3338682145
Copy link
Copy Markdown

Summary

  • Add RPA harness documentation and examples
  • Add RPA provider, safety, trace, workflow, and manifest tests
  • Extend ADB safety/tools integration

Verification

  • Added tests for RPA manifest, provider, safety, trace, and workflow

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces cross-platform support for OpenChronicle by adding Windows UI Automation (UIA) as a capture source and implementing a new RPA harness for pluggable automation providers, including an Android ADB provider. The changes include updates to configuration paths, daemon management for Windows, and robust file I/O operations. I have provided feedback regarding the use of read_bytes() for JSON parsing to improve encoding handling and a minor null-check optimization for the Windows UIA provider.

Comment thread src/openchronicle/capture/scheduler.py Outdated
"""Rewrite a capture JSON without its ``screenshot`` field. Returns True if stripped."""
try:
raw = path.read_text()
raw = path.read_text(encoding="utf-8")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When parsing JSON files, it is recommended to use read_bytes() and pass the result to json.loads() to let the JSON library handle encoding detection and prevent unhandled UnicodeDecodeError exceptions.

Suggested change
raw = path.read_text(encoding="utf-8")
raw = path.read_bytes()
References
  1. When parsing JSON files, use read_bytes() and pass the result to json.loads() to let the JSON library handle encoding detection and prevent unhandled UnicodeDecodeError exceptions, which are a type of ValueError and may not be caught by OSError handlers.

Comment thread src/openchronicle/cli.py Outdated
return {}
try:
data = json.loads(path.read_text())
data = json.loads(path.read_text(encoding="utf-8"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When parsing JSON files, it is recommended to use read_bytes() and pass the result to json.loads() to let the JSON library handle encoding detection and prevent unhandled UnicodeDecodeError exceptions.

Suggested change
data = json.loads(path.read_text(encoding="utf-8"))
data = json.loads(path.read_bytes())
References
  1. When parsing JSON files, use read_bytes() and pass the result to json.loads() to let the JSON library handle encoding detection and prevent unhandled UnicodeDecodeError exceptions, which are a type of ValueError and may not be caught by OSError handlers.

Comment thread src/openchronicle/cli.py Outdated
return {}
try:
data = json.loads(path.read_text())
data = json.loads(path.read_text(encoding="utf-8"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When parsing JSON files, it is recommended to use read_bytes() and pass the result to json.loads() to let the JSON library handle encoding detection and prevent unhandled UnicodeDecodeError exceptions.

Suggested change
data = json.loads(path.read_text(encoding="utf-8"))
data = json.loads(path.read_bytes())
References
  1. When parsing JSON files, use read_bytes() and pass the result to json.loads() to let the JSON library handle encoding detection and prevent unhandled UnicodeDecodeError exceptions, which are a type of ValueError and may not be caught by OSError handlers.

Comment thread src/openchronicle/cli.py Outdated
for p in files:
try:
data = json.loads(p.read_text())
data = json.loads(p.read_text(encoding="utf-8"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When parsing JSON files, it is recommended to use read_bytes() and pass the result to json.loads() to let the JSON library handle encoding detection and prevent unhandled UnicodeDecodeError exceptions.

Suggested change
data = json.loads(p.read_text(encoding="utf-8"))
data = json.loads(p.read_bytes())
References
  1. When parsing JSON files, use read_bytes() and pass the result to json.loads() to let the JSON library handle encoding detection and prevent unhandled UnicodeDecodeError exceptions, which are a type of ValueError and may not be caught by OSError handlers.

Comment thread src/openchronicle/mcp/captures.py Outdated
def _load_capture(path: Path) -> dict[str, Any] | None:
try:
return json.loads(path.read_text())
return json.loads(path.read_text(encoding="utf-8"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When parsing JSON files, it is recommended to use read_bytes() and pass the result to json.loads() to let the JSON library handle encoding detection and prevent unhandled UnicodeDecodeError exceptions.

Suggested change
return json.loads(path.read_text(encoding="utf-8"))
return json.loads(path.read_bytes())
References
  1. When parsing JSON files, use read_bytes() and pass the result to json.loads() to let the JSON library handle encoding detection and prevent unhandled UnicodeDecodeError exceptions, which are a type of ValueError and may not be caught by OSError handlers.

Comment thread src/openchronicle/rpa/manifest.py Outdated
def load_manifest(path: str | Path) -> ProviderManifest:
manifest_path = Path(path)
try:
data = json.loads(manifest_path.read_text(encoding="utf-8"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When parsing JSON files, it is recommended to use read_bytes() and pass the result to json.loads() to let the JSON library handle encoding detection and prevent unhandled UnicodeDecodeError exceptions.

Suggested change
data = json.loads(manifest_path.read_text(encoding="utf-8"))
data = json.loads(manifest_path.read_bytes())
References
  1. When parsing JSON files, use read_bytes() and pass the result to json.loads() to let the JSON library handle encoding detection and prevent unhandled UnicodeDecodeError exceptions, which are a type of ValueError and may not be caught by OSError handlers.

Comment thread src/openchronicle/rpa/workflow.py Outdated
def load_workflow(path: str | Path) -> dict[str, Any]:
workflow_path = Path(path)
try:
data = json.loads(workflow_path.read_text(encoding="utf-8"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When parsing JSON files, it is recommended to use read_bytes() and pass the result to json.loads() to let the JSON library handle encoding detection and prevent unhandled UnicodeDecodeError exceptions.

Suggested change
data = json.loads(workflow_path.read_text(encoding="utf-8"))
data = json.loads(workflow_path.read_bytes())
References
  1. When parsing JSON files, use read_bytes() and pass the result to json.loads() to let the JSON library handle encoding detection and prevent unhandled UnicodeDecodeError exceptions, which are a type of ValueError and may not be caught by OSError handlers.

Comment on lines +273 to +274
if _control_identity(focused) != _control_identity(foreground):
focused_el = _element_from_control(focused, depth=min(self._depth, 3), budget=budget)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The focused control can be None if _safe_focused_control fails. While _element_from_control handles None gracefully by returning None, it is more efficient to check for None before calling it.

Suggested change
if _control_identity(focused) != _control_identity(foreground):
focused_el = _element_from_control(focused, depth=min(self._depth, 3), budget=budget)
if focused is not None and _control_identity(focused) != _control_identity(foreground):
focused_el = _element_from_control(focused, depth=min(self._depth, 3), budget=budget)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant