agentic-platform-sdk 0.1.0__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.
Files changed (41) hide show
  1. agentic_platform_sdk/__init__.py +9 -0
  2. agentic_platform_sdk/_a2a.py +133 -0
  3. agentic_platform_sdk/_client.py +152 -0
  4. agentic_platform_sdk/_contract.py +72 -0
  5. agentic_platform_sdk/_generated/__init__.py +0 -0
  6. agentic_platform_sdk/_generated/_base.py +20 -0
  7. agentic_platform_sdk/_generated/models.py +698 -0
  8. agentic_platform_sdk/_paging.py +117 -0
  9. agentic_platform_sdk/_spec/call_areas.json +13 -0
  10. agentic_platform_sdk/_spec/chat-events.schema.json +371 -0
  11. agentic_platform_sdk/_spec/errors.json +2365 -0
  12. agentic_platform_sdk/_spec/operations.json +230 -0
  13. agentic_platform_sdk/_transport.py +630 -0
  14. agentic_platform_sdk/_util.py +133 -0
  15. agentic_platform_sdk/agents.py +793 -0
  16. agentic_platform_sdk/approvals.py +66 -0
  17. agentic_platform_sdk/auth.py +336 -0
  18. agentic_platform_sdk/chat.py +599 -0
  19. agentic_platform_sdk/datasets.py +69 -0
  20. agentic_platform_sdk/errors.py +204 -0
  21. agentic_platform_sdk/kb.py +288 -0
  22. agentic_platform_sdk/llm.py +40 -0
  23. agentic_platform_sdk/me.py +28 -0
  24. agentic_platform_sdk/models.py +91 -0
  25. agentic_platform_sdk/ontology.py +209 -0
  26. agentic_platform_sdk/py.typed +0 -0
  27. agentic_platform_sdk/testing/__init__.py +19 -0
  28. agentic_platform_sdk/testing/conformance.py +803 -0
  29. agentic_platform_sdk/testing/fake.py +902 -0
  30. agentic_platform_sdk/testing/standin.py +165 -0
  31. agentic_platform_sdk/toolchains.py +137 -0
  32. agentic_platform_sdk/tools/__init__.py +70 -0
  33. agentic_platform_sdk/tools/_jcs.py +218 -0
  34. agentic_platform_sdk/tools/asgi.py +228 -0
  35. agentic_platform_sdk/tools/mcp.py +751 -0
  36. agentic_platform_sdk/tools/verify.py +379 -0
  37. agentic_platform_sdk/vision.py +300 -0
  38. agentic_platform_sdk-0.1.0.dist-info/METADATA +226 -0
  39. agentic_platform_sdk-0.1.0.dist-info/RECORD +41 -0
  40. agentic_platform_sdk-0.1.0.dist-info/WHEEL +4 -0
  41. agentic_platform_sdk-0.1.0.dist-info/licenses/LICENSE +202 -0
@@ -0,0 +1,117 @@
1
+ """Iterators over the platform's two paging styles: offset/limit and a cursor (``before``, or
2
+ A2A's ``pageToken``), and the explicit one-page calls beside them.
3
+
4
+ The iterators are lazy: a page is fetched only when the one before it is used up. A fetch error
5
+ propagates, so a caller sees the platform error and not a silently short list.
6
+
7
+ A page call (``list_page``, ``documents_page``, ``versions_page``, ``tasks_page``) makes one
8
+ request and returns a ``Page``: its items and where the next page starts. For an offset list,
9
+ ``next`` is the next offset, or None once a page comes back shorter than its limit (a full last
10
+ page gives one more, empty, page, as the iterator also asks for it). For a cursor list, ``next``
11
+ is the cursor the platform sent, or None at the end.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ from collections.abc import AsyncIterator, Awaitable, Callable, Iterator
17
+ from dataclasses import dataclass
18
+ from typing import Generic, TypeVar
19
+
20
+ T = TypeVar("T")
21
+
22
+
23
+ @dataclass(frozen=True)
24
+ class Page(Generic[T]): # noqa: UP046 - PEP 695 syntax needs Python 3.12; the floor is 3.11
25
+ """One page of results and where the next one starts (an offset, a cursor, or None)."""
26
+
27
+ items: list[T]
28
+ next: int | str | None = None
29
+
30
+
31
+ def check_limit(limit: int) -> None:
32
+ if limit < 1:
33
+ raise ValueError("limit must be at least 1")
34
+
35
+
36
+ def _check_offset(offset: int) -> None:
37
+ if offset < 0:
38
+ raise ValueError("offset must not be negative")
39
+
40
+
41
+ def _offset_next(items: list[T], offset: int, limit: int) -> Page[T]:
42
+ return Page(items=items, next=offset + limit if len(items) >= limit else None)
43
+
44
+
45
+ def offset_page(fetch: Callable[[int, int], list[T]], offset: int, limit: int) -> Page[T]:
46
+ """One ``fetch(offset, limit)`` as a ``Page``: the next offset, or None after a short page."""
47
+ check_limit(limit)
48
+ _check_offset(offset)
49
+ return _offset_next(fetch(offset, limit), offset, limit)
50
+
51
+
52
+ async def aoffset_page(
53
+ fetch: Callable[[int, int], Awaitable[list[T]]], offset: int, limit: int
54
+ ) -> Page[T]:
55
+ """Async twin of ``offset_page``."""
56
+ check_limit(limit)
57
+ _check_offset(offset)
58
+ return _offset_next(await fetch(offset, limit), offset, limit)
59
+
60
+
61
+ def _check_advanced(cursor: str | None, following: str) -> None:
62
+ if following == cursor:
63
+ raise ValueError("the next cursor equals the one just used; refusing to loop")
64
+
65
+
66
+ def iter_offset(fetch: Callable[[int, int], list[T]], limit: int) -> Iterator[T]:
67
+ """Yield every item, fetching ``fetch(offset, limit)`` until a page is shorter than `limit`."""
68
+ check_limit(limit)
69
+ offset = 0
70
+ while True:
71
+ items = fetch(offset, limit)
72
+ yield from items
73
+ if len(items) < limit:
74
+ return
75
+ offset += limit
76
+
77
+
78
+ def iter_cursor(fetch: Callable[[str | None], tuple[list[T], str | None]]) -> Iterator[T]:
79
+ """Yield every item, following the cursor ``fetch`` returns until it is None."""
80
+ cursor: str | None = None
81
+ while True:
82
+ items, following = fetch(cursor)
83
+ yield from items
84
+ if following is None:
85
+ return
86
+ _check_advanced(cursor, following)
87
+ cursor = following
88
+
89
+
90
+ async def aiter_offset(
91
+ fetch: Callable[[int, int], Awaitable[list[T]]], limit: int
92
+ ) -> AsyncIterator[T]:
93
+ """Async twin of ``iter_offset``."""
94
+ check_limit(limit)
95
+ offset = 0
96
+ while True:
97
+ items = await fetch(offset, limit)
98
+ for item in items:
99
+ yield item
100
+ if len(items) < limit:
101
+ return
102
+ offset += limit
103
+
104
+
105
+ async def aiter_cursor(
106
+ fetch: Callable[[str | None], Awaitable[tuple[list[T], str | None]]],
107
+ ) -> AsyncIterator[T]:
108
+ """Async twin of ``iter_cursor``."""
109
+ cursor: str | None = None
110
+ while True:
111
+ items, following = await fetch(cursor)
112
+ for item in items:
113
+ yield item
114
+ if following is None:
115
+ return
116
+ _check_advanced(cursor, following)
117
+ cursor = following
@@ -0,0 +1,13 @@
1
+ {
2
+ "agents": "a2a",
3
+ "approvals": "approval",
4
+ "datasets": "dataset",
5
+ "kb": "knowledge_base",
6
+ "llm": "llm",
7
+ "me": "gateway",
8
+ "meta": "gateway",
9
+ "models": "model",
10
+ "ontology": "ontology",
11
+ "toolchains": "toolchain_task",
12
+ "vision": "training"
13
+ }
@@ -0,0 +1,371 @@
1
+ {
2
+ "$defs": {
3
+ "Approval": {
4
+ "additionalProperties": false,
5
+ "properties": {
6
+ "call_id": {
7
+ "title": "Call Id",
8
+ "type": "string"
9
+ },
10
+ "decidable_by_caller": {
11
+ "title": "Decidable By Caller",
12
+ "type": "boolean"
13
+ },
14
+ "expires_at": {
15
+ "format": "date-time",
16
+ "title": "Expires At",
17
+ "type": "string"
18
+ },
19
+ "request_id": {
20
+ "title": "Request Id",
21
+ "type": "string"
22
+ },
23
+ "state": {
24
+ "enum": [
25
+ "pending",
26
+ "approved",
27
+ "rejected",
28
+ "expired"
29
+ ],
30
+ "title": "State",
31
+ "type": "string"
32
+ },
33
+ "tool": {
34
+ "title": "Tool",
35
+ "type": "string"
36
+ },
37
+ "type": {
38
+ "const": "approval",
39
+ "title": "Type",
40
+ "type": "string"
41
+ }
42
+ },
43
+ "required": [
44
+ "type",
45
+ "request_id",
46
+ "tool",
47
+ "call_id",
48
+ "state",
49
+ "decidable_by_caller",
50
+ "expires_at"
51
+ ],
52
+ "title": "Approval",
53
+ "type": "object"
54
+ },
55
+ "Plan": {
56
+ "additionalProperties": false,
57
+ "properties": {
58
+ "steps": {
59
+ "items": {
60
+ "$ref": "#/$defs/PlanStep"
61
+ },
62
+ "title": "Steps",
63
+ "type": "array"
64
+ },
65
+ "type": {
66
+ "const": "plan",
67
+ "title": "Type",
68
+ "type": "string"
69
+ }
70
+ },
71
+ "required": [
72
+ "type",
73
+ "steps"
74
+ ],
75
+ "title": "Plan",
76
+ "type": "object"
77
+ },
78
+ "PlanState": {
79
+ "description": "A plan step's progress.",
80
+ "enum": [
81
+ "pending",
82
+ "running",
83
+ "done",
84
+ "failed"
85
+ ],
86
+ "title": "PlanState",
87
+ "type": "string"
88
+ },
89
+ "PlanStep": {
90
+ "additionalProperties": false,
91
+ "properties": {
92
+ "id": {
93
+ "title": "Id",
94
+ "type": "string"
95
+ },
96
+ "state": {
97
+ "$ref": "#/$defs/PlanState"
98
+ },
99
+ "title": {
100
+ "title": "Title",
101
+ "type": "string"
102
+ }
103
+ },
104
+ "required": [
105
+ "id",
106
+ "title",
107
+ "state"
108
+ ],
109
+ "title": "PlanStep",
110
+ "type": "object"
111
+ },
112
+ "Ref": {
113
+ "additionalProperties": false,
114
+ "description": "A typed reference an app tool returns (spec 4.7): the app UI fetches the real object through its own API.",
115
+ "properties": {
116
+ "id": {
117
+ "maxLength": 256,
118
+ "title": "Id",
119
+ "type": "string"
120
+ },
121
+ "kind": {
122
+ "maxLength": 64,
123
+ "title": "Kind",
124
+ "type": "string"
125
+ }
126
+ },
127
+ "required": [
128
+ "kind",
129
+ "id"
130
+ ],
131
+ "title": "Ref",
132
+ "type": "object"
133
+ },
134
+ "Source": {
135
+ "additionalProperties": false,
136
+ "properties": {
137
+ "document_id": {
138
+ "title": "Document Id",
139
+ "type": "string"
140
+ },
141
+ "kb_id": {
142
+ "title": "Kb Id",
143
+ "type": "string"
144
+ },
145
+ "score": {
146
+ "title": "Score",
147
+ "type": "number"
148
+ },
149
+ "snippet": {
150
+ "title": "Snippet",
151
+ "type": "string"
152
+ },
153
+ "title": {
154
+ "title": "Title",
155
+ "type": "string"
156
+ }
157
+ },
158
+ "required": [
159
+ "kb_id",
160
+ "document_id",
161
+ "title",
162
+ "snippet",
163
+ "score"
164
+ ],
165
+ "title": "Source",
166
+ "type": "object"
167
+ },
168
+ "Sources": {
169
+ "additionalProperties": false,
170
+ "properties": {
171
+ "items": {
172
+ "items": {
173
+ "$ref": "#/$defs/Source"
174
+ },
175
+ "title": "Items",
176
+ "type": "array"
177
+ },
178
+ "type": {
179
+ "const": "sources",
180
+ "title": "Type",
181
+ "type": "string"
182
+ }
183
+ },
184
+ "required": [
185
+ "type",
186
+ "items"
187
+ ],
188
+ "title": "Sources",
189
+ "type": "object"
190
+ },
191
+ "SubAgent": {
192
+ "additionalProperties": false,
193
+ "properties": {
194
+ "id": {
195
+ "title": "Id",
196
+ "type": "string"
197
+ },
198
+ "name": {
199
+ "title": "Name",
200
+ "type": "string"
201
+ },
202
+ "state": {
203
+ "$ref": "#/$defs/SubAgentState"
204
+ },
205
+ "summary": {
206
+ "anyOf": [
207
+ {
208
+ "type": "string"
209
+ },
210
+ {
211
+ "type": "null"
212
+ }
213
+ ],
214
+ "default": null,
215
+ "title": "Summary"
216
+ },
217
+ "type": {
218
+ "const": "subagent",
219
+ "title": "Type",
220
+ "type": "string"
221
+ }
222
+ },
223
+ "required": [
224
+ "type",
225
+ "id",
226
+ "name",
227
+ "state"
228
+ ],
229
+ "title": "SubAgent",
230
+ "type": "object"
231
+ },
232
+ "SubAgentState": {
233
+ "description": "A sub-agent's progress.",
234
+ "enum": [
235
+ "running",
236
+ "done",
237
+ "failed"
238
+ ],
239
+ "title": "SubAgentState",
240
+ "type": "string"
241
+ },
242
+ "ToolCall": {
243
+ "additionalProperties": false,
244
+ "properties": {
245
+ "arguments": {
246
+ "additionalProperties": true,
247
+ "title": "Arguments",
248
+ "type": "object"
249
+ },
250
+ "call_id": {
251
+ "title": "Call Id",
252
+ "type": "string"
253
+ },
254
+ "origin": {
255
+ "enum": [
256
+ "platform",
257
+ "app"
258
+ ],
259
+ "title": "Origin",
260
+ "type": "string"
261
+ },
262
+ "tool": {
263
+ "title": "Tool",
264
+ "type": "string"
265
+ },
266
+ "type": {
267
+ "const": "tool_call",
268
+ "title": "Type",
269
+ "type": "string"
270
+ }
271
+ },
272
+ "required": [
273
+ "type",
274
+ "call_id",
275
+ "tool",
276
+ "arguments",
277
+ "origin"
278
+ ],
279
+ "title": "ToolCall",
280
+ "type": "object"
281
+ },
282
+ "ToolResult": {
283
+ "additionalProperties": false,
284
+ "properties": {
285
+ "call_id": {
286
+ "title": "Call Id",
287
+ "type": "string"
288
+ },
289
+ "error_code": {
290
+ "anyOf": [
291
+ {
292
+ "type": "string"
293
+ },
294
+ {
295
+ "type": "null"
296
+ }
297
+ ],
298
+ "default": null,
299
+ "title": "Error Code"
300
+ },
301
+ "ok": {
302
+ "title": "Ok",
303
+ "type": "boolean"
304
+ },
305
+ "ref": {
306
+ "anyOf": [
307
+ {
308
+ "$ref": "#/$defs/Ref"
309
+ },
310
+ {
311
+ "type": "null"
312
+ }
313
+ ],
314
+ "default": null
315
+ },
316
+ "summary": {
317
+ "title": "Summary",
318
+ "type": "string"
319
+ },
320
+ "type": {
321
+ "const": "tool_result",
322
+ "title": "Type",
323
+ "type": "string"
324
+ }
325
+ },
326
+ "required": [
327
+ "type",
328
+ "call_id",
329
+ "ok",
330
+ "summary"
331
+ ],
332
+ "title": "ToolResult",
333
+ "type": "object"
334
+ }
335
+ },
336
+ "$id": "urn:agentic:a2a:ext:chat-events:v1",
337
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
338
+ "description": "Payloads of the A2A chat-events extension urn:agentic:a2a:ext:chat-events:v1. Carriers: a status event is statusUpdate.metadata['agentic.chat'] on a TASK_STATE_WORKING status update; every frame the extension logs carries metadata['agentic.seq'] (integer >= 1, no gaps) on its statusUpdate or artifactUpdate; streamed text is an artifactUpdate of the artifact 'answer' ('thinking' for reasoning). A stream resumes with SubscribeToTask params.metadata['agentic.after_seq'] (integer >= 0). A client ignores a 'type' it does not know.",
339
+ "discriminator": {
340
+ "mapping": {
341
+ "approval": "#/$defs/Approval",
342
+ "plan": "#/$defs/Plan",
343
+ "sources": "#/$defs/Sources",
344
+ "subagent": "#/$defs/SubAgent",
345
+ "tool_call": "#/$defs/ToolCall",
346
+ "tool_result": "#/$defs/ToolResult"
347
+ },
348
+ "propertyName": "type"
349
+ },
350
+ "oneOf": [
351
+ {
352
+ "$ref": "#/$defs/ToolCall"
353
+ },
354
+ {
355
+ "$ref": "#/$defs/ToolResult"
356
+ },
357
+ {
358
+ "$ref": "#/$defs/Approval"
359
+ },
360
+ {
361
+ "$ref": "#/$defs/Sources"
362
+ },
363
+ {
364
+ "$ref": "#/$defs/Plan"
365
+ },
366
+ {
367
+ "$ref": "#/$defs/SubAgent"
368
+ }
369
+ ],
370
+ "title": "ChatEvent"
371
+ }