-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(sdk): Add lib version to any outgoing requests for debugging purposes #1112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b67e311
add version header to sdk requests
mdean808 c69e3c3
Merge branch 'main' into feat/sdk-versions
mdean808 52316c9
Send sdk versions in all requests
mdean808 b40cbec
Run lint
mdean808 b2ecad6
add griffe to root pyproject for docs gen
mdean808 f0d904e
docs gen
mdean808 bfdd450
Fix import order
mdean808 988df32
use workspace for versioning so our ci doesn't fail without published…
mdean808 c51a7cc
use bun
mdean808 25d594e
parse package.json relatively
mdean808 cf4750a
Format
mdean808 8773b65
address coderabbit
mdean808 106d766
fix lint
mdean808 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| """Core functionality shared across Cua components.""" | ||
|
|
||
| __version__ = "0.1.8" | ||
|
|
||
| from core.http import CUA_CLIENT_VERSION_HEADER, cua_version_headers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| """Shared HTTP utilities for CUA SDK requests.""" | ||
|
|
||
| from functools import lru_cache | ||
|
|
||
| CUA_CLIENT_VERSION_HEADER = "X-Cua-Client-Version" | ||
|
|
||
| # CUA packages whose versions are included in the header value. | ||
| _CUA_PACKAGES = ("cua-agent", "cua-computer", "cua-core") | ||
|
|
||
|
|
||
| @lru_cache(maxsize=1) | ||
| def _build_version_string() -> str: | ||
| """Return a composite version string like ``agent:0.4.0 computer:0.1.0 core:0.1.8``.""" | ||
| from importlib.metadata import PackageNotFoundError, version | ||
|
|
||
| parts: list[str] = [] | ||
| for pkg in _CUA_PACKAGES: | ||
| try: | ||
| short = pkg.removeprefix("cua-") | ||
| parts.append(f"{short}:{version(pkg)}") | ||
| except PackageNotFoundError: | ||
| continue | ||
| return " ".join(parts) | ||
|
|
||
|
|
||
| def cua_version_headers() -> dict[str, str]: | ||
| """Return headers dict containing the CUA client version header. | ||
|
|
||
| Only installed CUA packages are included. If none are found the dict is | ||
| empty so it is always safe to unpack with ``**cua_version_headers()``. | ||
| """ | ||
| value = _build_version_string() | ||
| if not value: | ||
| return {} | ||
| return {CUA_CLIENT_VERSION_HEADER: value} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: trycua/cua
Length of output: 3171
🏁 Script executed:
Repository: trycua/cua
Length of output: 1214
🏁 Script executed:
Repository: trycua/cua
Length of output: 1905
Use relative imports for consistency with other local imports in this file.
The absolute
from core.http import cua_version_headersis inconsistent with other intra-project imports likefrom ..base import ...andfrom ..types import .... This pattern appears in multiple files but still depends oncorebeing onsys.path, making imports fragile to packaging restructures. Consider converting to a relative import or centralizing thecoremodule handling across the codebase.🤖 Prompt for AI Agents