hank-risk-client 0.3.2__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.
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.4
2
+ Name: hank-risk-client
3
+ Version: 0.3.2
4
+ Requires-Python: >=3.11
5
+ Requires-Dist: requests<3,>=2.32
@@ -0,0 +1,127 @@
1
+ # risk_client
2
+
3
+
4
+ `risk_client` is the thin native HTTP client for Risk's registered agent/tool surface. Code execution uses the same opaque active-cell capability as gateway frames; trusted non-code automation retains signed user claims.
5
+
6
+ ## Requirements
7
+
8
+ `RiskClient 0.3.1` requires `RISK_API_URL` only when it issues native HTTP requests; constructing the client does not require a Risk endpoint for cells that never use it. During native code execution, the runtime supplies `AGENT_CODE_EXECUTE_CELL_TOKEN` only while the cell executes. Discovery and every raw call are verified by the Risk producer against the owning cell's current grant and explicit native registration. No signing key, broad subject bearer or TTL credential is needed in code.
9
+
10
+ A retained client rereads the current token on every request, so a later cell cannot reuse an earlier grant. After release, its last token is sent to the producer and rejected there; the client does not fall back to broader signed authority.
11
+
12
+ Trusted non-code callers continue to provide all seven signed-claim variables:
13
+
14
+ - `AGENT_API_CLAIM_AUDIENCE`
15
+ - `AGENT_API_CLAIM_ISSUED_AT`
16
+ - `AGENT_API_CLAIM_EXPIRY`
17
+ - `AGENT_API_CLAIM_USER_ID`
18
+ - `AGENT_API_CLAIM_USER_EMAIL`
19
+ - `AGENT_API_CLAIM_NONCE`
20
+ - `AGENT_API_CLAIM_SIGNATURE`
21
+
22
+ `RISK_API_KEY` bearer fallback is not supported by this client. The HTTP API's ordinary legacy/signed consumers remain separate and compatible; adding an invalid cell header never downgrades to either mode.
23
+
24
+ ## Typed Usage
25
+
26
+ ```python
27
+ from risk_client import RiskClient
28
+
29
+ rc = RiskClient()
30
+ print(rc.registry()) # Current-cell native intersection, not all installed methods.
31
+ quote = rc.get_quote(ticker="MSFT") # Requires this producer operation in the grant.
32
+ print(quote)
33
+ ```
34
+
35
+ TypedDict return contracts are curated for the Tier A tools. Other wrappers still return `ToolResult` (`dict[str, Any]`) but keep typed parameter signatures.
36
+
37
+ ## Breaking Change In 0.3.0
38
+
39
+ HTTP errors from `call()` and `registry()` are now wrapped in `AgentAPIError` with `.status` and `.error_type` populated. `requests.HTTPError` is no longer raised by those methods. Network errors (`ConnectionError`, `Timeout`, SSL) propagate unchanged. Server-side 404s on `call()` include a "Did you mean" suggestion when a close function name exists, and generated multi-format wrappers now include a `Formats:` line in their docstring.
40
+
41
+ Before:
42
+
43
+ ```python
44
+ import requests
45
+
46
+ try:
47
+ rc.call("get_postions")
48
+ except requests.HTTPError as e:
49
+ print(e)
50
+ ```
51
+
52
+ After:
53
+
54
+ ```python
55
+ from risk_client import AgentAPIError
56
+
57
+ try:
58
+ rc.call("get_postions")
59
+ except AgentAPIError as e:
60
+ print(e.status, e.error_type, e)
61
+ # 404 unknown_function get_postions: Unknown function: 'get_postions'. Did you mean 'get_positions'?
62
+ ```
63
+
64
+ ## Breaking Change In 0.2.0
65
+
66
+ Generated wrapper methods now return the inner `result` payload and raise `AgentAPIError` on `{ok: false}` responses.
67
+
68
+ Before:
69
+
70
+ ```python
71
+ envelope = rc.get_positions(format="agent")
72
+ snapshot = envelope["result"]["snapshot"]
73
+ ```
74
+
75
+ After:
76
+
77
+ ```python
78
+ result = rc.get_positions(format="agent")
79
+ snapshot = result["snapshot"]
80
+ ```
81
+
82
+ If you still need the raw HTTP envelope, use `call()` directly:
83
+
84
+ ```python
85
+ envelope = rc.call("get_positions", format="agent")
86
+ ```
87
+
88
+ If you want the same inner-result behavior used by generated wrappers, use `call_or_raise()`:
89
+
90
+ ```python
91
+ result = rc.call_or_raise("get_positions", format="agent")
92
+ ```
93
+
94
+ ## Standalone Installation
95
+
96
+ `RISK_CLIENT_PATH` names the Risk checkout root, not the `risk_client` directory.
97
+ Install the local package into the interpreter that will run your code:
98
+
99
+ ```bash
100
+ export RISK_CLIENT_PATH=/path/to/risk_module
101
+ python -m pip install "$RISK_CLIENT_PATH/risk_client"
102
+ python -c 'from risk_client import RiskClient; print("RiskClient import OK")'
103
+ ```
104
+
105
+ The distribution includes the client, return types, and shared telemetry header
106
+ contract. It needs only its declared `requests` dependency, not the Risk backend
107
+ or a checkout entry on `PYTHONPATH`. Creating a client requires either the
108
+ executing cell's opaque token or the ordinary signed-claim environment.
109
+ Call and registry requests additionally require the configured API URL.
110
+
111
+ ## Code-executor installation and attribution
112
+
113
+ Supported product executors install the narrow client artifact from the selected
114
+ Risk revision. Do not expose the backend checkout or rely on a mounted source
115
+ tree to repair a missing SDK.
116
+
117
+ Native call envelopes add canonical parent/nested call IDs, ordinal, operation
118
+ and a producer-generated request ID in `meta`; ordinary envelopes are unchanged.
119
+ The gateway's owning cell ledger retains native calls, complete deduplicated
120
+ returned citation sources and untruncated producer computation provenance.
121
+ `tool_version` and `output_sha256` are computation evidence, not citations.
122
+ The gateway computation collector projects every valid native ledger entry
123
+ into `computations`, untruncated and with its `nested_call_id`; the existing
124
+ source consumer then recognizes actual hashes.
125
+ The SDK does not write computation sidecar files. Native computation evidence
126
+ is settled by the producer into the owning cell ledger; ordinary trusted HTTP
127
+ keeps its signed authentication and response envelope without local file I/O.