capture-runtime-client 0.4.0__tar.gz → 0.4.1__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 (61) hide show
  1. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/PKG-INFO +1 -1
  2. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/pyproject.toml +2 -2
  3. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/client.py +144 -2
  4. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/contracts.py +41 -1
  5. capture_runtime_client-0.4.1/src/capture_runtime_client/private/assets/contract-set.json +1 -0
  6. capture_runtime_client-0.4.1/src/capture_runtime_client/private/assets/contract-set.sha256 +1 -0
  7. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/generated_models.py +145 -5
  8. capture_runtime_client-0.4.1/src/capture_runtime_client/private/schemas/capture-streaming-result.schema.json +607 -0
  9. capture_runtime_client-0.4.1/src/capture_runtime_client/private/schemas/open-structuring-session-v2.schema.json +118 -0
  10. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/runtime-ready.schema.json +2 -2
  11. capture_runtime_client-0.4.1/src/capture_runtime_client/private/schemas/structuring-batch-v2.schema.json +96 -0
  12. capture_runtime_client-0.4.1/src/capture_runtime_client/private/schemas/structuring-provider-capability-v2.schema.json +68 -0
  13. capture_runtime_client-0.4.1/src/capture_runtime_client/private/schemas/structuring-semantic-block-v2.schema.json +43 -0
  14. capture_runtime_client-0.4.1/src/capture_runtime_client/private/schemas/structuring-session-v2.schema.json +188 -0
  15. capture_runtime_client-0.4.1/src/capture_runtime_client/private/schemas/submit-structuring-batch-v2.schema.json +76 -0
  16. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/tests/test_client_sdk.py +191 -5
  17. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/uv.lock +1 -1
  18. capture_runtime_client-0.4.0/src/capture_runtime_client/private/assets/contract-set.json +0 -1
  19. capture_runtime_client-0.4.0/src/capture_runtime_client/private/assets/contract-set.sha256 +0 -1
  20. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/.gitignore +0 -0
  21. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/README.md +0 -0
  22. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/project.json +0 -0
  23. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/__init__.py +0 -0
  24. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/codec.py +0 -0
  25. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/errors.py +0 -0
  26. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/__init__.py +0 -0
  27. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/assets/__init__.py +0 -0
  28. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/__init__.py +0 -0
  29. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/capture-block.schema.json +0 -0
  30. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/capture-document.schema.json +0 -0
  31. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/capture-engine.schema.json +0 -0
  32. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/capture-event-v2.schema.json +0 -0
  33. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/capture-failure-v2.schema.json +0 -0
  34. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/capture-operation-v2.schema.json +0 -0
  35. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/capture-source.schema.json +0 -0
  36. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/error-body-v2.schema.json +0 -0
  37. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/error-envelope-v2.schema.json +0 -0
  38. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/finalize-ingestion-v2.schema.json +0 -0
  39. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/ingestion-v2.schema.json +0 -0
  40. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/open-ingestion-v2.schema.json +0 -0
  41. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/page-locator.schema.json +0 -0
  42. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/partial-capture-v2.schema.json +0 -0
  43. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/raw-capture-segment.schema.json +0 -0
  44. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/raw-capture.schema.json +0 -0
  45. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/report-structuring-failure-v2.schema.json +0 -0
  46. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/runtime-artifact-descriptor-v2.schema.json +0 -0
  47. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/runtime-installation-v2.schema.json +0 -0
  48. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/runtime-installations-v2.schema.json +0 -0
  49. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/runtime-model-installation-v2.schema.json +0 -0
  50. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/runtime-model-installations-v2.schema.json +0 -0
  51. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/runtime-model-option-v2.schema.json +0 -0
  52. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/runtime-model-options-v2.schema.json +0 -0
  53. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/runtime-requirement-v2.schema.json +0 -0
  54. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/runtime-requirements-v2.schema.json +0 -0
  55. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/runtime-streaming-capabilities-v2.schema.json +0 -0
  56. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/start-capture-v2.schema.json +0 -0
  57. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/start-runtime-installation-v2.schema.json +0 -0
  58. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/start-runtime-model-installation-v2.schema.json +0 -0
  59. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/private/schemas/time-locator.schema.json +0 -0
  60. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/py.typed +0 -0
  61. {capture_runtime_client-0.4.0 → capture_runtime_client-0.4.1}/src/capture_runtime_client/transport.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: capture-runtime-client
3
- Version: 0.4.0
3
+ Version: 0.4.1
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.0"
7
+ version = "0.4.1"
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 = "5b93bcb557acca034386b6e9e47502efec91210331ecebabd9c470196d35fec3"
18
+ contract_set_sha256 = "b28366f022533192c063056bbf64cacfd09390815c65408066369dd61094e278"
19
19
 
20
20
  [tool.hatch.build.targets.wheel]
21
21
  packages = ["src/capture_runtime_client"]
@@ -27,6 +27,7 @@ from .contracts import (
27
27
  CaptureOperation,
28
28
  CaptureSourceKind,
29
29
  Ingestion,
30
+ OpenStructuringSession,
30
31
  PartialCapture,
31
32
  RawCapture,
32
33
  RuntimeInstallation,
@@ -35,7 +36,10 @@ from .contracts import (
35
36
  RuntimeReady,
36
37
  RuntimeRequirements,
37
38
  RuntimeStreamingCapabilities,
39
+ StructuringBatch,
38
40
  StructuringMode,
41
+ StructuringSession,
42
+ SubmitStructuringBatch,
39
43
  )
40
44
  from .errors import (
41
45
  CaptureRuntimeCompatibilityError,
@@ -282,6 +286,107 @@ class CaptureRuntimeClient:
282
286
  def get_result(self, capture_id: str) -> CaptureStreamingResult:
283
287
  return self.get_streaming_result(capture_id)
284
288
 
289
+ def open_structuring_session(
290
+ self,
291
+ capture_id: str,
292
+ request: OpenStructuringSession | Mapping[str, Any],
293
+ *,
294
+ idempotency_key: UUID | str | None = None,
295
+ ) -> StructuringSession:
296
+ """Open a pull-based structuring session with a matching idempotency key."""
297
+ try:
298
+ payload = (
299
+ request
300
+ if isinstance(request, OpenStructuringSession)
301
+ else OpenStructuringSession.model_validate(request)
302
+ )
303
+ except ValidationError as error:
304
+ raise CaptureRuntimeProtocolError(
305
+ "Structuring session request is invalid.", error.errors(include_url=False)
306
+ ) from error
307
+ if payload.capture_id != capture_id:
308
+ raise CaptureRuntimeProtocolError(
309
+ "Structuring session captureId must match the route capture."
310
+ )
311
+ key = (
312
+ payload.client_request_id
313
+ if idempotency_key is None
314
+ else str(idempotency_key)
315
+ )
316
+ if not key or key != payload.client_request_id:
317
+ raise CaptureRuntimeProtocolError(
318
+ "X-Idempotency-Key must match structuring session clientRequestId."
319
+ )
320
+ return decode_model(
321
+ self._request(
322
+ "POST",
323
+ f"/v2/captures/{_safe_id(capture_id)}/structure/session",
324
+ headers={
325
+ "Content-Type": "application/json",
326
+ "X-Idempotency-Key": key,
327
+ },
328
+ json=payload.model_dump(mode="json", by_alias=True),
329
+ ),
330
+ StructuringSession,
331
+ )
332
+
333
+ def get_structuring_session(self, capture_id: str) -> StructuringSession:
334
+ return decode_model(
335
+ self._request(
336
+ "GET", f"/v2/captures/{_safe_id(capture_id)}/structure/session"
337
+ ),
338
+ StructuringSession,
339
+ )
340
+
341
+ def get_structuring_batch(self, capture_id: str, batch_index: int) -> StructuringBatch:
342
+ return decode_model(
343
+ self._request(
344
+ "GET",
345
+ f"/v2/captures/{_safe_id(capture_id)}/structure/session/batches/{_safe_batch_index(batch_index)}",
346
+ ),
347
+ StructuringBatch,
348
+ )
349
+
350
+ def pull_structuring_batch(self, capture_id: str, batch_index: int) -> StructuringBatch:
351
+ """Alias that makes the pull nature explicit for host coordinators."""
352
+ return self.get_structuring_batch(capture_id, batch_index)
353
+
354
+ def submit_structuring_batch(
355
+ self,
356
+ capture_id: str,
357
+ batch_index: int,
358
+ submission: SubmitStructuringBatch | Mapping[str, Any],
359
+ *,
360
+ idempotency_key: UUID | str,
361
+ ) -> StructuringSession:
362
+ try:
363
+ payload = (
364
+ submission
365
+ if isinstance(submission, SubmitStructuringBatch)
366
+ else SubmitStructuringBatch.model_validate(submission)
367
+ )
368
+ except ValidationError as error:
369
+ raise CaptureRuntimeProtocolError(
370
+ "Structuring batch submission is invalid.", error.errors(include_url=False)
371
+ ) from error
372
+ key = str(idempotency_key)
373
+ if not key:
374
+ raise CaptureRuntimeProtocolError(
375
+ "Structuring batch submissions require X-Idempotency-Key."
376
+ )
377
+ return decode_model(
378
+ self._request(
379
+ "PUT",
380
+ f"/v2/captures/{_safe_id(capture_id)}/structure/session/batches/{_safe_batch_index(batch_index)}",
381
+ headers={
382
+ "Content-Type": "application/json",
383
+ "X-Idempotency-Key": key,
384
+ },
385
+ json=payload.model_dump(mode="json", by_alias=True),
386
+ ),
387
+ StructuringSession,
388
+ )
389
+
285
390
  def commit_structure(
286
391
  self,
287
392
  capture_id: str,
@@ -743,18 +848,22 @@ class CaptureRuntimeClient:
743
848
  "/v2/captures/{capture_id}/events",
744
849
  "/v2/captures/{capture_id}/raw",
745
850
  "/v2/captures/{capture_id}/result",
851
+ "/v2/captures/{capture_id}/structure/session",
852
+ "/v2/captures/{capture_id}/structure/session/batches/{batch_index}",
746
853
  }
747
854
  if not required_paths.issubset(operation_paths):
748
855
  raise CaptureRuntimeCompatibilityError(
749
856
  "Capture Runtime contract bundle does not advertise the required client surface."
750
857
  )
751
858
 
752
- def find_operation(path: str) -> Mapping[str, Any] | None:
859
+ def find_operation(path: str, method: str | None = None) -> Mapping[str, Any] | None:
753
860
  return next(
754
861
  (
755
862
  item
756
863
  for item in operations
757
- if isinstance(item, Mapping) and item.get("path") == path
864
+ if isinstance(item, Mapping)
865
+ and item.get("path") == path
866
+ and (method is None or item.get("method") == method)
758
867
  ),
759
868
  None,
760
869
  )
@@ -762,6 +871,15 @@ class CaptureRuntimeClient:
762
871
  upload = find_operation("/v2/captures")
763
872
  chunk = find_operation("/v2/ingestions/{ingestion_id}/chunks/{chunk_index}")
764
873
  events = find_operation("/v2/captures/{capture_id}/events")
874
+ session_open = find_operation(
875
+ "/v2/captures/{capture_id}/structure/session", "POST"
876
+ )
877
+ batch_get = find_operation(
878
+ "/v2/captures/{capture_id}/structure/session/batches/{batch_index}", "GET"
879
+ )
880
+ batch_submit = find_operation(
881
+ "/v2/captures/{capture_id}/structure/session/batches/{batch_index}", "PUT"
882
+ )
765
883
  if (
766
884
  upload is None
767
885
  or not isinstance(upload.get("body"), Mapping)
@@ -792,6 +910,24 @@ class CaptureRuntimeClient:
792
910
  or streaming.get("lastEventIdHeader") != "Last-Event-ID"
793
911
  ):
794
912
  raise CaptureRuntimeCompatibilityError("Capture Runtime SSE metadata is incompatible.")
913
+ if (
914
+ session_open is None
915
+ or not isinstance(session_open.get("body"), Mapping)
916
+ or session_open["body"].get("kind") != "json"
917
+ or "X-Idempotency-Key" not in session_open.get("requiredHeaders", [])
918
+ or session_open.get("idempotency", {}).get("mode") != "required"
919
+ or batch_get is None
920
+ or not isinstance(batch_get.get("body"), Mapping)
921
+ or batch_get["body"].get("kind") != "none"
922
+ or batch_submit is None
923
+ or not isinstance(batch_submit.get("body"), Mapping)
924
+ or batch_submit["body"].get("kind") != "json"
925
+ or "X-Idempotency-Key" not in batch_submit.get("requiredHeaders", [])
926
+ or batch_submit.get("idempotency", {}).get("mode") != "required"
927
+ ):
928
+ raise CaptureRuntimeCompatibilityError(
929
+ "Capture Runtime pull-session metadata is incompatible."
930
+ )
795
931
  canonical_bundle = json.dumps(
796
932
  bundle,
797
933
  ensure_ascii=False,
@@ -839,6 +975,12 @@ def _safe_id(value: str) -> str:
839
975
  return value
840
976
 
841
977
 
978
+ def _safe_batch_index(value: int) -> int:
979
+ if not isinstance(value, int) or isinstance(value, bool) or value < 0:
980
+ raise ValueError("Capture Runtime batch index is invalid")
981
+ return value
982
+
983
+
842
984
  def _retry_after_seconds(response: httpx.Response) -> float | None:
843
985
  value = response.headers.get("retry-after")
844
986
  if value is None:
@@ -24,6 +24,12 @@ for _generated_name in (
24
24
  "CaptureOperationV2",
25
25
  "PartialCaptureV2",
26
26
  "CaptureEventV2",
27
+ "StructuringProviderCapabilityV2",
28
+ "OpenStructuringSessionV2",
29
+ "StructuringSessionV2",
30
+ "StructuringBatchV2",
31
+ "StructuringSemanticBlockV2",
32
+ "SubmitStructuringBatchV2",
27
33
  ):
28
34
  getattr(_generated, _generated_name).model_rebuild(
29
35
  force=True,
@@ -32,7 +38,7 @@ for _generated_name in (
32
38
 
33
39
  CAPTURE_API_VERSION = "2.0"
34
40
  CAPTURE_DOCUMENT_SCHEMA_VERSION = _generated.CAPTURE_DOCUMENT_SCHEMA_VERSION
35
- CAPTURE_RUNTIME_VERSION = "0.4.0"
41
+ CAPTURE_RUNTIME_VERSION = "0.4.1"
36
42
  CAPTURE_DOCUMENT_SCHEMA_ID = (
37
43
  "https://github.com/gx-capture/capture-workbench/schema/capture-document-v2.schema.json"
38
44
  )
@@ -143,6 +149,30 @@ class CaptureEvent(_generated.CaptureEventV2):
143
149
  pass
144
150
 
145
151
 
152
+ class StructuringProviderCapability(_generated.StructuringProviderCapabilityV2):
153
+ pass
154
+
155
+
156
+ class OpenStructuringSession(_generated.OpenStructuringSessionV2):
157
+ pass
158
+
159
+
160
+ class StructuringSession(_generated.StructuringSessionV2):
161
+ pass
162
+
163
+
164
+ class StructuringBatch(_generated.StructuringBatchV2):
165
+ pass
166
+
167
+
168
+ class StructuringSemanticBlock(_generated.StructuringSemanticBlockV2):
169
+ pass
170
+
171
+
172
+ class SubmitStructuringBatch(_generated.SubmitStructuringBatchV2):
173
+ pass
174
+
175
+
146
176
  class RuntimeStreamingCapabilities(_generated.RuntimeStreamingCapabilitiesV2):
147
177
  pass
148
178
 
@@ -180,6 +210,8 @@ TimeLocator = _generated.TimeLocator
180
210
 
181
211
  CaptureSourceKind = _generated.CaptureSourceKind
182
212
  StructuringMode = _generated.StructuringMode
213
+ StructuringSessionStatus = _generated.StructuringSessionStatus
214
+ StructuringBatchStatus = _generated.StructuringBatchStatus
183
215
  RuntimeInstallationStatus = _generated.RuntimeInstallationStatus
184
216
  RuntimeModelOptionStatus = _generated.RuntimeModelOptionStatus
185
217
  RuntimeRequirementStatus = _generated.RuntimeRequirementStatus
@@ -253,6 +285,12 @@ __all__ = [
253
285
  "CaptureOperation",
254
286
  "PartialCapture",
255
287
  "CaptureEvent",
288
+ "StructuringProviderCapability",
289
+ "OpenStructuringSession",
290
+ "StructuringSession",
291
+ "StructuringBatch",
292
+ "StructuringSemanticBlock",
293
+ "SubmitStructuringBatch",
256
294
  "RuntimeStreamingCapabilities",
257
295
  "RuntimeReady",
258
296
  "ReportStructuringFailure",
@@ -260,6 +298,8 @@ __all__ = [
260
298
  "ErrorEnvelope",
261
299
  "CaptureSourceKind",
262
300
  "StructuringMode",
301
+ "StructuringSessionStatus",
302
+ "StructuringBatchStatus",
263
303
  "RuntimeInstallationStatus",
264
304
  "RuntimeModelOptionStatus",
265
305
  "RuntimeRequirementStatus",