oneshot-python 0.7.1__tar.gz → 0.8.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: oneshot-python
3
- Version: 0.7.1
3
+ Version: 0.8.0
4
4
  Summary: Core Python SDK for the OneShot API — HTTP client with x402 payment handling
5
5
  License-Expression: MIT
6
6
  Requires-Python: >=3.10
@@ -25,7 +25,7 @@ from oneshot._errors import (
25
25
  )
26
26
  from oneshot.x402 import sign_payment_authorization, encode_payment_header, parse_payment_required
27
27
 
28
- SDK_VERSION = "0.6.0"
28
+ SDK_VERSION = "0.8.0"
29
29
 
30
30
  # ---------------------------------------------------------------------------
31
31
  # Environment configuration
@@ -172,11 +172,9 @@ class OneShotClient:
172
172
  )
173
173
 
174
174
  # Step 4 — Re-POST with payment headers (x402 format)
175
- auth_json = json.dumps(auth)
176
175
  headers = {
177
176
  **self._headers(),
178
177
  "payment-signature": encode_payment_header(auth),
179
- "x-payment": auth_json, # backwards compat for identity extraction
180
178
  }
181
179
  if quote_id:
182
180
  headers["x-quote-id"] = quote_id
@@ -278,6 +276,111 @@ class OneShotClient:
278
276
  return {"success": True}
279
277
  return resp.json()
280
278
 
279
+ def call_free_delete(
280
+ self,
281
+ endpoint: str,
282
+ ) -> Any:
283
+ """DELETE a free endpoint (blocking)."""
284
+ return asyncio.get_event_loop().run_until_complete(
285
+ self.acall_free_delete(endpoint)
286
+ )
287
+
288
+ async def acall_free_delete(
289
+ self,
290
+ endpoint: str,
291
+ ) -> Any:
292
+ """DELETE a free endpoint (async)."""
293
+ url = f"{self.base_url}{endpoint}"
294
+ async with httpx.AsyncClient(timeout=httpx.Timeout(30.0)) as client:
295
+ resp = await client.delete(url, headers=self._headers())
296
+ if not resp.is_success:
297
+ raise ToolError(f"DELETE {endpoint} failed", resp.status_code, resp.text)
298
+ if resp.status_code == 204 or not resp.text:
299
+ return {"success": True}
300
+ return resp.json()
301
+
302
+ # ------------------------------------------------------------------
303
+ # Browser
304
+ # ------------------------------------------------------------------
305
+
306
+ def browser(
307
+ self,
308
+ task: str,
309
+ *,
310
+ output_schema: Optional[dict[str, Any]] = None,
311
+ start_url: Optional[str] = None,
312
+ allowed_domains: Optional[list[str]] = None,
313
+ profile_id: Optional[str] = None,
314
+ secrets: Optional[dict[str, str]] = None,
315
+ max_steps: Optional[int] = None,
316
+ max_cost: Optional[float] = None,
317
+ timeout_sec: int = 300,
318
+ ) -> Any:
319
+ """Run a browser automation task. Blocking."""
320
+ return asyncio.get_event_loop().run_until_complete(
321
+ self.abrowser(
322
+ task, output_schema=output_schema, start_url=start_url,
323
+ allowed_domains=allowed_domains, profile_id=profile_id,
324
+ secrets=secrets, max_steps=max_steps, max_cost=max_cost,
325
+ timeout_sec=timeout_sec,
326
+ )
327
+ )
328
+
329
+ async def abrowser(
330
+ self,
331
+ task: str,
332
+ *,
333
+ output_schema: Optional[dict[str, Any]] = None,
334
+ start_url: Optional[str] = None,
335
+ allowed_domains: Optional[list[str]] = None,
336
+ profile_id: Optional[str] = None,
337
+ secrets: Optional[dict[str, str]] = None,
338
+ max_steps: Optional[int] = None,
339
+ max_cost: Optional[float] = None,
340
+ timeout_sec: int = 300,
341
+ ) -> Any:
342
+ """Run a browser automation task. Async."""
343
+ payload: dict[str, Any] = {"task": task}
344
+ if output_schema is not None:
345
+ payload["output_schema"] = output_schema
346
+ if start_url is not None:
347
+ payload["start_url"] = start_url
348
+ if allowed_domains is not None:
349
+ payload["allowed_domains"] = allowed_domains
350
+ if profile_id is not None:
351
+ payload["profile_id"] = profile_id
352
+ if secrets is not None:
353
+ payload["secrets"] = secrets
354
+ if max_steps is not None:
355
+ payload["max_steps"] = max_steps
356
+ return await self.acall_tool(
357
+ "/v1/tools/browser", payload, max_cost=max_cost, timeout_sec=timeout_sec,
358
+ )
359
+
360
+ def create_browser_profile(self, name: str) -> dict:
361
+ """Create a persistent browser profile. Blocking."""
362
+ return self.call_free_post("/v1/tools/browser/profiles", {"name": name})
363
+
364
+ async def acreate_browser_profile(self, name: str) -> dict:
365
+ """Create a persistent browser profile. Async."""
366
+ return await self.acall_free_post("/v1/tools/browser/profiles", {"name": name})
367
+
368
+ def list_browser_profiles(self) -> list:
369
+ """List all browser profiles. Blocking."""
370
+ return self.call_free_get("/v1/tools/browser/profiles")
371
+
372
+ async def alist_browser_profiles(self) -> list:
373
+ """List all browser profiles. Async."""
374
+ return await self.acall_free_get("/v1/tools/browser/profiles")
375
+
376
+ def delete_browser_profile(self, profile_id: str) -> dict:
377
+ """Delete a browser profile. Blocking."""
378
+ return self.call_free_delete(f"/v1/tools/browser/profiles/{profile_id}")
379
+
380
+ async def adelete_browser_profile(self, profile_id: str) -> dict:
381
+ """Delete a browser profile. Async."""
382
+ return await self.acall_free_delete(f"/v1/tools/browser/profiles/{profile_id}")
383
+
281
384
  # ------------------------------------------------------------------
282
385
  # Balance
283
386
  # ------------------------------------------------------------------
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "oneshot-python"
3
- version = "0.7.1"
3
+ version = "0.8.0"
4
4
  description = "Core Python SDK for the OneShot API — HTTP client with x402 payment handling"
5
5
  readme = {text = "Core Python SDK for the OneShot API", content-type = "text/plain"}
6
6
  license = "MIT"
File without changes
File without changes