agentos-sdk-python 0.1.0__tar.gz → 1.0.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.
- {agentos_sdk_python-0.1.0 → agentos_sdk_python-1.0.0}/.gitignore +3 -0
- agentos_sdk_python-1.0.0/CHANGELOG.md +35 -0
- agentos_sdk_python-1.0.0/PKG-INFO +441 -0
- agentos_sdk_python-1.0.0/README-zh_CN.md +403 -0
- agentos_sdk_python-1.0.0/README.md +407 -0
- {agentos_sdk_python-0.1.0 → agentos_sdk_python-1.0.0}/RELEASE.md +2 -2
- agentos_sdk_python-1.0.0/agentos_sdk/__init__.py +67 -0
- {agentos_sdk_python-0.1.0 → agentos_sdk_python-1.0.0}/agentos_sdk/clients/__init__.py +6 -0
- {agentos_sdk_python-0.1.0 → agentos_sdk_python-1.0.0}/agentos_sdk/clients/agentkit.py +67 -40
- {agentos_sdk_python-0.1.0 → agentos_sdk_python-1.0.0}/agentos_sdk/clients/appkit.py +2 -1
- agentos_sdk_python-1.0.0/agentos_sdk/clients/authkit.py +60 -0
- agentos_sdk_python-1.0.0/agentos_sdk/clients/discoverykit.py +60 -0
- agentos_sdk_python-1.0.0/agentos_sdk/clients/toolkit.py +182 -0
- agentos_sdk_python-1.0.0/agentos_sdk/clients/transferkit.py +149 -0
- {agentos_sdk_python-0.1.0 → agentos_sdk_python-1.0.0}/agentos_sdk/handlers.py +38 -3
- {agentos_sdk_python-0.1.0 → agentos_sdk_python-1.0.0}/agentos_sdk/normalizers.py +1 -5
- agentos_sdk_python-1.0.0/agentos_sdk/protocol.py +239 -0
- agentos_sdk_python-1.0.0/agentos_sdk/sdk.py +921 -0
- {agentos_sdk_python-0.1.0 → agentos_sdk_python-1.0.0}/agentos_sdk/transport.py +35 -14
- {agentos_sdk_python-0.1.0 → agentos_sdk_python-1.0.0}/pyproject.toml +17 -2
- agentos_sdk_python-1.0.0/tests/test_agentkit.py +595 -0
- {agentos_sdk_python-0.1.0 → agentos_sdk_python-1.0.0}/tests/test_normalizers.py +46 -0
- agentos_sdk_python-1.0.0/tests/test_protocol.py +71 -0
- agentos_sdk_python-1.0.0/tests/test_sdk_facade.py +533 -0
- agentos_sdk_python-1.0.0/tests/test_toolkit.py +329 -0
- {agentos_sdk_python-0.1.0 → agentos_sdk_python-1.0.0}/tests/test_transport.py +40 -1
- agentos_sdk_python-1.0.0/tests/typecheck/toolkit_usage.py +28 -0
- agentos_sdk_python-0.1.0/CHANGELOG.md +0 -7
- agentos_sdk_python-0.1.0/PKG-INFO +0 -234
- agentos_sdk_python-0.1.0/README-zh_CN.md +0 -202
- agentos_sdk_python-0.1.0/README.md +0 -202
- agentos_sdk_python-0.1.0/agentos_sdk/__init__.py +0 -14
- agentos_sdk_python-0.1.0/agentos_sdk/clients/toolkit.py +0 -43
- agentos_sdk_python-0.1.0/agentos_sdk/protocol.py +0 -51
- agentos_sdk_python-0.1.0/agentos_sdk/sdk.py +0 -485
- agentos_sdk_python-0.1.0/tests/test_agentkit.py +0 -116
- agentos_sdk_python-0.1.0/tests/test_sdk_facade.py +0 -76
- agentos_sdk_python-0.1.0/tests/test_toolkit.py +0 -46
- {agentos_sdk_python-0.1.0 → agentos_sdk_python-1.0.0}/LICENSE +0 -0
- {agentos_sdk_python-0.1.0 → agentos_sdk_python-1.0.0}/agentos_sdk/clients/cronkit.py +0 -0
- {agentos_sdk_python-0.1.0 → agentos_sdk_python-1.0.0}/agentos_sdk/clients/modelkit.py +0 -0
- {agentos_sdk_python-0.1.0 → agentos_sdk_python-1.0.0}/agentos_sdk/clients/systemkit.py +0 -0
- {agentos_sdk_python-0.1.0 → agentos_sdk_python-1.0.0}/agentos_sdk/py.typed +0 -0
- {agentos_sdk_python-0.1.0 → agentos_sdk_python-1.0.0}/tests/test_cronkit.py +0 -0
- {agentos_sdk_python-0.1.0 → agentos_sdk_python-1.0.0}/tests/test_modelkit.py +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0 - 2026-09-01
|
|
4
|
+
|
|
5
|
+
- Updated AgentKit for the LiteAgent SDK 0.4 gateway contract.
|
|
6
|
+
- Added support and coverage for recursively nested inline agents through
|
|
7
|
+
`Capability.subAgentList`.
|
|
8
|
+
- **Breaking:** Removed the AgentKit agent CRUD methods because the corresponding
|
|
9
|
+
gateway routes no longer exist.
|
|
10
|
+
- **Breaking:** `init_session` now requires a Capability request body and no
|
|
11
|
+
longer accepts the removed `agent_id` argument.
|
|
12
|
+
- Removed the obsolete `agentId` field from AgentKit message type declarations.
|
|
13
|
+
|
|
14
|
+
## 0.2.0 - 2026-07-17
|
|
15
|
+
|
|
16
|
+
- **Breaking:** Updated OpenTool server identities to daemon 0.5
|
|
17
|
+
`namespace` / `name` / `version` fields.
|
|
18
|
+
- Added public `ToolContentState` and `ToolLifecycleEventDto` types.
|
|
19
|
+
- Added `materializedArtifactDigest` and `contentState` ToolKit metadata.
|
|
20
|
+
- Added OpenTool server declarations, registration statuses, and AppKit provisioning/availability events.
|
|
21
|
+
- Added paginated AgentKit history, summary history, and process history APIs.
|
|
22
|
+
- Added child-session routing and structured function-call lifecycle errors.
|
|
23
|
+
- Added ToolKit server metadata types and hardened SSE parsing.
|
|
24
|
+
- Added automatic app registration Bearer authentication to ToolKit list and load requests.
|
|
25
|
+
- Added one-time app token refresh and retry for ToolKit requests that return 401 or 403.
|
|
26
|
+
- Added `sdk.toolkit.call()` for non-streaming tool function calls.
|
|
27
|
+
- Added `sdk.toolkit.stream_call()` / `streamCall()` with typed stream events and safe
|
|
28
|
+
response closure after normal completion, errors, cancellation, or explicit early close.
|
|
29
|
+
- **Breaking:** Replaced `AgentOSEventHandler.on_call_app` / `onCallApp` with `on_app_event` / `onAppEvent`.
|
|
30
|
+
|
|
31
|
+
## 0.1.0 - 2026-06-12
|
|
32
|
+
|
|
33
|
+
- Initial public release of the AgentOS Python SDK.
|
|
34
|
+
- Added async clients for AgentOS, AgentKit, CronKit, ModelKit, and ToolKit APIs.
|
|
35
|
+
- Added facade helpers for bearer token reuse, token refresh retry, stream callbacks, and TS-style alias compatibility.
|
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: agentos-sdk-python
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Async Python SDK for AgentOS APIs.
|
|
5
|
+
Project-URL: Repository, https://gitlab.litevar.com/litevar/agentos/agentos-sdk-python
|
|
6
|
+
Project-URL: Issues, https://gitlab.litevar.com/litevar/agentos/agentos-sdk-python/-/issues
|
|
7
|
+
Author: LiteVar
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: agentkit,agentos,async,modelkit,sdk,toolkit
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: httpx<1,>=0.27
|
|
25
|
+
Requires-Dist: typing-extensions<5,>=4.6
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: build<2,>=1.2; extra == 'dev'
|
|
28
|
+
Requires-Dist: mypy<2,>=1.10; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest-asyncio<1,>=0.23; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest<9,>=8; extra == 'dev'
|
|
31
|
+
Requires-Dist: ruff<1,>=0.5; extra == 'dev'
|
|
32
|
+
Requires-Dist: twine<8,>=7; extra == 'dev'
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# AgentOS SDK for Python
|
|
36
|
+
|
|
37
|
+
Async Python SDK for AgentOS APIs. The package is a thin client over AgentOS HTTP and SSE endpoints with small compatibility helpers for bearer tokens, stream callbacks, Pythonic method names, and request defaults.
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install agentos-sdk-python
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
For local development:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
python3 -m venv .venv
|
|
49
|
+
.venv/bin/python -m pip install -e ".[dev]"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Quickstart
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from agentos_sdk import AgentOSSDK
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
async def main():
|
|
59
|
+
async with AgentOSSDK(base_url="http://localhost:8888") as sdk:
|
|
60
|
+
version = await sdk.agentos.get_version()
|
|
61
|
+
print(version)
|
|
62
|
+
|
|
63
|
+
registration = await sdk.agentos.register_bundle(
|
|
64
|
+
{
|
|
65
|
+
"bundleId": "com.demo.app",
|
|
66
|
+
"appGroupId": "com.demo.group",
|
|
67
|
+
"opentoolServers": [
|
|
68
|
+
{"ref": "websearch", "name": "opentool-server-websearch"}
|
|
69
|
+
],
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
print(registration.get("opentoolServers", []))
|
|
73
|
+
|
|
74
|
+
tasks = await sdk.cronkit.list_tasks(limit=10)
|
|
75
|
+
print(tasks)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`AgentOSSDK` also exposes TS-style camelCase aliases for common migration paths, such as `registerBundle`, `listTasks`, `chatSimple`, `listModels`, `loadTool`, `getPeers`, and `listTransfers`.
|
|
79
|
+
|
|
80
|
+
## Transport
|
|
81
|
+
|
|
82
|
+
The SDK uses `httpx.AsyncClient` and defaults to `http://localhost:8888`.
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
from agentos_sdk import AgentOSSDK
|
|
86
|
+
|
|
87
|
+
sdk = AgentOSSDK(
|
|
88
|
+
base_url="http://localhost:8888",
|
|
89
|
+
connect_timeout=5.0,
|
|
90
|
+
receive_timeout=10.0,
|
|
91
|
+
)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Use `async with AgentOSSDK(...)` or call `await sdk.aclose()` when done.
|
|
95
|
+
|
|
96
|
+
## Token Handling
|
|
97
|
+
|
|
98
|
+
`sdk.agentos.register_bundle(...)` stores the active app token. Protected facade methods in `sdk.agentkit`, `sdk.cronkit`, `sdk.authkit`, `sdk.discoverykit`, and `sdk.transferkit` use that token automatically.
|
|
99
|
+
|
|
100
|
+
If a protected call fails with HTTP `401`, HTTP `403`, or recognizable invalid-token text, the SDK re-runs registration for the same bundle once and retries the call. The cached bundle is a defensive copy and retains its `opentoolServers` declarations during refresh.
|
|
101
|
+
|
|
102
|
+
## AgentOS Events
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from agentos_sdk import AgentOSEventHandler, AgentOSSDK
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class Handler(AgentOSEventHandler):
|
|
109
|
+
async def on_welcome(self, welcome):
|
|
110
|
+
print("welcome", welcome)
|
|
111
|
+
|
|
112
|
+
async def on_app_event(self, event):
|
|
113
|
+
if event["type"] == "toolkit.provision.succeeded":
|
|
114
|
+
print("tool ready", event["data"]["ref"], event["data"]["id"])
|
|
115
|
+
elif event["type"] == "toolkit.provision.failed":
|
|
116
|
+
print("tool failed", event["data"]["error"])
|
|
117
|
+
|
|
118
|
+
async def on_done(self):
|
|
119
|
+
print("subscription ended")
|
|
120
|
+
|
|
121
|
+
async def on_error(self, error):
|
|
122
|
+
raise error
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
async with AgentOSSDK() as sdk:
|
|
126
|
+
await sdk.agentos.register_bundle(
|
|
127
|
+
{
|
|
128
|
+
"bundleId": "com.demo.app",
|
|
129
|
+
"opentoolServers": [
|
|
130
|
+
{"ref": "websearch", "name": "opentool-server-websearch"}
|
|
131
|
+
],
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
await sdk.agentos.subscribe(Handler())
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Registration statuses are `running`, `starting`, and `notFound`; only `running` includes a callable tool `id`. A `starting` declaration becomes callable after `toolkit.provision.succeeded`. Stop using a tool while it is `toolkit.tool.unavailable` and resume after `toolkit.tool.available`.
|
|
138
|
+
|
|
139
|
+
`on_call_app` / `onCallApp` were removed in 0.2.0. Use `on_app_event` / `onAppEvent`.
|
|
140
|
+
|
|
141
|
+
## AgentKit
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
from agentos_sdk import AgentMessageHandler, AgentOSSDK, ToolReturn
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class ChatHandler(AgentMessageHandler):
|
|
148
|
+
async def on_message(self, session_id, message):
|
|
149
|
+
print("message", session_id, message)
|
|
150
|
+
|
|
151
|
+
async def on_chunk(self, session_id, chunk):
|
|
152
|
+
print("chunk", session_id, chunk)
|
|
153
|
+
|
|
154
|
+
async def on_function_call(self, session_id, function_call):
|
|
155
|
+
return ToolReturn(function_call["id"], {"ok": True})
|
|
156
|
+
|
|
157
|
+
async def on_done(self):
|
|
158
|
+
print("done")
|
|
159
|
+
|
|
160
|
+
async def on_error(self, error):
|
|
161
|
+
raise error
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
async with AgentOSSDK() as sdk:
|
|
165
|
+
await sdk.agentos.register_bundle({"bundleId": "com.demo.app"})
|
|
166
|
+
session = await sdk.agentkit.init_session(
|
|
167
|
+
capability={"systemPrompt": "You are a helpful assistant."}
|
|
168
|
+
)
|
|
169
|
+
await sdk.agentkit.chat(
|
|
170
|
+
session,
|
|
171
|
+
{"content": [{"type": "text", "message": "Hello"}]},
|
|
172
|
+
ChatHandler(),
|
|
173
|
+
)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Summary-first history is available without loading every process message:
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
summaries = await sdk.agentkit.history_summary(session_id=session["sessionId"])
|
|
180
|
+
messages = await sdk.agentkit.history_process(
|
|
181
|
+
session_id=session["sessionId"],
|
|
182
|
+
original_task_id=summaries[0]["originalTaskId"],
|
|
183
|
+
)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
`history_summary` defaults to page 1 with 30 items; `history_process` defaults to page 1 with 50 items. Page sizes must be between 1 and 200. CamelCase callers can use `historySummary(sessionId=...)` and `historyProcess(sessionId=..., originalTaskId=...)`.
|
|
187
|
+
|
|
188
|
+
Message, chunk, and function-call handlers receive a child `sessionId` when the event supplies one, otherwise the root session ID. Function-call failures passed to `on_error` use `FunctionCallLifecycleError` with `stage` equal to `function_call_parse_failed`, `function_call_handler_failed`, or `function_call_callback_failed`.
|
|
189
|
+
|
|
190
|
+
AgentKit 1.0.0 follows the session-only gateway contract. Agent CRUD methods and
|
|
191
|
+
the `init_session(agent_id=...)` form have been removed. Define sub-agents inline
|
|
192
|
+
with `Capability.subAgentList`:
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
session = await sdk.agentkit.init_session(
|
|
196
|
+
capability={
|
|
197
|
+
"systemPrompt": "Coordinate the task.",
|
|
198
|
+
"subAgentList": [
|
|
199
|
+
{
|
|
200
|
+
"name": "researcher",
|
|
201
|
+
"capability": {"systemPrompt": "Research the requested topic."},
|
|
202
|
+
}
|
|
203
|
+
],
|
|
204
|
+
}
|
|
205
|
+
)
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Direct AgentKit methods include `init_session`, `init_simple`, `chat`,
|
|
209
|
+
`chat_simple`, `history`, `history_summary`, `history_process`, `stop`, `clear`,
|
|
210
|
+
`callback`, and `stream_callback`.
|
|
211
|
+
|
|
212
|
+
## CronKit
|
|
213
|
+
|
|
214
|
+
```python
|
|
215
|
+
async with AgentOSSDK() as sdk:
|
|
216
|
+
await sdk.agentos.register_bundle({"bundleId": "com.demo.app"})
|
|
217
|
+
task = await sdk.cronkit.create_task(
|
|
218
|
+
request={
|
|
219
|
+
"name": "Daily summary",
|
|
220
|
+
"schedule": "0 9 * * *",
|
|
221
|
+
"spec": {
|
|
222
|
+
"systemPrompt": "You are a scheduled agent.",
|
|
223
|
+
"content": [{"type": "text", "message": "Summarize today."}],
|
|
224
|
+
},
|
|
225
|
+
}
|
|
226
|
+
)
|
|
227
|
+
await sdk.cronkit.run_task_now(cron_id=task["cronId"])
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
CronKit create requests default `concurrency` to `skipIfRunning`, `enabled` to `True`, and `spec.timeoutSeconds` to `3600`.
|
|
231
|
+
|
|
232
|
+
## ModelKit
|
|
233
|
+
|
|
234
|
+
```python
|
|
235
|
+
async with AgentOSSDK() as sdk:
|
|
236
|
+
models = await sdk.modelkit.list_models()
|
|
237
|
+
chat_models = await sdk.modelkit.list_models_by_task("chat")
|
|
238
|
+
print(models[0]["capabilities"]["reasoning"])
|
|
239
|
+
|
|
240
|
+
completion = await sdk.modelkit.chat.create(
|
|
241
|
+
{
|
|
242
|
+
"model": "qwen3-1.7b",
|
|
243
|
+
"messages": [{"role": "user", "content": "Hello"}],
|
|
244
|
+
"maxTokens": 128,
|
|
245
|
+
}
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
async for chunk in sdk.modelkit.chat.create_stream(
|
|
249
|
+
{"model": "qwen3-1.7b", "messages": [{"role": "user", "content": "Stream"}]}
|
|
250
|
+
):
|
|
251
|
+
print(chunk)
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Normalized model capabilities include `vision`, `tool_call`, `stream`, and
|
|
255
|
+
`reasoning` booleans. `reasoning` reflects only the server-provided
|
|
256
|
+
`capabilities.reasoning` value and defaults to `False` when omitted.
|
|
257
|
+
|
|
258
|
+
ModelKit also supports:
|
|
259
|
+
|
|
260
|
+
- `sdk.modelkit.embedding.create(...)`
|
|
261
|
+
- `sdk.modelkit.asr.transcribe(...)`
|
|
262
|
+
- `sdk.modelkit.tts.synthesize(...)`
|
|
263
|
+
- `sdk.modelkit.tts.list_voices()`
|
|
264
|
+
|
|
265
|
+
## ToolKit
|
|
266
|
+
|
|
267
|
+
```python
|
|
268
|
+
async with AgentOSSDK() as sdk:
|
|
269
|
+
registration = await sdk.agentos.register_bundle(
|
|
270
|
+
{
|
|
271
|
+
"bundleId": "com.example.app",
|
|
272
|
+
"opentoolServers": [
|
|
273
|
+
{
|
|
274
|
+
"ref": "websearch",
|
|
275
|
+
"name": "opentool-server-websearch",
|
|
276
|
+
}
|
|
277
|
+
],
|
|
278
|
+
}
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
tools = await sdk.toolkit.list_tool()
|
|
282
|
+
websearch_tool = next(
|
|
283
|
+
(
|
|
284
|
+
tool
|
|
285
|
+
for tool in tools
|
|
286
|
+
if tool.get("status") == "running"
|
|
287
|
+
and (tool.get("server") or {}).get("name")
|
|
288
|
+
== "opentool-server-websearch"
|
|
289
|
+
),
|
|
290
|
+
None,
|
|
291
|
+
)
|
|
292
|
+
if websearch_tool is None:
|
|
293
|
+
raise RuntimeError("The registered websearch tool is not running")
|
|
294
|
+
|
|
295
|
+
tool_id = websearch_tool["id"]
|
|
296
|
+
definition = await sdk.toolkit.load_tool(tool_id)
|
|
297
|
+
raw_json = definition.to_json() if definition else None
|
|
298
|
+
|
|
299
|
+
result = await sdk.toolkit.call(
|
|
300
|
+
tool_id,
|
|
301
|
+
{
|
|
302
|
+
"id": "call-1",
|
|
303
|
+
"name": "websearch",
|
|
304
|
+
"arguments": {
|
|
305
|
+
"query": "AgentOS",
|
|
306
|
+
"max_results": 5,
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
)
|
|
310
|
+
print(result)
|
|
311
|
+
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
`registration["opentoolServers"]` also contains the resolved `id` when its
|
|
315
|
+
status is `running`; the example uses `list_tool()` so it can select the running
|
|
316
|
+
tool by `server.name`.
|
|
317
|
+
|
|
318
|
+
`subscribe_tool_events()` is retained for legacy direct-daemon deployments.
|
|
319
|
+
The deprecated `/toolkit/events` endpoint is not exposed by the AgentOS API
|
|
320
|
+
gateway.
|
|
321
|
+
|
|
322
|
+
`stream_call()` is only appropriate for functions whose tool server explicitly
|
|
323
|
+
supports `streamCall`. For such a function, retain the stream and close it when
|
|
324
|
+
consumer work ends early:
|
|
325
|
+
|
|
326
|
+
```python
|
|
327
|
+
async def consume_streaming_function(sdk, streaming_tool_id):
|
|
328
|
+
stream = sdk.toolkit.stream_call(
|
|
329
|
+
streaming_tool_id,
|
|
330
|
+
{"id": "call-2", "name": "streaming-function", "arguments": {}},
|
|
331
|
+
)
|
|
332
|
+
try:
|
|
333
|
+
async for event in stream:
|
|
334
|
+
print(event["event"], event["data"])
|
|
335
|
+
finally:
|
|
336
|
+
await stream.aclose()
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
The high-level ToolKit list, load, call, and stream-call methods use the bearer
|
|
340
|
+
token returned by `register_bundle()` and refresh it once after a 401/403
|
|
341
|
+
response. `load_tool()` returns an `OpenToolDefinition` wrapper that preserves
|
|
342
|
+
the raw JSON definition.
|
|
343
|
+
|
|
344
|
+
## AuthKit
|
|
345
|
+
|
|
346
|
+
```python
|
|
347
|
+
async with AgentOSSDK() as sdk:
|
|
348
|
+
await sdk.agentos.register_bundle({"bundleId": "com.demo.app"})
|
|
349
|
+
|
|
350
|
+
auth = await sdk.authkit.authorize({"scopes": ["profile"], "appName": "Demo"})
|
|
351
|
+
print(auth["requestId"], auth["status"])
|
|
352
|
+
|
|
353
|
+
status = await sdk.authkit.get_status(request_id=auth["requestId"])
|
|
354
|
+
if status.get("authCode"):
|
|
355
|
+
token_resp = await sdk.authkit.exchange_token(
|
|
356
|
+
request={"authCode": status["authCode"]}
|
|
357
|
+
)
|
|
358
|
+
user = await sdk.authkit.get_user_info(access_token=token_resp["accessToken"])
|
|
359
|
+
print(user["name"])
|
|
360
|
+
|
|
361
|
+
await sdk.authkit.revoke({"bundleId": "com.other.app"})
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
## DiscoveryKit
|
|
365
|
+
|
|
366
|
+
```python
|
|
367
|
+
async with AgentOSSDK() as sdk:
|
|
368
|
+
await sdk.agentos.register_bundle({"bundleId": "com.demo.app"})
|
|
369
|
+
|
|
370
|
+
await sdk.discoverykit.register({"receivePolicy": "autoAccept"})
|
|
371
|
+
|
|
372
|
+
peers = await sdk.discoverykit.get_peers()
|
|
373
|
+
print(peers)
|
|
374
|
+
|
|
375
|
+
self_info = await sdk.discoverykit.get_self()
|
|
376
|
+
print(self_info["deviceName"], self_info["registered"])
|
|
377
|
+
|
|
378
|
+
async for event in sdk.discoverykit.stream_peers():
|
|
379
|
+
print(event["type"], event["device"]["name"])
|
|
380
|
+
|
|
381
|
+
await sdk.discoverykit.unregister()
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
## TransferKit
|
|
385
|
+
|
|
386
|
+
```python
|
|
387
|
+
async with AgentOSSDK() as sdk:
|
|
388
|
+
await sdk.agentos.register_bundle({"bundleId": "com.demo.app"})
|
|
389
|
+
|
|
390
|
+
session = await sdk.transferkit.send(
|
|
391
|
+
request={
|
|
392
|
+
"targetDeviceId": "device-abc",
|
|
393
|
+
"files": [
|
|
394
|
+
{"fileName": "photo.jpg", "size": 1024, "filePath": "/tmp/photo.jpg"}
|
|
395
|
+
],
|
|
396
|
+
}
|
|
397
|
+
)
|
|
398
|
+
print(session["transferId"], session["state"])
|
|
399
|
+
|
|
400
|
+
transfers = await sdk.transferkit.list_transfers()
|
|
401
|
+
|
|
402
|
+
async for progress in sdk.transferkit.stream_progress(
|
|
403
|
+
transfer_id=session["transferId"]
|
|
404
|
+
):
|
|
405
|
+
print(progress["progress"])
|
|
406
|
+
|
|
407
|
+
await sdk.transferkit.set_policy(request={"policy": "autoAccept"})
|
|
408
|
+
policy = await sdk.transferkit.get_policy()
|
|
409
|
+
|
|
410
|
+
history = await sdk.transferkit.get_history()
|
|
411
|
+
await sdk.transferkit.clear_history()
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
`list_tool()` is typed as `list[ToolDto]` and exposes daemon 0.5 metadata. Its
|
|
415
|
+
optional `server` identity uses `namespace`, `name`, and `version`;
|
|
416
|
+
`materializedArtifactDigest` identifies installed content when available, and
|
|
417
|
+
`contentState` reports whether it is current.
|
|
418
|
+
|
|
419
|
+
## Direct Clients
|
|
420
|
+
|
|
421
|
+
The low-level clients are available for explicit-token or custom transport usage:
|
|
422
|
+
|
|
423
|
+
```python
|
|
424
|
+
from agentos_sdk.clients import AgentKitClient, CronKitClient, ModelKitClient
|
|
425
|
+
from agentos_sdk.transport import ApiClient
|
|
426
|
+
|
|
427
|
+
api = ApiClient(base_url="http://localhost:8888")
|
|
428
|
+
agentkit = AgentKitClient(api)
|
|
429
|
+
session = await agentkit.init_session(
|
|
430
|
+
"bearer-token",
|
|
431
|
+
capability={"systemPrompt": "You are a helpful assistant."},
|
|
432
|
+
)
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
## Development
|
|
436
|
+
|
|
437
|
+
```bash
|
|
438
|
+
.venv/bin/python -m compileall agentos_sdk
|
|
439
|
+
.venv/bin/python -m pytest -q
|
|
440
|
+
.venv/bin/ruff check .
|
|
441
|
+
```
|