agentkit-sdk-python 0.9.1__py3-none-any.whl → 0.9.2__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.
@@ -59,9 +59,6 @@ except ImportError: # pragma: no cover - default migration path avoids veadk.
59
59
  ShortTermMemory = None # type: ignore[assignment,misc]
60
60
  VeadkRunner = None # type: ignore[assignment]
61
61
 
62
- from agentkit.apps.agent_server_app.middleware import (
63
- AgentkitTelemetryHTTPMiddleware,
64
- )
65
62
  from agentkit.apps.agent_server_app.credential_service import (
66
63
  AgentkitCredentialService,
67
64
  )
@@ -70,7 +67,9 @@ from agentkit.apps.agent_server_app.inbound_auth_adapter import (
70
67
  build_a2a_inbound_auth_executor_factory,
71
68
  save_inbound_auth,
72
69
  )
73
- from agentkit.apps.auth.inbound import redact_inbound_auth_headers
70
+ from agentkit.apps.agent_server_app.middleware import (
71
+ AgentkitTelemetryHTTPMiddleware,
72
+ )
74
73
  from agentkit.apps.agent_server_app.origin import (
75
74
  add_cors_compat_middleware,
76
75
  adk_supports_regex_origins,
@@ -79,6 +78,7 @@ from agentkit.apps.agent_server_app.origin import (
79
78
  supports_get_fast_api_kwarg,
80
79
  )
81
80
  from agentkit.apps.agent_server_app.telemetry import telemetry
81
+ from agentkit.apps.auth.inbound import redact_inbound_auth_headers
82
82
  from agentkit.apps.base_app import BaseAgentkitApp
83
83
 
84
84
  if TYPE_CHECKING:
@@ -124,6 +124,34 @@ def _resolve_memory_service(root_agent: BaseAgent) -> Any:
124
124
  return InMemoryMemoryService()
125
125
 
126
126
 
127
+ class _SsePayloadEventIdRewriter:
128
+ def __init__(self) -> None:
129
+ self._emitted_ids: set[str] = set()
130
+ self._next_id = 0
131
+
132
+ def prepare(self, event: Any) -> Any:
133
+ event_id = str(getattr(event, "id", "") or "")
134
+ should_rewrite = (
135
+ bool(getattr(event, "partial", False))
136
+ or not event_id
137
+ or event_id in self._emitted_ids
138
+ )
139
+ if should_rewrite:
140
+ event = event.model_copy(deep=True)
141
+ unique_id = (
142
+ f"{event_id}:veid:{self._next_id}"
143
+ if event_id
144
+ else f"veid:{self._next_id}"
145
+ )
146
+ self._next_id += 1
147
+ event.id = unique_id
148
+
149
+ emitted_id = str(getattr(event, "id", "") or "")
150
+ if emitted_id:
151
+ self._emitted_ids.add(emitted_id)
152
+ return event
153
+
154
+
127
155
  def _create_a2a_runner(
128
156
  *,
129
157
  entry: BaseAgent | App,
@@ -425,6 +453,7 @@ class AgentkitAgentServerApp(BaseAgentkitApp):
425
453
  # Convert the events to properly formatted SSE
426
454
  async def event_generator():
427
455
  error_payload = None
456
+ event_id_rewriter = _SsePayloadEventIdRewriter()
428
457
  try:
429
458
  stream_mode = (
430
459
  StreamingMode.SSE if req.streaming else StreamingMode.NONE
@@ -460,6 +489,9 @@ class AgentkitAgentServerApp(BaseAgentkitApp):
460
489
  artifact_event,
461
490
  ]
462
491
  for event_to_stream in events_to_stream:
492
+ event_to_stream = event_id_rewriter.prepare(
493
+ event_to_stream
494
+ )
463
495
  sse_event = event_to_stream.model_dump_json(
464
496
  exclude_none=True,
465
497
  by_alias=True,
@@ -596,6 +628,7 @@ class AgentkitAgentServerApp(BaseAgentkitApp):
596
628
 
597
629
  async def event_generator():
598
630
  error_payload = None
631
+ event_id_rewriter = _SsePayloadEventIdRewriter()
599
632
  try:
600
633
  runner = await self.server.get_runner_async(app_name)
601
634
  async with Aclosing(
@@ -607,6 +640,7 @@ class AgentkitAgentServerApp(BaseAgentkitApp):
607
640
  )
608
641
  ) as agen:
609
642
  async for event in agen:
643
+ event = event_id_rewriter.prepare(event)
610
644
  yield (
611
645
  "data: "
612
646
  + event.model_dump_json(
@@ -152,24 +152,27 @@ class AgentSentryV3:
152
152
  return UNAVAILABLE
153
153
  data = response.json()
154
154
  result = data.get("Result") or {}
155
+ metadata = data.get("ResponseMetadata") or {}
156
+ request_id = metadata.get("RequestId")
157
+ if metadata.get("Error"):
158
+ logger.warning("AgentSentry V3 API error request_id=%s", request_id)
159
+ return UNAVAILABLE
160
+ decision = (result.get("Decision") or {}).get("DecisionType")
155
161
  logger.info(
156
162
  "AgentSentry V3 hook=%s request_id=%s decision=%s degraded=%s",
157
163
  hook_name,
158
- (data.get("ResponseMetadata") or {}).get("RequestId"),
159
- (result.get("Decision") or {}).get("DecisionType"),
164
+ request_id,
165
+ decision,
160
166
  result.get("Degraded"),
161
167
  )
162
- if (data.get("ResponseMetadata") or {}).get("Error"):
163
- return UNAVAILABLE
164
- if result.get("Degraded") is not False:
165
- return UNAVAILABLE
166
- decision = (result.get("Decision") or {}).get("DecisionType")
167
- if type(decision) is int and decision == 1:
168
+ try:
169
+ decision = int(decision)
170
+ except (ValueError, TypeError, OverflowError):
168
171
  return None
169
- if type(decision) is int and decision == 2:
172
+ if decision == 2:
170
173
  return BLOCK
171
- # REPLACE/unknown decisions are stopped rather than executing unreviewed args.
172
- return UNAVAILABLE
174
+ # Only an explicit BLOCK decision stops a successful moderation response.
175
+ return None
173
176
  except (requests.RequestException, ValueError, TypeError, AttributeError):
174
177
  logger.warning("AgentSentry V3 transport or response error")
175
178
  return UNAVAILABLE
@@ -0,0 +1,29 @@
1
+ # Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from .client import AgentkitGatewayClient
16
+ from .types import (
17
+ CreateGatewayPluginBindingRequest,
18
+ CreateGatewayPluginBindingResponse,
19
+ CreateGatewayPluginRequest,
20
+ CreateGatewayPluginResponse,
21
+ )
22
+
23
+ __all__ = [
24
+ "AgentkitGatewayClient",
25
+ "CreateGatewayPluginBindingRequest",
26
+ "CreateGatewayPluginBindingResponse",
27
+ "CreateGatewayPluginRequest",
28
+ "CreateGatewayPluginResponse",
29
+ ]
@@ -0,0 +1,70 @@
1
+ # Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from __future__ import annotations
16
+
17
+ from typing import ClassVar
18
+
19
+ from agentkit.client import BaseAgentkitClient
20
+
21
+ from .types import (
22
+ CreateGatewayPluginBindingRequest,
23
+ CreateGatewayPluginBindingResponse,
24
+ CreateGatewayPluginRequest,
25
+ CreateGatewayPluginResponse,
26
+ )
27
+
28
+
29
+ class AgentkitGatewayClient(BaseAgentkitClient):
30
+ """Manage plugins on dedicated AgentKit gateways and bind them to MCP services."""
31
+
32
+ API_ACTIONS: ClassVar[dict[str, str]] = {
33
+ "CreateGatewayPlugin": "CreateGatewayPlugin",
34
+ "CreateGatewayPluginBinding": "CreateGatewayPluginBinding",
35
+ }
36
+
37
+ def __init__(
38
+ self,
39
+ access_key: str = "",
40
+ secret_key: str = "",
41
+ region: str = "",
42
+ session_token: str = "",
43
+ ) -> None:
44
+ super().__init__(
45
+ access_key=access_key,
46
+ secret_key=secret_key,
47
+ region=region,
48
+ session_token=session_token,
49
+ service_name="gateway",
50
+ )
51
+
52
+ def create_gateway_plugin(
53
+ self, request: CreateGatewayPluginRequest
54
+ ) -> CreateGatewayPluginResponse:
55
+ """Install a plugin; create a binding separately to apply it to requests."""
56
+ return self._invoke_api(
57
+ api_action="CreateGatewayPlugin",
58
+ request=request,
59
+ response_type=CreateGatewayPluginResponse,
60
+ )
61
+
62
+ def create_gateway_plugin_binding(
63
+ self, request: CreateGatewayPluginBindingRequest
64
+ ) -> CreateGatewayPluginBindingResponse:
65
+ """Bind an installed gateway plugin to a target MCP service."""
66
+ return self._invoke_api(
67
+ api_action="CreateGatewayPluginBinding",
68
+ request=request,
69
+ response_type=CreateGatewayPluginBindingResponse,
70
+ )
@@ -0,0 +1,45 @@
1
+ # Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from __future__ import annotations
16
+
17
+ from pydantic import BaseModel, Field
18
+
19
+
20
+ class GatewayBaseModel(BaseModel):
21
+ model_config = {"populate_by_name": True}
22
+
23
+
24
+ class CreateGatewayPluginRequest(GatewayBaseModel):
25
+ gateway_instance_id: str = Field(..., alias="GatewayInstanceId")
26
+ gateway_plugin_name: str = Field(..., alias="GatewayPluginName")
27
+ gateway_plugin_config: str = Field(..., alias="GatewayPluginConfig")
28
+
29
+
30
+ class CreateGatewayPluginResponse(GatewayBaseModel):
31
+ gateway_plugin_id: str | None = Field(default=None, alias="GatewayPluginId")
32
+
33
+
34
+ class CreateGatewayPluginBindingRequest(GatewayBaseModel):
35
+ gateway_plugin_id: str = Field(..., alias="GatewayPluginId")
36
+ target_id: str = Field(..., alias="TargetId")
37
+ gateway_plugin_binding_config: str = Field(..., alias="GatewayPluginBindingConfig")
38
+ enable: bool | None = Field(default=None, alias="Enable")
39
+ comments: str | None = Field(default=None, alias="Comments")
40
+
41
+
42
+ class CreateGatewayPluginBindingResponse(GatewayBaseModel):
43
+ gateway_plugin_binding_id: str | None = Field(
44
+ default=None, alias="GatewayPluginBindingId"
45
+ )
agentkit/version.py CHANGED
@@ -12,4 +12,4 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- VERSION = "0.9.1"
15
+ VERSION = "0.9.2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentkit-sdk-python
3
- Version: 0.9.1
3
+ Version: 0.9.2
4
4
  Summary: Python SDK for transforming any AI agent into a production-ready application. Framework-agnostic primitives for runtime, memory, authentication, and tools with volcengine-managed infrastructure.
5
5
  Author-email: Xiangrui Cheng <innsdcc@gmail.com>, Yumeng Bao <baoyumeng.123@gmail.com>, Yaozheng Fang <fangyozheng@gmail.com>, Guodong Li <cu.eric.lee@gmail.com>
6
6
  License: Apache License
@@ -1,6 +1,6 @@
1
1
  agentkit/__init__.py,sha256=l27ZMDslc3VhmmnPZJyrqVvTDoZ0LqhCtM5hw0caHcU,1021
2
2
  agentkit/errors.py,sha256=UWlXv0ZsXd_oLTMlxuf4u9-XkTdRYeVZueE--Z3JsHU,1214
3
- agentkit/version.py,sha256=xdaOmClla_D6rxyWhfTBx5FMq3JRKpWmIZhqZYUaCSY,653
3
+ agentkit/version.py,sha256=S-JFp6zp3F5qnumt6_WB_5ZZ686sIhab2ZIUhSDOP7k,653
4
4
  agentkit/apps/__init__.py,sha256=_Na1A4NSaMbVfPbsFKj2U-yI5mytD7W5skMaAOGbauY,2328
5
5
  agentkit/apps/base_app.py,sha256=3hZZExL1wyTGWveJEZZoqXN086MzmkVS_WU1vyulIWg,754
6
6
  agentkit/apps/utils.py,sha256=IzimIDmT6FS6PV9MLimPh46mq5zT-EjVmnYPxBdyEq0,1934
@@ -8,7 +8,7 @@ agentkit/apps/a2a_app/__init__.py,sha256=pkSabKw7_ai4NOo56pXKL40EcaxIDh6HYxPXOY7
8
8
  agentkit/apps/a2a_app/a2a_app.py,sha256=mFuPFuqRlGdQ2VIjQq2_gtQKWwnkwSjSmIMRnammWJU,7605
9
9
  agentkit/apps/a2a_app/telemetry.py,sha256=vR8tf7EHLor62cxs5PBx4mrfHeOaV1a7Xryqlu8nGCU,4290
10
10
  agentkit/apps/agent_server_app/__init__.py,sha256=pkSabKw7_ai4NOo56pXKL40EcaxIDh6HYxPXOY7qWbo,634
11
- agentkit/apps/agent_server_app/agent_server_app.py,sha256=Iu4_9OXpsigS7mqvBnXFLU6R6Q29c9f_rCMUIofhMBw,27410
11
+ agentkit/apps/agent_server_app/agent_server_app.py,sha256=ZNhmBtazxQKyfHsLPl8GDJsausziXtYfAsdO3be06jQ,28620
12
12
  agentkit/apps/agent_server_app/credential_service.py,sha256=jBSIY6-1yc01rRRVYN8wuahTIs9AEY4zH5JGSAWIzUU,3468
13
13
  agentkit/apps/agent_server_app/inbound_auth.py,sha256=FPCfFdg13Z9E-kasyZ-in3COdXHG_exKHAFThwXFnS8,1394
14
14
  agentkit/apps/agent_server_app/inbound_auth_adapter.py,sha256=n0ji_wKVmBOabepqTqWR1_0mrcYjH2xZlQJx-tGgNcs,6087
@@ -76,11 +76,14 @@ agentkit/platform/constants.py,sha256=52XqqOEBcvGQFgEb2rALyaDhdx1MOT9YSyS1s8VSYV
76
76
  agentkit/platform/context.py,sha256=eb6ub4nUhoV1hXawjSVdY7gfc5XcgHJjFIhrzOuQ2G0,1662
77
77
  agentkit/platform/provider.py,sha256=Yy5bYveVYQOJiR8_s_DW7rEDtK4cXZQSxLaUifDozuY,2245
78
78
  agentkit/plugins/__init__.py,sha256=f8WA2b4D44jM42QGY7OPAG-3EwV8URnqigwABG8JLT0,129
79
- agentkit/plugins/agentsentry_v3.py,sha256=fNucjUc8gLgCtFcOAEdwos8iNtij50q2DW9wA_HtuEU,6908
79
+ agentkit/plugins/agentsentry_v3.py,sha256=mirwC-xvQ_X-oA6JcuHqZfolc7AlFz83Zxa_CDECUzM,6925
80
80
  agentkit/plugins/llm_shield.py,sha256=1z6GgZPgyFYxq9Uyf3HAkFsU2xEGqlROLlutdHirsKM,20722
81
81
  agentkit/sdk/__init__.py,sha256=lT6PKXd1N-Z4kMYIe2fdNLq9Z_apddIcwkS1DOGZSZI,635
82
82
  agentkit/sdk/account/client.py,sha256=hOxqpiI0H7qlsBZR3aUNKi8G7eJOr46GtAS-J9on_Uk,3919
83
83
  agentkit/sdk/account/types.py,sha256=RQdVaeQxd_ntlyG2HZIx4q24m1aDvttxncXtrSamILE,1540
84
+ agentkit/sdk/gateway/__init__.py,sha256=Ujt-tNcwI4CKELMZ4Z0LCVT_cjvt9CpOw_FyYou1DOI,1040
85
+ agentkit/sdk/gateway/client.py,sha256=KXf_hKkVe6pHfKwf_UQVlScLGnXn4Upj4ZjObr6pZqs,2384
86
+ agentkit/sdk/gateway/types.py,sha256=jcf7YUWxT7-sQZm8mfOwHdrKd791oKCVr5zkAoAWVvQ,1756
84
87
  agentkit/sdk/identity/__init__.py,sha256=pkSabKw7_ai4NOo56pXKL40EcaxIDh6HYxPXOY7qWbo,634
85
88
  agentkit/sdk/identity/auth.py,sha256=zRX5ViIiEJZedBx4dctb7zEGYsOme70UmOPZFkBXvKk,2808
86
89
  agentkit/sdk/identity/client.py,sha256=LY0qds5y2p0b3_y1c7xa_0EnGCOub7c-D7VMMCEv-ew,2915
@@ -291,9 +294,9 @@ agentkit_identity/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
291
294
  agentkit_identity/runtime.py,sha256=hQHLvbAK760teFPTGZ0RG9Ed5DQAXAqIdaAm9ojzS34,14423
292
295
  agentkit_identity/transport.py,sha256=kwGHSEQ5Qcn1kIu6N6DVid7MdDUMj5uaIRIUA_tJ3cM,7693
293
296
  agentkit_identity/types.py,sha256=lT8KQz1pG0rgdy5Gh6WnM0mq9VqCsWSE41Z8Fw3DHZo,7358
294
- agentkit_sdk_python-0.9.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
295
- agentkit_sdk_python-0.9.1.dist-info/METADATA,sha256=gMsFpCpKN3GzKx7U2cTE-dSlLED1FBeuD2npf3FsESk,21544
296
- agentkit_sdk_python-0.9.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
297
- agentkit_sdk_python-0.9.1.dist-info/entry_points.txt,sha256=fhzZUsvsLXeB4mPaa0SBQiTBqFT404uDAKPaePAOUAE,58
298
- agentkit_sdk_python-0.9.1.dist-info/top_level.txt,sha256=Kw8DVx7vzg-oUh7xC_hBZw7OwKW3Y_fo_8rkWOL1d5o,27
299
- agentkit_sdk_python-0.9.1.dist-info/RECORD,,
297
+ agentkit_sdk_python-0.9.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
298
+ agentkit_sdk_python-0.9.2.dist-info/METADATA,sha256=WKCRL6ReEdjQImf2gHyuauwZO1jHNj9cMmC3qlaEGJs,21544
299
+ agentkit_sdk_python-0.9.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
300
+ agentkit_sdk_python-0.9.2.dist-info/entry_points.txt,sha256=fhzZUsvsLXeB4mPaa0SBQiTBqFT404uDAKPaePAOUAE,58
301
+ agentkit_sdk_python-0.9.2.dist-info/top_level.txt,sha256=Kw8DVx7vzg-oUh7xC_hBZw7OwKW3Y_fo_8rkWOL1d5o,27
302
+ agentkit_sdk_python-0.9.2.dist-info/RECORD,,