assistant-runtime-sdk 1.1.0__tar.gz → 1.2.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: assistant_runtime_sdk
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Python SDK for FAC Cloud - the Assistant Runtime AI assistant backend
5
5
  Keywords: frappe,ai,assistant,llm,mcp,anthropic,openai,streaming
6
6
  Author: Paul Clinton
@@ -157,9 +157,9 @@ surface. A representative selection:
157
157
  `create_message()`, `update_conversation()`, `delete_conversation()`, `delete_message()`
158
158
 
159
159
  **Billing** — `get_plan_comparison()`, `get_usage_dashboard()`, `get_usage_history()`,
160
- `get_credit_balance()`, `initiate_checkout()`, `verify_checkout()`, `upgrade_plan()`,
161
- `cancel_subscription()`, `get_invoices()`, `get_payment_instrument()`,
162
- `update_payment_method()`
160
+ `get_credit_balance()`, `initiate_checkout()`, `create_hosted_checkout()`,
161
+ `verify_checkout()`, `upgrade_plan()`, `cancel_subscription()`, `get_invoices()`,
162
+ `get_payment_instrument()`, `update_payment_method()`
163
163
 
164
164
  **Users & seats** — `register_user()`, `get_user()`, `list_users()`, `invite_user()`,
165
165
  `add_user_seat()`, `set_user_credit_limit()`, `get_user_auth_status()`
@@ -124,9 +124,9 @@ surface. A representative selection:
124
124
  `create_message()`, `update_conversation()`, `delete_conversation()`, `delete_message()`
125
125
 
126
126
  **Billing** — `get_plan_comparison()`, `get_usage_dashboard()`, `get_usage_history()`,
127
- `get_credit_balance()`, `initiate_checkout()`, `verify_checkout()`, `upgrade_plan()`,
128
- `cancel_subscription()`, `get_invoices()`, `get_payment_instrument()`,
129
- `update_payment_method()`
127
+ `get_credit_balance()`, `initiate_checkout()`, `create_hosted_checkout()`,
128
+ `verify_checkout()`, `upgrade_plan()`, `cancel_subscription()`, `get_invoices()`,
129
+ `get_payment_instrument()`, `update_payment_method()`
130
130
 
131
131
  **Users & seats** — `register_user()`, `get_user()`, `list_users()`, `invite_user()`,
132
132
  `add_user_seat()`, `set_user_credit_limit()`, `get_user_auth_status()`
@@ -53,7 +53,7 @@ Standalone Functions:
53
53
 
54
54
  """
55
55
 
56
- __version__ = "1.1.0"
56
+ __version__ = "1.2.0"
57
57
  __author__ = "Paul Clinton"
58
58
  __license__ = "AGPL-3.0"
59
59
 
@@ -872,6 +872,16 @@ class AsyncAssistantRuntimeClient(BaseAssistantRuntimeClient):
872
872
  endpoint, payload = self._prepare_initiate_checkout(plan, billing_cycle, gateway, billing_name, billing_email)
873
873
  return await self._request_post_json(endpoint, payload, api_base=self.billing_api_base)
874
874
 
875
+ async def create_hosted_checkout(
876
+ self,
877
+ purpose: str,
878
+ params: Optional[Dict[str, Any]] = None,
879
+ return_url: Optional[str] = None,
880
+ ) -> Optional[Dict[str, Any]]:
881
+ """Async version of AssistantRuntimeClient.create_hosted_checkout."""
882
+ endpoint, payload = self._prepare_create_hosted_checkout(purpose, params, return_url)
883
+ return await self._request_post_json(endpoint, payload, api_base=self.billing_api_base)
884
+
875
885
  async def verify_checkout(self, session_id: Optional[str] = None) -> Optional[Dict[str, Any]]:
876
886
  """Async version of AssistantRuntimeClient.verify_checkout."""
877
887
  endpoint, payload = self._prepare_verify_checkout(session_id)
@@ -906,6 +906,20 @@ class BaseAssistantRuntimeClient:
906
906
  payload["billing_email"] = billing_email
907
907
  return "initiate_checkout", payload
908
908
 
909
+ def _prepare_create_hosted_checkout(
910
+ self, purpose: str, params: Optional[Dict[str, Any]] = None,
911
+ return_url: Optional[str] = None,
912
+ ) -> tuple:
913
+ self._require_billing()
914
+ payload: Dict[str, Any] = {
915
+ "tenant_id": self.tenant_id,
916
+ "purpose": purpose,
917
+ "params": params or {},
918
+ }
919
+ if return_url:
920
+ payload["return_url"] = return_url
921
+ return "create_hosted_checkout", payload
922
+
909
923
  def _prepare_verify_checkout(self, session_id: Optional[str] = None) -> tuple:
910
924
  self._require_billing()
911
925
  payload: Dict[str, Any] = {"tenant_id": self.tenant_id}
@@ -1238,6 +1238,34 @@ class AssistantRuntimeClient(BaseAssistantRuntimeClient):
1238
1238
  endpoint, payload = self._prepare_initiate_checkout(plan, billing_cycle, gateway, billing_name, billing_email)
1239
1239
  return self._request_post_json(endpoint, payload, api_base=self.billing_api_base)
1240
1240
 
1241
+ def create_hosted_checkout(
1242
+ self,
1243
+ purpose: str,
1244
+ params: Optional[Dict[str, Any]] = None,
1245
+ return_url: Optional[str] = None,
1246
+ ) -> Optional[Dict[str, Any]]:
1247
+ """
1248
+ Get a link to the page where a purchase is paid for.
1249
+
1250
+ Payments are collected on the runtime's own public site rather than
1251
+ on this one, so that a payment gateway can be onboarded against a
1252
+ single declared address. Send the user to ``checkout_url``; they are
1253
+ returned to ``return_url`` when they are done.
1254
+
1255
+ Args:
1256
+ purpose: "Subscription", "Payment Method", "Credits", "Pack" or "Seat".
1257
+ params: Purpose-specific arguments — e.g. ``{"plan": "Team",
1258
+ "billing_cycle": "monthly"}`` for a subscription, or
1259
+ ``{"credit_amount": 5000}`` for credits.
1260
+ return_url: Where to send the user afterwards. Must be on this
1261
+ site; defaults to the registered site URL.
1262
+
1263
+ Returns:
1264
+ Dict with checkout_url, session, purpose and expires_at.
1265
+ """
1266
+ endpoint, payload = self._prepare_create_hosted_checkout(purpose, params, return_url)
1267
+ return self._request_post_json(endpoint, payload, api_base=self.billing_api_base)
1268
+
1241
1269
  def verify_checkout(self, session_id: Optional[str] = None) -> Optional[Dict[str, Any]]:
1242
1270
  """Verify payment completion after checkout."""
1243
1271
  endpoint, payload = self._prepare_verify_checkout(session_id)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "assistant_runtime_sdk"
3
- version = "1.1.0"
3
+ version = "1.2.0"
4
4
  description = "Python SDK for FAC Cloud - the Assistant Runtime AI assistant backend"
5
5
  readme = "README.md"
6
6
  license = {text = "AGPL-3.0"}