agenticdome-python-sdk 1.2.47__py3-none-any.whl → 1.2.49__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agenticdome-python-sdk
3
- Version: 1.2.47
3
+ Version: 1.2.49
4
4
  Summary: Official Python SDK for AgenticDome security guardrails, DLP, tool authorization, and multi-agent delegation enforcement.
5
5
  Author: AgenticDome
6
6
  License-Expression: Apache-2.0
@@ -2899,3 +2899,20 @@ The Python SDK client, public examples, and public SDK documentation in this rep
2899
2899
  Security vulnerabilities must be reported privately as described in [SECURITY.md](https://github.com/agenticdome/agenticdome-python-sdk/blob/main/SECURITY.md), not through a public issue.
2900
2900
 
2901
2901
  For enterprise deployments, advanced governance workflows, dedicated regional control planes, or priority integration support, visit **[agenticdome.io](https://agenticdome.io)**.
2902
+ ## Exact HTTP execution
2903
+
2904
+ `client.execute_http(method=..., url=..., body=..., headers=..., agent_id=...,
2905
+ tool_name=..., request_purpose=...)` authorizes and sends the same bounded UTF-8
2906
+ request. It requires a compatible sidecar broker and refuses redirects. It
2907
+ raises `ApprovalRequired` before sending when human review is required; resume
2908
+ with `client.resume_approved_http(pending, headers=...)` after approval. Fresh
2909
+ API authentication headers may be supplied; reviewed content and If-Match,
2910
+ If-None-Match or If-Unmodified-Since preconditions cannot change. Existing
2911
+ generic tool callbacks keep their existing contract. Network-level protection
2912
+ also requires routing through a compatible enforcing gateway with direct egress
2913
+ controlled. A returned HTTP response is the provider's outcome, separate from
2914
+ the policy decision and gateway admission.
2915
+
2916
+ ### Shared resource adapters and GraphQL
2917
+
2918
+ `OwnershipGuard` and `ResourceRule` verify tenant, resource identity, ownership or explicit entitlements and permitted operations through trusted provider callbacks. Attach the guard to the client or MCP gateway; HTTP approval resume rechecks current facts. `execute_graphql` sends exact prepared JSON through the interpreting sidecar. GraphQL rules use `tool#Mutation.field` and resolved field arguments, never an asserted owner or unused variable. See [resource adapter examples](docs/resource-adapters.md).
@@ -1,6 +1,6 @@
1
- agenticdome_python_sdk-1.2.47.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
2
- agenticdome_python_sdk-1.2.47.dist-info/licenses/NOTICE,sha256=obvKP6kV1Ny5R8_INFOpf0X5um9U2X43LGwQFobO9kg,550
3
- agenticdome_sdk/__init__.py,sha256=j3-Auc4es9obpMYJzT7PX3W4K475zXPSKr8jZMr9hDU,1144
1
+ agenticdome_python_sdk-1.2.49.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
2
+ agenticdome_python_sdk-1.2.49.dist-info/licenses/NOTICE,sha256=obvKP6kV1Ny5R8_INFOpf0X5um9U2X43LGwQFobO9kg,550
3
+ agenticdome_sdk/__init__.py,sha256=7nGHtISU9udPIEepFh2JFzZ8trV44ziv1o19RClpls0,1270
4
4
  agenticdome_sdk/_framework_firewall.py,sha256=87VViabk5bySrN36BCE_Wzooqlz653L21r6usyq_d_Q,32914
5
5
  agenticdome_sdk/_mode.py,sha256=XvOgh5sW-FG8S39V483h3uLiFh8wSt14OmYXz_6eDO8,1283
6
6
  agenticdome_sdk/action_path_proof.py,sha256=5Zlghy7-LNhtRJM0Unb4NPUASzIsAC0LaWNVFR2yzzo,13497
@@ -8,41 +8,43 @@ agenticdome_sdk/agno.py,sha256=L3yfjTBHW47xzT67a1DsjtwmvrAoYBkbxADpsr85Cp0,60766
8
8
  agenticdome_sdk/attestation.py,sha256=ij4cMff7nzLaIS0W02d2WURFcyKe72bcUlSz-dYkaLE,10310
9
9
  agenticdome_sdk/autogen.py,sha256=KP4qlIcsNXB-4ZT9D7Slc1xWEeWXRIWkc5HGW0U6k2c,29018
10
10
  agenticdome_sdk/aws_bedrock.py,sha256=2zD9j7xi0jna0sMeMf-hKZdc3Y4RPwzj6tMVOUGgIDQ,69581
11
- agenticdome_sdk/catalog_snapshot.json,sha256=C9_V73H8v39i21EZYqOCGwYwAqxBCLU_ltq6p5XhE6E,957
11
+ agenticdome_sdk/catalog_snapshot.json,sha256=FAyMJzT7mSreSSIm4ETCHENVKYNikHkVY47LVbvn_so,957
12
12
  agenticdome_sdk/claude.py,sha256=XeY9AUu61SYcJjQVz_AtL_WaN6X4KqP5nprEbbr4Q6A,17456
13
- agenticdome_sdk/client.py,sha256=ZNuP0k5bBrB73H4vAto6Ny5S0qP8KsalOqZHZOVqscw,73976
13
+ agenticdome_sdk/client.py,sha256=ba9J2mtDpTtC6nejp0GpKb7V6UfUKgWCt_BySL0ua3k,87059
14
14
  agenticdome_sdk/connect.py,sha256=WOh9hEOEy6OmX4zrJEWZPsgYJUbl3PR03ukODe3WC4Q,18864
15
15
  agenticdome_sdk/copilot_ir.py,sha256=zT13tOX8xu11yrOtIPMRFVud8CQ81Gu3WxsXxyQ4XT0,17928
16
16
  agenticdome_sdk/copilot_ir_collector.cjs,sha256=oxLY8ByONo7Es4YjYiJuRz_A7IKL65Sy486UXnu-4Rs,9681
17
17
  agenticdome_sdk/crewai.py,sha256=sSJQ49O7-8kqOAD2_jrsMtMOmBOcJmFkeOv7S3-ayMs,52490
18
18
  agenticdome_sdk/demo.py,sha256=dyfqt2N_cJoyUWKnjPYuQxuw2hb2DrCNUf1jQKeYYoc,8350
19
- agenticdome_sdk/existing_integration.py,sha256=be6xFqe3P9d98YOydHzDeyRSbuAim4bLBrfafLOJpJM,11465
19
+ agenticdome_sdk/existing_integration.py,sha256=O40rkFucrbuyQsezXhXm6txpt8T9PiXrmg4JmVSkYdw,11543
20
20
  agenticdome_sdk/framework_edits.py,sha256=4BgWHxWKEkex8_DMhjVxjovpUVkrMF7TsCZzlS94mpA,23344
21
21
  agenticdome_sdk/generic_python.py,sha256=JtXRcYEZ6_Dgxnnv4QgqeMZR8dFVr8EqFDM-XYQ-GMA,6823
22
22
  agenticdome_sdk/google_adk.py,sha256=2TA-tUhY0lOnkGcs1BN9CUEz67ebVX4HJ7mnNoRPcZs,57258
23
23
  agenticdome_sdk/guided_integration.py,sha256=4NBCacAcwEQkVct86G8NGYwrcTNT7xaxXGZ21aPaygY,52449
24
- agenticdome_sdk/hook_catalog.py,sha256=-z5bNJSDgUNQ0gVFdBsZ2eh5QcQljW9gJYNDRaI9KBk,29557
24
+ agenticdome_sdk/hook_catalog.py,sha256=9rugYzDPBajlRtLeIZHdhcbKqLjlVmOzGnFZNIdARuE,29892
25
+ agenticdome_sdk/http_execution.py,sha256=85bBRxC0TBOKUaRmy4WHyyIoAub71_KkRL_--1YQrm4,3801
25
26
  agenticdome_sdk/identity.py,sha256=mrymGgZSVsKJ9THRde54qGmMT7j_uZHmPJ-HtWk7PXE,4635
26
27
  agenticdome_sdk/langgraph.py,sha256=FUvF6DSA5aZP3eoBoNeldgGtPrz-dO5xcVmrPPSBEhI,84312
27
28
  agenticdome_sdk/lifecycle.py,sha256=obRIbJ9H90TPpfa46pZRTilg9Q8nhLTP5P2bsFbChbI,15210
28
29
  agenticdome_sdk/llamaindex.py,sha256=BHplSUIsgMi7k8tBztprzaV9iaOXiljXbdeMRax_2h8,42860
29
- agenticdome_sdk/mcp_host.py,sha256=4jze8c40o-kcVbX6ZSUpKM9Psyt02KfdrMa7G09o-Z8,70662
30
+ agenticdome_sdk/mcp_host.py,sha256=Arl5bpc0hTLy_4a33BQiWWtWNeAPh7nsRV6178h0ps0,72321
30
31
  agenticdome_sdk/mcp_http_gateway.py,sha256=XrTgj46ZHIKJ9xS3EQPsac2C9OGUZnrOXomcLdkMk_Y,13629
31
32
  agenticdome_sdk/mcp_rehearsal_server.py,sha256=cox4XqUTL8d0gaDzqxDZcEALkaz8otjOjOqHvoUeeCo,2118
32
33
  agenticdome_sdk/mcp_verification.py,sha256=WtRhAFVPTBqGOcHNf_db1m4jX9_TO0oxP98XWk4_ISY,14551
33
34
  agenticdome_sdk/microsoft_agent_framework.py,sha256=GfIIuk0n-VhsZaTyoB7P6ilpz9bFLD95TWuX0rFSWeU,67219
34
35
  agenticdome_sdk/microsoft_ai_foundry.py,sha256=YlO968s1dbAYcaEqhqufL92NFR66GuTtngnCv7-1mYc,56911
35
- agenticdome_sdk/onboarding_cli.py,sha256=8HK3xQ03Vp-SWZ_fZmxBXsgeZVKeUpFCZj-LmR6YbNI,169693
36
+ agenticdome_sdk/onboarding_cli.py,sha256=qxU9hTp25qMM7Z6Kwv2Quf6NcY34REHpS78n9NlumB8,172600
36
37
  agenticdome_sdk/onboarding_observations.py,sha256=M4UWdpYipMGi6Nw_eP7PvMLZsAv5UpXRYK0qR28qX6o,4498
37
38
  agenticdome_sdk/openai_agents.py,sha256=0z-7FDBIG4usxnILpan6yjQHF4zXIzm9YLsh3-bW8Lw,57678
38
39
  agenticdome_sdk/outcomes.py,sha256=jadWDzQaZXrHNvpPme8lQY0jihYLCoM3s4CihAq0JRo,2507
40
+ agenticdome_sdk/ownership.py,sha256=KEbRNZWJQn4rPnnBdmmmO4qn177sc2q3G0anKZvGkC4,8032
39
41
  agenticdome_sdk/proof.py,sha256=ECKc14xSE0V1HHmcpZjfVz8-Q2H_fooah3BfdblFV8M,2878
40
42
  agenticdome_sdk/pydantic.py,sha256=WKb8X0Fgydfid-ep8E-M8Yslz2pWcCP6w7n_aBxt1rI,54961
41
43
  agenticdome_sdk/report_scope.py,sha256=Waoaal9hkZsNF5G-ifDXNO_3an0ZjQJVv6-Uzg94oOM,3575
42
44
  agenticdome_sdk/simulation.py,sha256=UCbZy3u9AzfxQCfY38SCV3CxGxhinV9EA4aHMPlK4mc,8426
43
45
  agenticdome_sdk/smolagents.py,sha256=wjMA1HVAQ-9wRNM38Jr9wlCpKMhF-9vxtTk6R-kwQhs,19094
44
- agenticdome_python_sdk-1.2.47.dist-info/METADATA,sha256=3V1et6oMr-MYGotkAIdvvYd74-dtC5kaI3_pC7heqa0,146441
45
- agenticdome_python_sdk-1.2.47.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
46
- agenticdome_python_sdk-1.2.47.dist-info/entry_points.txt,sha256=cRfCphkr5gLrkGIzXJEtL50HdHLajoZLbZtcMLE8NoY,113
47
- agenticdome_python_sdk-1.2.47.dist-info/top_level.txt,sha256=LZbbjXco5mqDrGwlTJpIKI5Sp6R_njzHHjExxAs9c3s,16
48
- agenticdome_python_sdk-1.2.47.dist-info/RECORD,,
46
+ agenticdome_python_sdk-1.2.49.dist-info/METADATA,sha256=uUM70exTkl52dY9IQod2_wiR_-vrE61z4vbWADTkYKY,147841
47
+ agenticdome_python_sdk-1.2.49.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
48
+ agenticdome_python_sdk-1.2.49.dist-info/entry_points.txt,sha256=cRfCphkr5gLrkGIzXJEtL50HdHLajoZLbZtcMLE8NoY,113
49
+ agenticdome_python_sdk-1.2.49.dist-info/top_level.txt,sha256=LZbbjXco5mqDrGwlTJpIKI5Sp6R_njzHHjExxAs9c3s,16
50
+ agenticdome_python_sdk-1.2.49.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (84.0.0)
2
+ Generator: setuptools (84.2.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -5,8 +5,10 @@ from ._mode import LIVE_MODE, LOCAL_SIM_MODE, is_local_sim_mode, resolve_mode
5
5
  from .lifecycle import VerifiedActionContext, VerifiedActionDenied, VerifiedActionReporter, verified_action
6
6
  from .action_path_proof import ExecutionSpy
7
7
  from .generic_python import AgenticDomeActionDenied, guarded_tool_executor
8
+ from .ownership import OwnershipGuard, OwnershipDenied, ResourceRule
8
9
 
9
10
  __all__ = [
11
+ "OwnershipGuard", "OwnershipDenied", "ResourceRule",
10
12
  "AgenticDomeClient",
11
13
  "AgenticDomeError",
12
14
  "AgenticDomeHTTPError",
@@ -2,12 +2,12 @@
2
2
  "schema": "agenticdome.catalog-snapshot.v1",
3
3
  "catalog_schema": "agenticdome.hook-catalog.v1",
4
4
  "verified_at": "2026-10-12",
5
- "python_sdk_version": "1.2.47",
5
+ "python_sdk_version": "1.2.49",
6
6
  "published_packages": {
7
7
  "agenticdome-python-sdk": {
8
8
  "registry": "pypi",
9
- "version": "1.2.47",
10
- "url": "https://pypi.org/project/agenticdome-python-sdk/1.2.47/"
9
+ "version": "1.2.49",
10
+ "url": "https://pypi.org/project/agenticdome-python-sdk/1.2.49/"
11
11
  },
12
12
  "agenticdome-sdk": {
13
13
  "registry": "npm",
agenticdome_sdk/client.py CHANGED
@@ -4,6 +4,9 @@ import json
4
4
  import uuid
5
5
  import logging
6
6
  import os
7
+ import threading
8
+ from contextlib import contextmanager
9
+ from contextvars import ContextVar
7
10
  import re
8
11
  from importlib import metadata
9
12
  from typing import Optional, Dict, List, Any, Tuple, Union, Mapping
@@ -73,6 +76,9 @@ class ApprovalRequired(AgenticDomeError):
73
76
  return cls({"context": {"approval": {"id": approval["id"]}, "approval_url": approval.get("url", "")}}, record["prepared_request"])
74
77
 
75
78
 
79
+ _CALL_IDENTITIES=ContextVar('agenticdome_client_identities',default=None)
80
+
81
+
76
82
  class AgenticDomeClient:
77
83
  """
78
84
  Official Python SDK for the AgenticDome Action Firewall.
@@ -111,7 +117,11 @@ class AgenticDomeClient:
111
117
  tool_provenance: Optional[Mapping[str, Mapping[str, str]]] = None,
112
118
  execution_broker_mode: Optional[str] = None,
113
119
  mode: Optional[str] = None,
120
+ ownership_guard=None,
114
121
  ):
122
+ self.ownership_guard = ownership_guard
123
+ self._managed_token_lock=None
124
+ self._managed_token_cache={}
115
125
  self.mode = resolve_mode(mode)
116
126
  self.is_simulation = self.mode == LOCAL_SIM_MODE
117
127
  if self.is_simulation:
@@ -218,8 +228,70 @@ class AgenticDomeClient:
218
228
  if extra_headers:
219
229
  headers.update(extra_headers)
220
230
 
231
+ # Renewed projected/JWT-SVID proof files are read on every request.
232
+ for environment, header in (("AGENTICDOME_AGENT_CREDENTIAL", "X-AgenticDome-Agent-Credential"),
233
+ ("AGENTICDOME_IDENTITY_DEPLOYMENT", "X-AgenticDome-Deployment"),
234
+ ("AGENTICDOME_AGENT_ID", "X-AgenticDome-Agent-Id"),
235
+ ("AGENTICDOME_AGENT_FRAMEWORK", "X-AgenticDome-Agent-Framework"),
236
+ ("AGENTICDOME_AGENT_TOKEN", "X-AgenticDome-Agent-Token"),
237
+ ("AGENTICDOME_WORKLOAD_TOKEN", "X-AgenticDome-Workload-Token"),
238
+ ("AGENTICDOME_USER_TOKEN", "X-AgenticDome-User-Token"),
239
+ ("AGENTICDOME_DELEGATION_TOKEN", "X-AgenticDome-Delegation-Token"),
240
+ ("AGENTICDOME_TASK_ID", "X-AgenticDome-Task-Id")):
241
+ value = os.getenv(environment, "").strip(); filename=os.getenv(environment+'_FILE','').strip()
242
+ if value and filename:
243
+ raise ValueError('Configure one identity value or file for '+environment)
244
+ if filename:
245
+ with open(filename,'rb') as handle:
246
+ raw=handle.read(16385)
247
+ if len(raw)>16384:
248
+ raise ValueError('Identity proof exceeds the size limit')
249
+ value=raw.decode().strip()
250
+ if not value:
251
+ raise ValueError('Identity proof file is empty')
252
+ if len(value)>16384 or any(ord(c)<32 or ord(c)==127 for c in value):
253
+ raise ValueError('Identity header contains an invalid value')
254
+ if value:
255
+ headers.setdefault(header,value)
256
+ scoped=(_CALL_IDENTITIES.get() or {}).get(id(self),{})
257
+ for header,value in scoped.items():
258
+ if extra_headers and header in extra_headers:continue
259
+ if value is None:headers.pop(header,None)
260
+ else:headers[header]=value
261
+ if headers.get('X-AgenticDome-Agent-Token'):
262
+ headers.pop('X-AgenticDome-Agent-Credential',None);headers.pop('X-AgenticDome-Workload-Token',None)
263
+
221
264
  return headers
222
265
 
266
+ @contextmanager
267
+ def identity_context(self,*,user_token: Optional[str]=None,delegation_token: Optional[str]=None,task_id: Optional[str]=None):
268
+ """Bind one request/task identity to existing hooks without sharing it across tasks."""
269
+ if user_token and delegation_token:raise ValueError('Use a user token or a delegation token, not both')
270
+ if delegation_token and not task_id:raise ValueError('A delegation token requires its task ID')
271
+ contexts=dict(_CALL_IDENTITIES.get() or {});headers=dict(contexts.get(id(self),{}))
272
+ if user_token or delegation_token:
273
+ headers.update({'X-AgenticDome-User-Token':None,'X-AgenticDome-Delegation-Token':None})
274
+ for value,header,limit in ((user_token,'X-AgenticDome-User-Token',16384),(delegation_token,'X-AgenticDome-Delegation-Token',16384),(task_id,'X-AgenticDome-Task-Id',256)):
275
+ if value is not None:
276
+ if not isinstance(value,str) or not value.strip() or len(value)>limit or any(ord(c)<32 or ord(c)==127 for c in value):raise ValueError('Invalid scoped identity value')
277
+ headers[header]=value.strip()
278
+ contexts[id(self)]=headers;token=_CALL_IDENTITIES.set(contexts)
279
+ try:yield self
280
+ finally:_CALL_IDENTITIES.reset(token)
281
+
282
+ def enrol_identity(self, agent_id: str, framework: str = 'application') -> Dict[str, Any]:
283
+ """Obtain/renew a short-lived managed identity using configured deployment proof."""
284
+ return self._request('POST','/identity/v1/enrol',json_body={'agent_id':agent_id,'framework':framework})
285
+
286
+ def delegate_identity(self, recipient_agent_id: str, task_id: str, *, subject_token: Optional[str] = None) -> Dict[str, Any]:
287
+ payload={'recipient_agent_id':recipient_agent_id,'task_id':task_id,'scope':'identity:act'}
288
+ if subject_token:payload['subject_token']=subject_token
289
+ return self._request('POST','/identity/v1/delegate',json_body=payload)
290
+
291
+ def exchange_identity(self, subject_token: str, audience: str, task_id: str, scope: str) -> Dict[str, Any]:
292
+ return self._request('POST','/identity/v1/token',json_body={'grant_type':'urn:ietf:params:oauth:grant-type:token-exchange',
293
+ 'subject_token':subject_token,'subject_token_type':'urn:ietf:params:oauth:token-type:access_token','audience':audience,'task_id':task_id,'scope':scope})
294
+
223
295
  def _require_nonempty(self, name: str, value: Optional[str]) -> str:
224
296
  """
225
297
  Require a non-empty, non-whitespace-only string.
@@ -229,6 +301,53 @@ class AgenticDomeClient:
229
301
  raise ValueError(f"'{name}' is required and cannot be blank")
230
302
  return s
231
303
 
304
+ def _managed_headers(self,path,json_body,headers):
305
+ """Fail closed on old runtimes; reuse a short-lived token across existing hooks."""
306
+ if not path.startswith(('/tools/','/a2a','/mcp')):
307
+ return headers
308
+ if not any(headers.get(h) for h in ('X-AgenticDome-Deployment','X-AgenticDome-Agent-Token')):
309
+ if headers.get('X-AgenticDome-User-Token') or headers.get('X-AgenticDome-Delegation-Token'):raise AgenticDomeError('Configure deployment proof or an enrolled agent token before supplying delegated identity')
310
+ return headers
311
+ import hashlib,time
312
+ body=json_body if isinstance(json_body,dict) else {}
313
+ params=body.get('params') if isinstance(body.get('params'),dict) else {}
314
+ if isinstance(params.get('arguments'),dict):body=params['arguments']
315
+ elif params.get('agent_id'):body=params
316
+ context=body.get('policy_context') if isinstance(body.get('policy_context'),dict) else {}
317
+ native=body.get('agent_id') or headers.get('X-AgenticDome-Agent-Id') or 'application'
318
+ framework=context.get('platform') or body.get('platform') or headers.get('X-AgenticDome-Agent-Framework') or 'gateway'
319
+ explicit=headers.get('X-AgenticDome-Agent-Token')
320
+ proof=explicit or headers.get('X-AgenticDome-Agent-Credential') or headers.get('X-AgenticDome-Workload-Token') or ''
321
+ cache_key=hashlib.sha256(json.dumps([headers.get('X-Tenant-Id'),headers.get('X-AgenticDome-Deployment'),native,framework,proof]).encode()).hexdigest()
322
+ if self._managed_token_lock is None:
323
+ self._managed_token_lock=threading.RLock()
324
+ with self._managed_token_lock:
325
+ cached=self._managed_token_cache.get(cache_key)
326
+ if not cached or cached[1]<=time.time()+30:
327
+ clean={k:v for k,v in headers.items() if k.lower() not in {'x-agenticdome-user-token','x-agenticdome-delegation-token','x-agenticdome-task-id'}}
328
+ endpoint='/identity/v1/introspect' if explicit else '/identity/v1/enrol'
329
+ payload={'token':explicit} if explicit else {'agent_id':native,'framework':framework}
330
+ result=self.session.request(method='POST',url=self.api_base+endpoint,headers=clean,json=payload,timeout=self._timeout_tuple(None))
331
+ if not result.ok:
332
+ raise AgenticDomeHTTPError(result.status_code,'Managed identity could not be verified. Check deployment approval and update the assigned sidecar.',result.text)
333
+ issued=result.json()
334
+ if explicit:
335
+ if issued.get('active') is not True or issued.get('token_use')!='agent_identity':
336
+ raise AgenticDomeError('Managed agent token is not active')
337
+ token=explicit;expires=float(issued.get('exp',0))
338
+ else:
339
+ token=issued.get('access_token');expires=time.time()+min(float(issued.get('expires_in',0)),3600)
340
+ if not isinstance(token,str) or not token or not time.time()<expires<=time.time()+3601:
341
+ raise AgenticDomeError('Runtime returned an invalid managed identity response')
342
+ # Bound cache entries when frameworks create short-lived specialist names.
343
+ if len(self._managed_token_cache)>=1000:
344
+ self._managed_token_cache={k:v for k,v in self._managed_token_cache.items() if v[1]>time.time()+30}
345
+ if len(self._managed_token_cache)>=1000:self._managed_token_cache.pop(next(iter(self._managed_token_cache)))
346
+ cached=(token,expires);self._managed_token_cache[cache_key]=cached
347
+ headers=dict(headers);headers.pop('X-AgenticDome-Agent-Credential',None);headers.pop('X-AgenticDome-Workload-Token',None)
348
+ headers['X-AgenticDome-Agent-Token']=cached[0]
349
+ return headers
350
+
232
351
  def _effective_tenant_id(self, tenant_id: Optional[Union[str, int]] = None) -> str:
233
352
  return self._require_nonempty(
234
353
  "tenant_id",
@@ -433,6 +552,7 @@ class AgenticDomeClient:
433
552
  use_bearer=use_bearer,
434
553
  extra_headers=extra_headers,
435
554
  )
555
+ headers=self._managed_headers(path,json_body,headers)
436
556
 
437
557
  response = self.session.request(
438
558
  method=method.upper(),
@@ -635,6 +755,7 @@ class AgenticDomeClient:
635
755
  execution_boundary_id: Optional[str] = None,
636
756
  execution_destination: Optional[str] = None,
637
757
  execution_http_method: Optional[str] = None,
758
+ execution_request: Optional[Dict[str, Any]] = None,
638
759
  workload_id: Optional[str] = None,
639
760
  workload_uuid: Optional[str] = None,
640
761
  tenant_id: Optional[Union[str, int]] = None,
@@ -828,6 +949,10 @@ class AgenticDomeClient:
828
949
 
829
950
  if tool_name:
830
951
  payload["policy_context"].setdefault("approval_action_id", str(uuid.uuid4()))
952
+ if execution_request is not None:
953
+ if not broker_enabled:
954
+ raise ValueError("Prepared HTTP execution requires the execution broker")
955
+ payload["execution_request"] = json.loads(json.dumps(execution_request, allow_nan=False))
831
956
  path = "/tools/execution/authorize" if broker_enabled else "/tools/guardrail/validate"
832
957
  if broker_enabled and resolved_broker_mode == "policy" and execution_broker is not True:
833
958
  path = "/tools/execution/resolve"
@@ -855,7 +980,7 @@ class AgenticDomeClient:
855
980
  )
856
981
  return response
857
982
 
858
- def resume_approved_action(self, pending: ApprovalRequired, executor):
983
+ def resume_approved_action(self, pending: ApprovalRequired, executor, *, with_authorization=False):
859
984
  """Revalidate and consume one exact-action grant before invoking executor(args).
860
985
 
861
986
  The caller retains the prepared request; the portal never holds payloads.
@@ -866,7 +991,11 @@ class AgenticDomeClient:
866
991
  request_id = str(uuid.UUID(pending.request_id))
867
992
  payload = json.loads(pending._prepared_json)
868
993
  tenant = payload.get("tenant_id")
869
- grant = self._request("GET", f"/tools/approvals/{request_id}/grant", tenant_id=tenant).get("approval_grant")
994
+ grant_options={'tenant_id':tenant}
995
+ if any(os.getenv(name) for name in ('AGENTICDOME_IDENTITY_DEPLOYMENT','AGENTICDOME_AGENT_TOKEN','AGENTICDOME_AGENT_TOKEN_FILE')):
996
+ grant_options['extra_headers']={'X-AgenticDome-Agent-Id':payload.get('agent_id') or 'application',
997
+ 'X-AgenticDome-Agent-Framework':(payload.get('policy_context') or {}).get('platform') or 'gateway'}
998
+ grant = self._request("GET", f"/tools/approvals/{request_id}/grant", **grant_options).get("approval_grant")
870
999
  if not isinstance(grant, str) or not grant:
871
1000
  raise AgenticDomeError("No current approval grant was returned")
872
1001
  payload["policy_context"] = {**(payload.get("policy_context") or {}), "approval_grant": grant}
@@ -875,7 +1004,47 @@ class AgenticDomeClient:
875
1004
  broker = response.get("broker") or {}
876
1005
  if response.get("verdict") != "ALLOWED" or not broker.get("verified") or not broker.get("token_consumed") or broker.get("approval_request_id") != request_id or not response.get("execution_receipt"):
877
1006
  raise AgenticDomeError("The approved action could not be revalidated and consumed")
878
- return executor(json.loads(pending._prepared_json)["tool_args"])
1007
+ exact_args = json.loads(pending._prepared_json)["tool_args"]
1008
+ return executor(exact_args, response) if with_authorization else executor(exact_args)
1009
+
1010
+ def execute_http(self, *, method, url, agent_id, tool_name, body=b"", headers=None, timeout=30, **context):
1011
+ """Authorize and send the same HTTP request. ApprovalRequired pauses before sending."""
1012
+ from .http_execution import prepare, send
1013
+ prepared, arguments, descriptor = prepare(method, url, body, headers)
1014
+ result = self.guardrail_validate(text="Execute reviewed HTTP operation", agent_id=agent_id,
1015
+ tool_name=tool_name, tool_args=arguments, platform=context.pop("platform", "generic"),
1016
+ execution_broker=True, execution_destination=prepared.url, execution_http_method=prepared.method,
1017
+ execution_request=descriptor, **context)
1018
+ return send(prepared, result, self, workload_id=context.get("workload_id"), timeout=timeout,
1019
+ tool_name=tool_name, arguments=arguments, require_graphql=(context.get("policy_context") or {}).get("required_graphql_schema"))
1020
+
1021
+ def execute_graphql(self, *, url, query, agent_id, tool_name, variables=None, operation_name=None, headers=None, **context):
1022
+ """Review GraphQL in the sidecar and execute its exact JSON bytes."""
1023
+ if not isinstance(query, str) or not query.strip(): raise ValueError("Supply a complete GraphQL document")
1024
+ if variables is not None and not isinstance(variables, dict): raise ValueError("GraphQL variables must be an object")
1025
+ if any(k.lower() == "content-type" for k in (headers or {})): raise ValueError("GraphQL content type is managed by the SDK")
1026
+ payload = {"query": query, "variables": variables or {}}
1027
+ if operation_name is not None: payload["operationName"] = operation_name
1028
+ context["policy_context"] = {**(context.get("policy_context") or {}), "required_graphql_schema": "agenticdome.graphql-actions.v1"}
1029
+ return self.execute_http(method="POST", url=url, body=json.dumps(payload, allow_nan=False),
1030
+ headers={**(headers or {}), "Content-Type": "application/json"}, agent_id=agent_id, tool_name=tool_name, **context)
1031
+
1032
+ def resume_approved_http(self, pending: ApprovalRequired, *, headers=None, timeout=30):
1033
+ """Resume the frozen HTTP request; supply fresh authentication headers separately."""
1034
+ from .http_execution import prepare, send, BOUND_HEADERS
1035
+ payload = json.loads(pending._prepared_json)
1036
+ descriptor = payload.get("execution_request")
1037
+ if not isinstance(descriptor, dict):
1038
+ raise ValueError("This approval does not contain a prepared HTTP request")
1039
+ if any(str(k).lower() in BOUND_HEADERS for k in (headers or {})):
1040
+ raise ValueError("Approved content and resource preconditions cannot be changed")
1041
+ prepared, arguments, actual = prepare(payload["http_method"], payload["destination"],
1042
+ base64.b64decode(descriptor["body_base64"], validate=True), {**(headers or {}), **descriptor["headers"]})
1043
+ if arguments != payload["tool_args"] or actual != descriptor:
1044
+ raise AgenticDomeError("Prepared HTTP action changed during resume")
1045
+ return self.resume_approved_action(pending, lambda args, result: send(prepared, result, self,
1046
+ workload_id=payload.get("workload_id"), timeout=timeout, tool_name=payload["tool_name"], arguments=arguments,
1047
+ require_graphql=(payload.get("policy_context") or {}).get("required_graphql_schema")), with_authorization=True)
879
1048
 
880
1049
  @staticmethod
881
1050
  def enforcement_headers(result: Dict[str, Any], *, workload_id: Optional[str] = None) -> Dict[str, str]:
@@ -33,6 +33,7 @@ README_METHODS = {
33
33
  "invoke_agent_securely", "wrap_retriever", "create_node_postprocessor",
34
34
  "create_callback_handler",
35
35
  "guarded_tool_executor",
36
+ "execute_http", "execute_graphql",
36
37
  }
37
38
  FRAMEWORK_METHODS = (CATALOG_METHODS | README_METHODS) - {"guardrail_validate", "mesh_validate"}
38
39
  A2A_METHODS = {
@@ -53,6 +54,7 @@ OUTPUT_METHODS = {
53
54
  "sanitize_streaming_events", "sanitize_retrieval_documents",
54
55
  }
55
56
  TOOL_METHODS = {
57
+ "execute_http", "execute_graphql",
56
58
  "authorize_tool_call", "authorize_transition", "transition_node",
57
59
  "wrap_tool_handler", "wrap_tool_node", "wrap_tool_function",
58
60
  "wrap_tool_executor", "wrap_action_group_lambda", "secure_tool",
@@ -51,8 +51,8 @@ PUBLISHED_AGENTICDOME_PACKAGES: Dict[str, Dict[str, str]] = {
51
51
 
52
52
  # Prepared artifacts are kept separate from registry-verified published releases.
53
53
  RELEASE_CANDIDATE_PACKAGES = {
54
- 'agenticdome-python-sdk': {'version': '1.2.44', 'status': 'unpublished'},
55
- 'agenticdome-sdk': {'version': '0.6.15', 'status': 'unpublished'},
54
+ 'agenticdome-python-sdk': {'version': '1.2.48', 'status': 'unpublished'},
55
+ 'agenticdome-sdk': {'version': '0.6.16', 'status': 'unpublished'},
56
56
  }
57
57
 
58
58
 
@@ -298,7 +298,7 @@ FRAMEWORK_HOOK_CATALOG: Dict[str, Dict[str, Any]] = {
298
298
  "Custom Python",
299
299
  "agenticdome_sdk",
300
300
  "AgenticDomeClient",
301
- ["guardrail_validate", "mesh_validate"],
301
+ ["guardrail_validate", "mesh_validate", "execute_http", "execute_graphql"],
302
302
  docs="docs/frameworks/custom-python.md",
303
303
  ),
304
304
  "typescript": {
@@ -311,6 +311,7 @@ FRAMEWORK_HOOK_CATALOG: Dict[str, Dict[str, Any]] = {
311
311
  "adapter_module": "agenticdome-sdk",
312
312
  "adapter_class": "AgenticDomeClient",
313
313
  "attachment_methods": ["guardrailValidate", "meshValidate"],
314
+ "action_adapters": {"http": "executeHttp", "graphql": "executeGraphql", "ownership": "OwnershipGuard", "qualification": "Verify these optional exports in the installed npm package before use; Python catalogue publication does not certify an npm release."},
314
315
  "native_hooks": [],
315
316
  "docs": "agenticdome-sdk package README",
316
317
  },
@@ -445,7 +446,7 @@ _HARNESS_VERIFICATION: Dict[str, Dict[str, Any]] = {
445
446
  },
446
447
  "custom-python": {
447
448
  "adapter_attrs": ["AgenticDomeClient"],
448
- "firewall_methods": ["guardrail_validate", "mesh_validate"],
449
+ "firewall_methods": ["guardrail_validate", "mesh_validate", "execute_http", "execute_graphql"],
449
450
  },
450
451
  }
451
452
 
@@ -0,0 +1,64 @@
1
+ """Prepare once and send the policy-reviewed HTTP bytes without redirects."""
2
+ import base64
3
+ import json
4
+ from urllib.parse import urlsplit, urlunsplit
5
+
6
+ import requests
7
+
8
+ BOUND_HEADERS = ("content-type", "if-match", "if-none-match", "if-unmodified-since")
9
+
10
+
11
+ def prepare(method, url, body=b"", headers=None):
12
+ method = method.upper()
13
+ if method not in {"GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"}:
14
+ raise ValueError("Unsupported exact HTTP method")
15
+ if isinstance(body, str):
16
+ body = body.encode("utf-8")
17
+ if not isinstance(body, bytes) or len(body) > 131072:
18
+ raise ValueError("Supply at most 128 KiB of UTF-8 HTTP body bytes")
19
+ if method in {"GET", "HEAD"} and body:
20
+ raise ValueError("GET/HEAD bodies are not supported")
21
+ body.decode("utf-8")
22
+ headers = dict(headers or {})
23
+ if any(str(k).lower() in {"host", "content-length", "transfer-encoding", "content-encoding"} or str(k).lower().startswith("x-agenticdome-") for k in headers):
24
+ raise ValueError("HTTP transport and AgenticDome headers are managed by the SDK")
25
+ parsed = urlsplit(url)
26
+ if parsed.scheme not in {"http", "https"} or not parsed.hostname or parsed.username is not None or parsed.password is not None or parsed.fragment:
27
+ raise ValueError("Use an absolute HTTP(S) URL without credentials or fragment")
28
+ host = parsed.hostname.lower()
29
+ if ":" in host:
30
+ host = "[" + host + "]"
31
+ if parsed.port and parsed.port != (443 if parsed.scheme == "https" else 80):
32
+ host += ":" + str(parsed.port)
33
+ url = urlunsplit((parsed.scheme, host, parsed.path or "/", parsed.query, ""))
34
+ prepared = requests.Request(method, url, data=body, headers=headers).prepare()
35
+ bound = {k.lower(): v for k, v in prepared.headers.items() if k.lower() in BOUND_HEADERS}
36
+ content = None
37
+ if body:
38
+ content = json.loads(body) if "json" in bound.get("content-type", "").lower() else body.decode("utf-8")
39
+ arguments = {"method": method, "url": prepared.url, "body": content, "headers": bound}
40
+ descriptor = {"body_base64": base64.b64encode(body).decode("ascii"), "headers": bound}
41
+ return prepared, arguments, descriptor
42
+
43
+
44
+ def send(prepared, authorization, client, *, workload_id=None, timeout=30, tool_name=None, arguments=None, require_graphql=None):
45
+ from .client import AgenticDomeError
46
+ broker = authorization.get("broker") or {}
47
+ evidence = authorization.get("enforcement_evidence") or {}
48
+ if authorization.get("verdict") != "ALLOWED" or not broker.get("verified") or not broker.get("token_consumed") or evidence.get("http_request_bound") is not True:
49
+ raise AgenticDomeError("Exact HTTP execution requires a compatible enforcing broker receipt")
50
+ if require_graphql and evidence.get("graphql_interpretation") != require_graphql:
51
+ raise AgenticDomeError("GraphQL execution requires a compatible interpreting sidecar")
52
+ if client.ownership_guard is not None:
53
+ if not client.tenant_id:
54
+ raise AgenticDomeError("Configure the enforcement tenant when using resource ownership adapters")
55
+ client.ownership_guard.check_http(tool_name, arguments, evidence, expected_tenant=client.tenant_id)
56
+ prepared.headers.update(client.enforcement_headers(authorization, workload_id=workload_id))
57
+ # A fresh session has no agent-supplied hooks, cookies or automatic retries.
58
+ with requests.Session() as session:
59
+ settings = session.merge_environment_settings(prepared.url, {}, False, True, None)
60
+ response = session.send(prepared, timeout=timeout, allow_redirects=False, **settings)
61
+ if 300 <= response.status_code < 400:
62
+ response.close()
63
+ raise AgenticDomeError("Redirect refused; authorize its destination as a new action")
64
+ return response
@@ -363,6 +363,7 @@ class AgenticDomeMCPHostFirewall:
363
363
  lifecycle_reporter: Optional[VerifiedActionReporter] = None,
364
364
  provider_action_rules: Optional[Dict[str, "ProviderActionRule"]] = None,
365
365
  resolve_provider_facts: Optional[Callable[[str, Dict[str, Any]], Any]] = None,
366
+ ownership_guard=None,
366
367
  ) -> None:
367
368
  self.config = config or load_config()
368
369
  if not credentials_or_local_sim(self.config.api_base, self.config.api_key, self.config.tenant_id):
@@ -382,6 +383,7 @@ class AgenticDomeMCPHostFirewall:
382
383
  api_base=self.config.api_base, api_key=self.config.api_key, sender=getattr(self.client, "report_action_evidence", None))
383
384
  self.provider_action_rules = dict(provider_action_rules or {})
384
385
  self.resolve_provider_facts = resolve_provider_facts
386
+ self.ownership_guard = ownership_guard
385
387
  self._rate_lock = Lock()
386
388
  self._rate_events: Dict[str, Deque[float]] = defaultdict(deque)
387
389
 
@@ -674,7 +676,7 @@ class AgenticDomeMCPHostFirewall:
674
676
  logger.warning("AgenticDome incident reporting failed; continuing. reason=%s", exc)
675
677
 
676
678
  def _fail_or_raise(self, message: str, exc: Optional[Exception] = None) -> None:
677
- if self.config.fail_closed:
679
+ if self.config.fail_closed or self.ownership_guard is not None:
678
680
  if exc is not None:
679
681
  raise MCPToolBlocked(message) from exc
680
682
  raise MCPToolBlocked(message)
@@ -1249,6 +1251,9 @@ class AgenticDomeMCPHostFirewall:
1249
1251
  if not isinstance(mcp_request, dict):
1250
1252
  return self.jsonrpc_error(None, -32600, "Invalid Request")
1251
1253
 
1254
+ if self._method(mcp_request) == "tools/call" or (self.ownership_guard is not None and self._method(mcp_request) in {"resources/read", "prompts/get"}):
1255
+ mcp_request = copy.deepcopy(mcp_request)
1256
+
1252
1257
  rid = self._request_id(mcp_request)
1253
1258
  method = self._method(mcp_request)
1254
1259
  params = self._params(mcp_request)
@@ -1270,28 +1275,36 @@ class AgenticDomeMCPHostFirewall:
1270
1275
  if blocked:
1271
1276
  return blocked
1272
1277
  sanitized_args = self._sanitized_args(decision, explicit_only=self._verdict(decision) == "REDACTED")
1273
- forwarded_args = sanitized_args if sanitized_args is not None else self._strip_internal_args(tool_args)
1278
+ forwarded_args = copy.deepcopy(sanitized_args if sanitized_args is not None else self._strip_internal_args(tool_args))
1274
1279
  await self._check_provider_action(tool_name=tool_name, arguments=forwarded_args)
1280
+ if self.ownership_guard is not None:
1281
+ await self.ownership_guard.check_async(tool_name, forwarded_args, expected_tenant=self.config.tenant_id)
1275
1282
  self._audit("mcp_request_allowed", context=local_context, details={"method": method, "operation": tool_name})
1276
1283
  return self._replace_tool_args(mcp_request, forwarded_args)
1277
1284
 
1278
- if method == "resources/read" and self.config.protect_resources_read:
1285
+ if method == "resources/read" and (self.config.protect_resources_read or self.ownership_guard is not None):
1279
1286
  uri, resource_params = self._extract_resource_read(mcp_request)
1280
1287
  decision = await self.authorize_mcp_resource_read(uri=uri, params=resource_params, context=local_context)
1281
1288
  blocked = await self._handle_blocking_decision(decision=decision, rid=rid, context=local_context, method=method, operation=uri)
1282
1289
  if blocked:
1283
1290
  return blocked
1284
1291
  sanitized_params = self._sanitized_args(decision, explicit_only=self._verdict(decision) == "REDACTED")
1292
+ if self.ownership_guard is not None:
1293
+ sanitized_params = copy.deepcopy(sanitized_params if sanitized_params is not None else resource_params)
1294
+ await self.ownership_guard.check_async("mcp.resources/read", sanitized_params, expected_tenant=self.config.tenant_id)
1285
1295
  self._audit("mcp_request_allowed", context=local_context, details={"method": method, "operation": uri})
1286
1296
  return self._replace_params(mcp_request, sanitized_params) if sanitized_params is not None else mcp_request
1287
1297
 
1288
- if method == "prompts/get" and self.config.protect_prompts_get:
1298
+ if method == "prompts/get" and (self.config.protect_prompts_get or self.ownership_guard is not None):
1289
1299
  name, prompt_params = self._extract_prompt_get(mcp_request)
1290
1300
  decision = await self.authorize_mcp_prompt_get(name=name, params=prompt_params, context=local_context)
1291
1301
  blocked = await self._handle_blocking_decision(decision=decision, rid=rid, context=local_context, method=method, operation=name)
1292
1302
  if blocked:
1293
1303
  return blocked
1294
1304
  sanitized_params = self._sanitized_args(decision, explicit_only=self._verdict(decision) == "REDACTED")
1305
+ if self.ownership_guard is not None:
1306
+ sanitized_params = copy.deepcopy(sanitized_params if sanitized_params is not None else prompt_params)
1307
+ await self.ownership_guard.check_async("mcp.prompts/get", sanitized_params, expected_tenant=self.config.tenant_id)
1295
1308
  self._audit("mcp_request_allowed", context=local_context, details={"method": method, "operation": name})
1296
1309
  return self._replace_params(mcp_request, sanitized_params) if sanitized_params is not None else mcp_request
1297
1310
 
@@ -1322,8 +1335,11 @@ class AgenticDomeMCPHostFirewall:
1322
1335
  except MCPToolBlocked as exc:
1323
1336
  return self.jsonrpc_error(rid, -32000, "AgenticDome Blocked: MCP request not authorized", data={"method": method})
1324
1337
  except (AgenticDomeHTTPError, Exception) as exc:
1325
- if method == "tools/call" and self._extract_tool_call(mcp_request)[0] in self.provider_action_rules:
1326
- return self.jsonrpc_error(rid, -32000, "AgenticDome Blocked: Booking authorization unavailable", data={"method": method})
1338
+ if method in {"resources/read", "prompts/get"} and self.ownership_guard is not None and self.ownership_guard.protects("mcp." + method):
1339
+ return self.jsonrpc_error(rid, -32000, "AgenticDome Blocked: Provider resource authorization unavailable", data={"method": method})
1340
+ if method == "tools/call" and (self._extract_tool_call(mcp_request)[0] in self.provider_action_rules or
1341
+ self.ownership_guard is not None and self.ownership_guard.protects(self._extract_tool_call(mcp_request)[0])):
1342
+ return self.jsonrpc_error(rid, -32000, "AgenticDome Blocked: Provider resource authorization unavailable", data={"method": method})
1327
1343
  if self.config.fail_closed:
1328
1344
  return self.jsonrpc_error(rid, -32000, "AgenticDome Blocked: MCP preflight unavailable", data={"method": method})
1329
1345
  logger.warning("AgenticDome MCP preflight failed open. reason=%s", exc)
@@ -1430,6 +1430,7 @@ def _hook_plans(
1430
1430
  "class": contract.get("adapter_class"),
1431
1431
  "attachment_methods": contract.get("attachment_methods", []),
1432
1432
  "native_hooks": contract.get("native_hooks", []),
1433
+ "action_adapters": contract.get("action_adapters", {}),
1433
1434
  },
1434
1435
  "runtime": contract.get("runtime", {}),
1435
1436
  "packages": package_rows,
@@ -1479,7 +1480,8 @@ _PRIMARY_HOOKS = {
1479
1480
  "llamaindex": ("to_function_tool", "Wrap each consequential LlamaIndex function tool; add retrieval and output review separately."),
1480
1481
  "bedrock": ("wrap_tool_handler", "Wrap each Bedrock action-group or local tool executor before calling it."),
1481
1482
  "mcp": ("forward_with_firewall", "Route the real MCP forwarder and responses through the host firewall."),
1482
- "custom-python": ("guardrail_validate", "Call the runtime immediately before each real tool executor and enforce its returned verdict; explicit dispatchers can use guarded_tool_executor."),
1483
+ "custom-python": ("guardrail_validate", "Use execute_http or execute_graphql for outbound API actions; attach OwnershipGuard to authoritative provider access records when resource access is involved. Other dispatchers can use guarded_tool_executor or enforce guardrail_validate immediately before execution."),
1484
+ "typescript": ("guardrailValidate", "For outbound API actions, verify executeHttp/executeGraphql and OwnershipGuard exist in the installed core SDK; use them at the actual execution boundary."),
1483
1485
  }
1484
1486
 
1485
1487
  # These are conditional attachment choices, not assertions that the selected
@@ -1521,7 +1523,7 @@ _SURFACE_HOOKS = {
1521
1523
  ],
1522
1524
  "mcp": [("tool_execution", ("forward_with_firewall", "preflight_request"), "Route the actual JSON-RPC forwarder and response path through the MCP host firewall.")],
1523
1525
  "custom-python": [
1524
- ("tool_execution", ("guardrail_validate", "guarded_tool_executor"), "Enforce the returned verdict immediately before the real executor; the decorator requires explicit trusted agent and session identity."),
1526
+ ("tool_execution", ("guardrail_validate", "guarded_tool_executor", "execute_http", "execute_graphql"), "Use the exact HTTP/GraphQL helper for API actions; enforce other verdicts immediately before the real executor. Resolve ownership from the authenticated provider, never caller-supplied owner fields."),
1525
1527
  ("output_egress", ("mesh_validate",), "Review the final response before release to a user or external destination."),
1526
1528
  ("delegation", ("a2a_authorize_tool", "a2a_verify_decision_token_rpc"), "Authorize the handoff and verify its token at the receiving executor."),
1527
1529
  ],
@@ -1559,8 +1561,9 @@ def _recommend_hook(hook: Dict[str, Any], existing: Dict[str, Any]) -> Dict[str,
1559
1561
  observed = (
1560
1562
  "agenticdome_sdk.crewai" in imports if framework == "crewai" else method in observed_methods
1561
1563
  )
1562
- if framework == "custom-python" and "guarded_tool_executor" in observed_methods:
1564
+ if framework == "custom-python" and observed_methods & {"guarded_tool_executor", "execute_http", "execute_graphql"}:
1563
1565
  observed = True
1566
+ method = next(value for value in ("execute_graphql", "execute_http", "guarded_tool_executor") if value in observed_methods)
1564
1567
  return {
1565
1568
  "framework": framework,
1566
1569
  "method": method,
@@ -1681,6 +1684,7 @@ def integration_plan(root: Path) -> Dict[str, Any]:
1681
1684
  "framework_hook_plans": hook_plans,
1682
1685
  "hook_recommendations": [item["recommended_attachment"] for item in hook_plans],
1683
1686
  "surface_hook_recommendations": [row for item in hook_plans for row in item["surface_recommendations"]],
1687
+ "resource_action_guidance": _resource_action_guidance(),
1684
1688
  "business_purpose": config.get("business_purpose"),
1685
1689
  "deployment": config.get("deployment", {}),
1686
1690
  "candidate_boundaries": report["boundaries"],
@@ -1830,9 +1834,29 @@ def _framework_hooks_markdown(plan: Dict[str, Any]) -> str:
1830
1834
  lines.extend(["", "Required before production:", ""])
1831
1835
  lines.extend("1. " + str(action) for action in item.get("required_actions", []))
1832
1836
  lines.append("")
1837
+ guidance = _resource_action_guidance()
1838
+ lines.extend(["## API actions, GraphQL and resource ownership", "", "Apply these steps where the workload accesses provider resources. Runtime proof: NOT ASSESSED.", ""])
1839
+ lines.extend("1. " + step for step in guidance["steps"])
1833
1840
  return "\n".join(lines).rstrip() + "\n"
1834
1841
 
1835
1842
 
1843
+ def _resource_action_guidance() -> Dict[str, Any]:
1844
+ return {
1845
+ "schema": "agenticdome.resource-action-onboarding.v1", "runtime_proof": "not_assessed",
1846
+ "python": {"http": "execute_http", "graphql": "execute_graphql", "ownership": "OwnershipGuard"},
1847
+ "typescript": {"http": "executeHttp", "graphql": "executeGraphql", "ownership": "OwnershipGuard"},
1848
+ "steps": [
1849
+ "Check the installed SDK exports and assigned runtime's GraphQL capability before changing an existing integration. Upgrade through the certified release path if unavailable.",
1850
+ "Route the real API executor through the exact HTTP/GraphQL helper; retain existing framework and MCP hooks. A helper elsewhere is not proof of coverage.",
1851
+ "Connect OwnershipGuard to authenticated request-scoped tenant/principal identity and read-only authoritative resource lookups. Check explicit allowed operations; read entitlement never grants deletion.",
1852
+ "Configure exact grants in Policy Studio. SuperSaaSAdmin defines the global ceiling; tenants narrow it. Every selected GraphQL mutation field needs its own grant. Do not weaken hard controls to pass a test.",
1853
+ "Test allowed reads, another user's resource, another tenant, denied deletion, multi-field GraphQL, approval hold/resume, changed payload, revoked ownership and provider lookup failure. Use staging fixtures, not real destructive actions.",
1854
+ "Prove BLOCKED and APPROVAL_REQUIRED execute zero provider calls, and a permitted action executes once. Approval must recheck current provider access; the destination must enforce permissions atomically with version preconditions.",
1855
+ "Record the tested SDK version, runtime capability, grant IDs and real-path test evidence. Imports, generated examples and catalogue presence alone do not prove the resolver is connected.",
1856
+ ],
1857
+ }
1858
+
1859
+
1836
1860
  def _onboarding_broker_options(config: Dict[str, Any]) -> Dict[str, str]:
1837
1861
  # An absent value is a pre-existing integration: retain the SDK/env default.
1838
1862
  if "execution_broker_mode" not in config:
@@ -0,0 +1,139 @@
1
+ """Provider-owned resource authorization shared by HTTP and MCP adapters.
2
+
3
+ Instantiate in a trusted gateway/provider process. Callbacks read the server's
4
+ authenticated request scope and system of record; no user/owner claim from an
5
+ agent is authoritative. Facts are resolved again on every execution, not cached.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import asyncio
10
+ from copy import deepcopy
11
+ from dataclasses import dataclass
12
+ import inspect
13
+ import re
14
+ import time
15
+
16
+
17
+ class OwnershipDenied(ValueError):
18
+ """The action must not reach the provider transport."""
19
+
20
+
21
+ @dataclass(frozen=True)
22
+ class ResourceRule:
23
+ resource_type: str
24
+ resource_argument: str
25
+ operation: str
26
+ relationship: str = "owner"
27
+ max_resources: int = 1
28
+
29
+
30
+ def _id(value):
31
+ return isinstance(value, str) and bool(value.strip()) and len(value) <= 512
32
+
33
+
34
+ def verify_resource_fact(subject, request, fact, relationship):
35
+ """Universal fact contract; a matching owner still needs operation rights."""
36
+ if not isinstance(subject, dict) or not all(_id(subject.get(k)) for k in ("tenant_id", "principal_id")):
37
+ raise OwnershipDenied("Authenticated tenant and principal are required")
38
+ if not isinstance(fact, dict) or any(fact.get(k) != request[k] for k in ("tenant_id", "resource_type", "resource_id")):
39
+ raise OwnershipDenied("Provider facts do not match the requested tenant and resource")
40
+ operations = fact.get("allowed_operations")
41
+ if not isinstance(operations, list) or request["operation"] not in operations:
42
+ raise OwnershipDenied("Provider does not permit this operation")
43
+ if relationship == "owner":
44
+ permitted = fact.get("owner_id") == subject["principal_id"]
45
+ else:
46
+ principals = fact.get("entitled_principals")
47
+ permitted = isinstance(principals, list) and subject["principal_id"] in principals
48
+ if not permitted: raise OwnershipDenied("Authenticated principal has no required resource relationship")
49
+
50
+
51
+ class OwnershipGuard:
52
+ def __init__(self, rules, *, resolve_subject, resolve_resource, deny_unmapped=True, timeout_seconds=5):
53
+ if not isinstance(rules, dict) or not rules or not callable(resolve_subject) or not callable(resolve_resource):
54
+ raise ValueError("Supply reviewed resource rules and trusted provider resolvers")
55
+ if not 0 < timeout_seconds <= 30: raise ValueError("Resolver timeout must be within 30 seconds")
56
+ self._rules = deepcopy(rules)
57
+ for tool, rule in self._rules.items():
58
+ if not _id(tool) or not isinstance(rule, ResourceRule) or not _id(rule.resource_type) or not _id(rule.operation):
59
+ raise ValueError("Use exact tool names and resource types/operations")
60
+ if rule.relationship not in {"owner", "entitled"} or type(rule.max_resources) is not int or not 1 <= rule.max_resources <= 50:
61
+ raise ValueError("Invalid resource relationship or batch limit")
62
+ if not re.fullmatch(r"[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*){0,7}", rule.resource_argument):
63
+ raise ValueError("Use an exact resource argument path")
64
+ self._subject = resolve_subject
65
+ self._resource = resolve_resource
66
+ self._deny_unmapped = deny_unmapped
67
+ self._timeout = timeout_seconds
68
+
69
+ def protects(self, tool):
70
+ return self._deny_unmapped or tool in self._rules
71
+
72
+ def _requests(self, tool, arguments, subject):
73
+ rule = self._rules.get(tool)
74
+ if rule is None:
75
+ if self._deny_unmapped: raise OwnershipDenied("Tool has no reviewed resource adapter")
76
+ return []
77
+ if not isinstance(subject, dict) or not all(_id(subject.get(k)) for k in ("tenant_id", "principal_id")):
78
+ raise OwnershipDenied("Authenticated tenant and principal are required")
79
+ value = arguments
80
+ for part in rule.resource_argument.split("."):
81
+ value = value.get(part) if isinstance(value, dict) else None
82
+ ids = value if isinstance(value, list) else [value]
83
+ if not ids or len(ids) > rule.max_resources or any(not _id(v) for v in ids):
84
+ raise OwnershipDenied("Missing resource identity or excessive resource scope")
85
+ return [(rule, {"tenant_id": subject["tenant_id"], "principal_id": subject["principal_id"],
86
+ "resource_type": rule.resource_type, "resource_id": rid, "operation": rule.operation,
87
+ "tool": tool, "arguments": deepcopy(arguments)}) for rid in dict.fromkeys(ids)]
88
+
89
+ def check(self, tool, arguments, *, expected_tenant=None):
90
+ if not self.protects(tool): return
91
+ try:
92
+ deadline = time.monotonic() + self._timeout
93
+ subject = self._subject()
94
+ if inspect.isawaitable(subject):
95
+ if inspect.iscoroutine(subject): subject.close()
96
+ raise OwnershipDenied("Use check_async with asynchronous resolvers")
97
+ subject = deepcopy(subject)
98
+ if expected_tenant is not None and (not isinstance(subject, dict) or subject.get("tenant_id") != str(expected_tenant)):
99
+ raise OwnershipDenied("Provider subject tenant does not match the enforcement tenant")
100
+ for rule, request in self._requests(tool, arguments, subject):
101
+ if time.monotonic() >= deadline: raise OwnershipDenied("Provider resource authorization timed out")
102
+ fact = self._resource(deepcopy(request))
103
+ if inspect.isawaitable(fact):
104
+ if inspect.iscoroutine(fact): fact.close()
105
+ raise OwnershipDenied("Use check_async with asynchronous resolvers")
106
+ if time.monotonic() >= deadline: raise OwnershipDenied("Provider resource authorization timed out")
107
+ verify_resource_fact(subject, request, fact, rule.relationship)
108
+ except OwnershipDenied: raise
109
+ except Exception as exc: raise OwnershipDenied("Provider resource authorization unavailable") from exc
110
+
111
+ async def check_async(self, tool, arguments, *, expected_tenant=None):
112
+ if not self.protects(tool): return
113
+ arguments = deepcopy(arguments)
114
+ async def resolve():
115
+ async def call(fn, *args):
116
+ value = fn(*args) if inspect.iscoroutinefunction(fn) else await asyncio.to_thread(fn, *args)
117
+ return await value if inspect.isawaitable(value) else value
118
+ subject = await call(self._subject)
119
+ subject = deepcopy(subject)
120
+ if expected_tenant is not None and (not isinstance(subject, dict) or subject.get("tenant_id") != str(expected_tenant)):
121
+ raise OwnershipDenied("Provider subject tenant does not match the enforcement tenant")
122
+ for rule, request in self._requests(tool, arguments, subject):
123
+ fact = await call(self._resource, deepcopy(request))
124
+ verify_resource_fact(subject, request, fact, rule.relationship)
125
+ try: await asyncio.wait_for(resolve(), timeout=self._timeout)
126
+ except OwnershipDenied: raise
127
+ except Exception as exc: raise OwnershipDenied("Provider resource authorization unavailable") from exc
128
+
129
+ def check_http(self, tool, arguments, evidence, *, expected_tenant=None):
130
+ # GraphQL IDs must come from interpreted fields, never unused variables
131
+ # or agent-provided aliases. The authenticated sidecar supplies evidence.
132
+ has_graphql = any(k.startswith(tool + "#") for k in self._rules)
133
+ if has_graphql or evidence.get("graphql_interpretation"):
134
+ if evidence.get("graphql_interpretation") != "agenticdome.graphql-actions.v1" or not isinstance(evidence.get("graphql_actions"), list):
135
+ raise OwnershipDenied("A compatible sidecar must interpret GraphQL before ownership checks")
136
+ for action in evidence["graphql_actions"]:
137
+ self.check(tool + "#" + action["coordinate"], action["arguments"], expected_tenant=expected_tenant)
138
+ else:
139
+ self.check(tool, arguments, expected_tenant=expected_tenant)