capture-runtime-client 0.4.2__tar.gz → 0.4.4__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.
Files changed (74) hide show
  1. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/PKG-INFO +1 -1
  2. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/pyproject.toml +4 -2
  3. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/client.py +44 -0
  4. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/contracts.py +1 -1
  5. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/errors.py +12 -0
  6. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/assets/contract-set.json +1 -1
  7. capture_runtime_client-0.4.4/src/capture_runtime_client/private/assets/contract-set.sha256 +1 -0
  8. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/generated_models.py +4 -4
  9. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/capture-ocr-projection-v3.schema.json +1 -1
  10. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/ocr-compute-preflight-v2.schema.json +2 -2
  11. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/runtime-ready.schema.json +4 -4
  12. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/transport.py +7 -0
  13. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/tests/test_client_sdk.py +7 -7
  14. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/uv.lock +1 -1
  15. capture_runtime_client-0.4.2/src/capture_runtime_client/private/assets/contract-set.sha256 +0 -1
  16. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/.gitignore +0 -0
  17. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/README.md +0 -0
  18. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/project.json +0 -0
  19. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/__init__.py +0 -0
  20. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/_discovery.py +0 -0
  21. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/_error_mapping.py +0 -0
  22. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/_retry.py +0 -0
  23. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/_transport.py +0 -0
  24. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/codec.py +0 -0
  25. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/__init__.py +0 -0
  26. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/assets/__init__.py +0 -0
  27. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/__init__.py +0 -0
  28. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/capture-block.schema.json +0 -0
  29. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/capture-document.schema.json +0 -0
  30. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/capture-engine.schema.json +0 -0
  31. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/capture-event-v2.schema.json +0 -0
  32. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/capture-failure-v2.schema.json +0 -0
  33. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/capture-operation-v2.schema.json +0 -0
  34. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/capture-source.schema.json +0 -0
  35. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/capture-streaming-result.schema.json +0 -0
  36. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/error-body-v2.schema.json +0 -0
  37. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/error-envelope-v2.schema.json +0 -0
  38. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/finalize-ingestion-v2.schema.json +0 -0
  39. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/ingestion-v2.schema.json +0 -0
  40. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/ocr-box-v3.schema.json +0 -0
  41. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/ocr-page-projection-v3.schema.json +0 -0
  42. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/ocr-page-scope-v2.schema.json +0 -0
  43. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/ocr-point-v3.schema.json +0 -0
  44. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/ocr-provenance-resolved-v3.schema.json +0 -0
  45. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/ocr-provenance-unavailable-v3.schema.json +0 -0
  46. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/ocr-provenance-v3.schema.json +0 -0
  47. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/ocr-raster-v3.schema.json +0 -0
  48. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/open-ingestion-v2.schema.json +0 -0
  49. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/open-structuring-session-v2.schema.json +0 -0
  50. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/page-locator.schema.json +0 -0
  51. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/partial-capture-v2.schema.json +0 -0
  52. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/raw-capture-segment.schema.json +0 -0
  53. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/raw-capture.schema.json +0 -0
  54. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/report-structuring-failure-v2.schema.json +0 -0
  55. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/runtime-artifact-descriptor-v2.schema.json +0 -0
  56. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/runtime-installation-v2.schema.json +0 -0
  57. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/runtime-installations-v2.schema.json +0 -0
  58. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/runtime-model-installation-v2.schema.json +0 -0
  59. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/runtime-model-installations-v2.schema.json +0 -0
  60. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/runtime-model-option-v2.schema.json +0 -0
  61. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/runtime-model-options-v2.schema.json +0 -0
  62. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/runtime-requirement-v2.schema.json +0 -0
  63. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/runtime-requirements-v2.schema.json +0 -0
  64. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/runtime-streaming-capabilities-v2.schema.json +0 -0
  65. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/start-capture-v2.schema.json +0 -0
  66. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/start-runtime-installation-v2.schema.json +0 -0
  67. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/start-runtime-model-installation-v2.schema.json +0 -0
  68. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/structuring-batch-v2.schema.json +0 -0
  69. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/structuring-provider-capability-v2.schema.json +0 -0
  70. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/structuring-semantic-block-v2.schema.json +0 -0
  71. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/structuring-session-v2.schema.json +0 -0
  72. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/submit-structuring-batch-v2.schema.json +0 -0
  73. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/private/schemas/time-locator.schema.json +0 -0
  74. {capture_runtime_client-0.4.2 → capture_runtime_client-0.4.4}/src/capture_runtime_client/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: capture-runtime-client
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: Capture Runtime HTTP, in-memory, discovery, and protocol client SDK.
5
5
  License: MIT
6
6
  Requires-Python: <3.15,>=3.12
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "capture-runtime-client"
7
- version = "0.4.2"
7
+ version = "0.4.4"
8
8
  description = "Capture Runtime HTTP, in-memory, discovery, and protocol client SDK."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12,<3.15"
@@ -15,7 +15,7 @@ dependencies = [
15
15
  ]
16
16
 
17
17
  [tool.capture_runtime_client]
18
- contract_set_sha256 = "d293a3de26114f1b4fd65ea6d6d3f157fa2f93109b31e1e30d5d15ef0dfdeb40"
18
+ contract_set_sha256 = "03ba27e42e13292162b0f3da12bf3fe065edad12806efdf4bb19e0cc360e42d7"
19
19
 
20
20
  [tool.hatch.build.targets.wheel]
21
21
  packages = ["src/capture_runtime_client"]
@@ -36,6 +36,8 @@ dev = [
36
36
  pythonpath = ["src"]
37
37
  testpaths = ["tests"]
38
38
  addopts = "-ra"
39
+ # Remove tmp_path directories after every session; tests must not leave temp files.
40
+ tmp_path_retention_policy = "failed"
39
41
 
40
42
  [tool.ruff]
41
43
  line-length = 100
@@ -62,6 +62,8 @@ from .transport import RuntimeTransport
62
62
 
63
63
  @dataclass(frozen=True, slots=True)
64
64
  class CaptureUpload:
65
+ """One source file to capture: its bytes, source kind, and capture options."""
66
+
65
67
  file_name: str
66
68
  content: bytes
67
69
  source_kind: CaptureSourceKind | str
@@ -80,6 +82,8 @@ class CaptureUpload:
80
82
 
81
83
  @dataclass(frozen=True, slots=True)
82
84
  class CaptureStreamingResult:
85
+ """Terminal capture state with its raw extraction and structured document."""
86
+
83
87
  operation: CaptureOperation
84
88
  raw: RawCapture
85
89
  result: CaptureDocument
@@ -125,9 +129,11 @@ class CaptureRuntimeClient:
125
129
  self._discovering = False
126
130
 
127
131
  def handshake(self) -> RuntimeReady:
132
+ """Read ``/v2/health/ready`` and check the runtime's API and contract identity."""
128
133
  return handshake_runtime(self._request)
129
134
 
130
135
  def discover(self) -> RuntimeDiscovery:
136
+ """Discover and verify the runtime contract set once, then reuse the cached result."""
131
137
  if self._discovery is not None:
132
138
  return self._discovery
133
139
  if self._discovering:
@@ -143,11 +149,13 @@ class CaptureRuntimeClient:
143
149
  self._discovering = False
144
150
 
145
151
  def get_requirements(self) -> RuntimeRequirements:
152
+ """List the runtime requirements (OCR, Whisper, Ollama) and their install status."""
146
153
  return decode_model(self._request("GET", "/v2/runtime/requirements"), RuntimeRequirements)
147
154
 
148
155
  def start_installation(
149
156
  self, requirement_id: str, *, idempotency_key: UUID | str
150
157
  ) -> RuntimeInstallation:
158
+ """Start installing a requirement with user consent; the key makes retries idempotent."""
151
159
  return decode_model(
152
160
  self._request(
153
161
  "POST",
@@ -159,6 +167,7 @@ class CaptureRuntimeClient:
159
167
  )
160
168
 
161
169
  def list_installations(self) -> list[RuntimeInstallation]:
170
+ """List requirement installations known to the runtime, including active ones."""
162
171
  payload = decode_response(self._request("GET", "/v2/runtime/installations"))
163
172
  if not isinstance(payload, Mapping) or not isinstance(payload.get("items"), list):
164
173
  raise CaptureRuntimeProtocolError("Capture Runtime installations response is invalid.")
@@ -170,21 +179,25 @@ class CaptureRuntimeClient:
170
179
  ) from error
171
180
 
172
181
  def get_installation(self, installation_id: str) -> RuntimeInstallation:
182
+ """Read one requirement installation's status and progress."""
173
183
  return decode_model(
174
184
  self._request("GET", f"/v2/runtime/installations/{_safe_id(installation_id)}"),
175
185
  RuntimeInstallation,
176
186
  )
177
187
 
178
188
  def cancel_installation(self, installation_id: str) -> RuntimeInstallation:
189
+ """Cancel a queued or running requirement installation."""
179
190
  return decode_model(
180
191
  self._request("POST", f"/v2/runtime/installations/{_safe_id(installation_id)}/cancel"),
181
192
  RuntimeInstallation,
182
193
  )
183
194
 
184
195
  def get_model_options(self) -> RuntimeModelOptions:
196
+ """List the structuring model options the runtime allows."""
185
197
  return decode_model(self._request("GET", "/v2/runtime/model-options"), RuntimeModelOptions)
186
198
 
187
199
  def get_model_installation(self, installation_id: str) -> RuntimeModelInstallation:
200
+ """Read one structuring model installation's status."""
188
201
  return decode_model(
189
202
  self._request("GET", f"/v2/runtime/model-installations/{_safe_id(installation_id)}"),
190
203
  RuntimeModelInstallation,
@@ -195,6 +208,7 @@ class CaptureRuntimeClient:
195
208
  return self.get_model_installation(installation_id)
196
209
 
197
210
  def cancel_model_installation(self, installation_id: str) -> RuntimeModelInstallation:
211
+ """Cancel a structuring model installation."""
198
212
  return decode_model(
199
213
  self._request(
200
214
  "POST", f"/v2/runtime/model-installations/{_safe_id(installation_id)}/cancel"
@@ -216,6 +230,7 @@ class CaptureRuntimeClient:
216
230
  target_language: str | None = None,
217
231
  pdf_page_numbers: Sequence[int] | None = None,
218
232
  ) -> CaptureOperation:
233
+ """Read a local file and start a capture for it (see :meth:`start_capture`)."""
219
234
  return self.start_capture(
220
235
  CaptureUpload(
221
236
  path.name,
@@ -229,23 +244,28 @@ class CaptureRuntimeClient:
229
244
  )
230
245
 
231
246
  def get_capture(self, capture_id: str) -> CaptureOperation:
247
+ """Read a capture operation's current state."""
232
248
  return self.get_streaming_capture(capture_id)
233
249
 
234
250
  def cancel_capture(self, capture_id: str) -> CaptureOperation:
251
+ """Request cancellation of a capture operation."""
235
252
  return self.cancel_streaming_capture(capture_id)
236
253
 
237
254
  def get_raw(self, capture_id: str) -> RawCapture:
255
+ """Read the raw extraction of a capture."""
238
256
  return decode_model(
239
257
  self._request("GET", f"/v2/captures/{_safe_id(capture_id)}/raw"), RawCapture
240
258
  )
241
259
 
242
260
  def get_ocr(self, capture_id: str) -> CaptureOcrProjection:
261
+ """Read the page-addressable OCR projection of a capture."""
243
262
  return decode_model(
244
263
  self._request("GET", f"/v2/captures/{_safe_id(capture_id)}/ocr"),
245
264
  CaptureOcrProjection,
246
265
  )
247
266
 
248
267
  def get_result(self, capture_id: str) -> CaptureStreamingResult:
268
+ """Read the terminal capture state, raw extraction, and structured document."""
249
269
  return self.get_streaming_result(capture_id)
250
270
 
251
271
  def open_structuring_session(
@@ -289,12 +309,14 @@ class CaptureRuntimeClient:
289
309
  )
290
310
 
291
311
  def get_structuring_session(self, capture_id: str) -> StructuringSession:
312
+ """Read the structuring session of a capture."""
292
313
  return decode_model(
293
314
  self._request("GET", f"/v2/captures/{_safe_id(capture_id)}/structure/session"),
294
315
  StructuringSession,
295
316
  )
296
317
 
297
318
  def get_structuring_batch(self, capture_id: str, batch_index: int) -> StructuringBatch:
319
+ """Read one batch of a structuring session."""
298
320
  return decode_model(
299
321
  self._request(
300
322
  "GET",
@@ -315,6 +337,7 @@ class CaptureRuntimeClient:
315
337
  *,
316
338
  idempotency_key: UUID | str,
317
339
  ) -> StructuringSession:
340
+ """Submit a host's result for one structuring batch; requires an idempotency key."""
318
341
  try:
319
342
  payload = (
320
343
  submission
@@ -350,6 +373,7 @@ class CaptureRuntimeClient:
350
373
  *,
351
374
  idempotency_key: UUID | str,
352
375
  ) -> CaptureOperation:
376
+ """Commit the final structured document for a capture."""
353
377
  return self.commit_streaming_structure(
354
378
  capture_id,
355
379
  candidate,
@@ -364,6 +388,7 @@ class CaptureRuntimeClient:
364
388
  message: str,
365
389
  idempotency_key: UUID | str,
366
390
  ) -> CaptureOperation:
391
+ """Report that host-side structuring failed for a capture."""
367
392
  return self.report_streaming_failure(
368
393
  capture_id,
369
394
  code=code,
@@ -372,9 +397,11 @@ class CaptureRuntimeClient:
372
397
  )
373
398
 
374
399
  def delete_capture(self, capture_id: str) -> None:
400
+ """Delete a capture and its stored artifacts from the runtime."""
375
401
  self.delete_streaming_capture(capture_id)
376
402
 
377
403
  def get_streaming_capabilities(self) -> RuntimeStreamingCapabilities:
404
+ """Read streaming limits such as the maximum upload chunk size."""
378
405
  return decode_model(
379
406
  self._request("GET", "/v2/streaming/health/ready"), RuntimeStreamingCapabilities
380
407
  )
@@ -382,6 +409,10 @@ class CaptureRuntimeClient:
382
409
  def start_streaming_capture(
383
410
  self, upload: CaptureUpload, *, client_request_id: str
384
411
  ) -> CaptureOperation:
412
+ """Upload a file through a chunked ingestion and start its capture.
413
+
414
+ The ingestion is deleted if any step before the capture starts fails.
415
+ """
385
416
  content = upload.content
386
417
  digest = hashlib.sha256(content).hexdigest()
387
418
  kind = CaptureSourceKind(upload.source_kind)
@@ -456,11 +487,13 @@ class CaptureRuntimeClient:
456
487
  raise
457
488
 
458
489
  def get_streaming_capture(self, capture_id: str) -> CaptureOperation:
490
+ """Read a capture operation and check that it matches ``capture_id``."""
459
491
  return self._decode_capture_operation(
460
492
  self._request("GET", f"/v2/captures/{_safe_id(capture_id)}"), capture_id
461
493
  )
462
494
 
463
495
  def get_partial(self, capture_id: str) -> PartialCapture:
496
+ """Read the partial result a capture has produced so far."""
464
497
  partial = decode_model(
465
498
  self._request("GET", f"/v2/captures/{_safe_id(capture_id)}/partial"), PartialCapture
466
499
  )
@@ -471,6 +504,7 @@ class CaptureRuntimeClient:
471
504
  return partial
472
505
 
473
506
  def get_streaming_result(self, capture_id: str) -> CaptureStreamingResult:
507
+ """Read the terminal capture state, raw extraction, and structured document."""
474
508
  operation, raw, result = decode_streaming_result(
475
509
  self._request("GET", f"/v2/captures/{_safe_id(capture_id)}/result"),
476
510
  capture_id,
@@ -485,6 +519,11 @@ class CaptureRuntimeClient:
485
519
  max_reconnects: int = 2,
486
520
  on_activity: Callable[[], None] | None = None,
487
521
  ) -> Iterator[CaptureEvent]:
522
+ """Yield capture events from the SSE stream until a terminal event.
523
+
524
+ Reconnects up to ``max_reconnects`` times, resuming after the last seen
525
+ event; out-of-order or foreign events raise ``CaptureRuntimeProtocolError``.
526
+ """
488
527
  if max_reconnects < 0:
489
528
  raise ValueError("max_reconnects must be non-negative")
490
529
  self._ensure_discovered()
@@ -543,6 +582,7 @@ class CaptureRuntimeClient:
543
582
  reconnects += 1
544
583
 
545
584
  def cancel_streaming_capture(self, capture_id: str) -> CaptureOperation:
585
+ """Request cancellation of a capture operation."""
546
586
  return self._decode_capture_operation(
547
587
  self._request("POST", f"/v2/captures/{_safe_id(capture_id)}/cancel"), capture_id
548
588
  )
@@ -554,6 +594,7 @@ class CaptureRuntimeClient:
554
594
  *,
555
595
  idempotency_key: UUID | str,
556
596
  ) -> CaptureOperation:
597
+ """Commit the final structured document (JSON text, bytes, mapping, or model)."""
557
598
  headers = {
558
599
  "Content-Type": "application/json",
559
600
  "X-Idempotency-Key": str(idempotency_key),
@@ -579,6 +620,7 @@ class CaptureRuntimeClient:
579
620
  def report_streaming_failure(
580
621
  self, capture_id: str, *, code: str, message: str, idempotency_key: UUID | str
581
622
  ) -> CaptureOperation:
623
+ """Report that host-side structuring failed for a capture."""
582
624
  return self._decode_capture_operation(
583
625
  self._request(
584
626
  "POST",
@@ -590,9 +632,11 @@ class CaptureRuntimeClient:
590
632
  )
591
633
 
592
634
  def delete_streaming_capture(self, capture_id: str) -> None:
635
+ """Delete a capture and its stored artifacts from the runtime."""
593
636
  decode_response(self._request("DELETE", f"/v2/captures/{_safe_id(capture_id)}"))
594
637
 
595
638
  def close(self) -> None:
639
+ """Close the underlying transport."""
596
640
  close = getattr(self._transport, "close", None)
597
641
  if callable(close):
598
642
  close()
@@ -40,7 +40,7 @@ for _generated_name in (
40
40
 
41
41
  CAPTURE_API_VERSION = "2.0"
42
42
  CAPTURE_DOCUMENT_SCHEMA_VERSION = _generated.CAPTURE_DOCUMENT_SCHEMA_VERSION
43
- CAPTURE_RUNTIME_VERSION = "0.4.2"
43
+ CAPTURE_RUNTIME_VERSION = "0.4.4"
44
44
  CAPTURE_DOCUMENT_SCHEMA_ID = (
45
45
  "https://github.com/gx-capture/capture-workbench/schema/capture-document-v2.schema.json"
46
46
  )
@@ -10,10 +10,12 @@ _SECRET_FIELD = re.compile(r"(?:token|authorization|credential|secret|password)"
10
10
 
11
11
 
12
12
  def redact_text(value: str) -> str:
13
+ """Mask bearer tokens in ``value`` and cap it at 500 characters."""
13
14
  return _BEARER.sub("Bearer [redacted]", value)[:500]
14
15
 
15
16
 
16
17
  def redact_value(value: Any, *, depth: int = 0) -> Any:
18
+ """Recursively redact strings and secret-looking keys in a JSON-like value."""
17
19
  if depth > 4:
18
20
  return "[redacted]"
19
21
  if isinstance(value, str):
@@ -64,6 +66,8 @@ class CaptureRuntimeError(RuntimeError):
64
66
 
65
67
 
66
68
  class CaptureTransportError(CaptureRuntimeError):
69
+ """The runtime could not be reached or the connection failed; retryable."""
70
+
67
71
  category = "transport"
68
72
 
69
73
  def __init__(self, message: str, details: Any = None, *, code: str = "transport_error") -> None:
@@ -78,6 +82,8 @@ class CaptureTransportError(CaptureRuntimeError):
78
82
 
79
83
 
80
84
  class CaptureAuthenticationError(CaptureRuntimeError):
85
+ """The runtime rejected the bearer token."""
86
+
81
87
  category = "authentication"
82
88
 
83
89
  def __init__(
@@ -99,6 +105,8 @@ class CaptureAuthenticationError(CaptureRuntimeError):
99
105
 
100
106
 
101
107
  class CaptureCompatibilityError(CaptureRuntimeError):
108
+ """The runtime's API version or contract set is not supported by this client."""
109
+
102
110
  category = "compatibility"
103
111
 
104
112
  def __init__(self, message: str, details: Any = None) -> None:
@@ -112,6 +120,8 @@ class CaptureCompatibilityError(CaptureRuntimeError):
112
120
 
113
121
 
114
122
  class CaptureProtocolError(CaptureRuntimeError):
123
+ """The runtime returned a response that does not match the contract."""
124
+
115
125
  category = "protocol"
116
126
 
117
127
  def __init__(self, message: str, details: Any = None) -> None:
@@ -125,6 +135,8 @@ class CaptureProtocolError(CaptureRuntimeError):
125
135
 
126
136
 
127
137
  class CaptureRemoteError(CaptureRuntimeError):
138
+ """The runtime returned an error envelope; fields mirror that envelope."""
139
+
128
140
  category = "remote"
129
141
 
130
142
  def __init__(