agentos-sdk-python 1.1.1__tar.gz → 3.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-1.1.1 → agentos_sdk_python-3.0.0}/CHANGELOG.md +32 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/PKG-INFO +25 -26
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/README-zh_CN.md +20 -23
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/README.md +24 -25
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/RELEASE.md +7 -7
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/agentos_sdk/clients/discoverykit.py +1 -19
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/agentos_sdk/clients/modelkit.py +3 -2
- agentos_sdk_python-3.0.0/agentos_sdk/clients/transferkit.py +64 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/agentos_sdk/normalizers.py +14 -13
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/agentos_sdk/protocol.py +11 -7
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/agentos_sdk/sdk.py +4 -71
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/pyproject.toml +1 -1
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/tests/test_modelkit.py +70 -21
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/tests/test_normalizers.py +55 -23
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/tests/test_sdk_facade.py +54 -1
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/tests/typecheck/modelkit_usage.py +3 -2
- agentos_sdk_python-1.1.1/agentos_sdk/clients/transferkit.py +0 -149
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/.gitignore +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/LICENSE +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/agentos_sdk/__init__.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/agentos_sdk/clients/__init__.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/agentos_sdk/clients/agentkit.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/agentos_sdk/clients/appkit.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/agentos_sdk/clients/authkit.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/agentos_sdk/clients/cronkit.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/agentos_sdk/clients/harnesskit.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/agentos_sdk/clients/notifykit.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/agentos_sdk/clients/systemkit.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/agentos_sdk/clients/toolkit.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/agentos_sdk/handlers.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/agentos_sdk/py.typed +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/agentos_sdk/transport.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/tests/test_agentkit.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/tests/test_cronkit.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/tests/test_harnesskit.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/tests/test_notifykit.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/tests/test_protocol.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/tests/test_toolkit.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/tests/test_transport.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/tests/typecheck/harnesskit_usage.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/tests/typecheck/notifykit_usage.py +0 -0
- {agentos_sdk_python-1.1.1 → agentos_sdk_python-3.0.0}/tests/typecheck/toolkit_usage.py +0 -0
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
- **Breaking change.** Include `baseUrl` and `endpointProtocol` alongside
|
|
6
|
+
`name` in the request to `register_app_model`. Use `AppModelRegistration`
|
|
7
|
+
for registration and `AppModelUpdate` for partial updates. Both request
|
|
8
|
+
types accept optional `adapterSettings`.
|
|
9
|
+
- Model and app model listings recognize the `image`, `video`, and `music`
|
|
10
|
+
task values. When the gateway supplies them, `list_models()` returns
|
|
11
|
+
`endpointProtocol` and `provider`, and `list_app_models()` returns
|
|
12
|
+
`endpointProtocol`.
|
|
13
|
+
|
|
14
|
+
## 2.0.0
|
|
15
|
+
|
|
16
|
+
- **Breaking:** Nearby discovery is device-level. Removed `register` and
|
|
17
|
+
`unregister` from `DiscoveryKitClient` and the authenticated
|
|
18
|
+
`sdk.discoverykit` facade. Apps can query nearby devices and the current
|
|
19
|
+
device, and watch discovery events without registering.
|
|
20
|
+
- **Breaking:** Incoming nearby transfers are handled by the receiving device's
|
|
21
|
+
built-in UI. Removed `respond`, `receive_stream`, `set_policy`, `get_policy`,
|
|
22
|
+
`get_history`, `delete_history`, and `clear_history` from `TransferKitClient`
|
|
23
|
+
and the authenticated `sdk.transferkit` facade, including their camelCase
|
|
24
|
+
aliases. Apps can send files and track or cancel their own transfers.
|
|
25
|
+
- **Breaking:** Model info now takes the billing fields of the AgentOS server's
|
|
26
|
+
model list as they are: `billingType` (`ModelBillingType`: `"free"`,
|
|
27
|
+
`"in plan"`, `"pay as you go"` or `"benefit card"`), `cardName` (the benefit
|
|
28
|
+
card, only for `"benefit card"`; it is the only identifier of a card) and
|
|
29
|
+
`planNameZh` / `planNameEn` (the plan, only for `"free"` and `"in plan"`).
|
|
30
|
+
The old `billingType` values `"plan"` and `"payAsYouGo"` are no longer
|
|
31
|
+
understood, and `isBenefitCard`, `benefitCardId` and `benefitCardName` are
|
|
32
|
+
removed: use `billingType == "benefit card"` and `cardName`. A benefit card
|
|
33
|
+
model still keeps `source` `"platform"` and its plain `name` / `alias`.
|
|
34
|
+
|
|
3
35
|
## 1.1.1
|
|
4
36
|
|
|
5
37
|
- Added HarnessKit private App tool registration with `register_private_tools`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agentos-sdk-python
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0
|
|
4
4
|
Summary: Async Python SDK for AgentOS APIs.
|
|
5
5
|
Project-URL: Repository, https://gitlab.litevar.com/litevar/agentos/agentos-sdk-python
|
|
6
6
|
Project-URL: Issues, https://gitlab.litevar.com/litevar/agentos/agentos-sdk-python/-/issues
|
|
@@ -262,7 +262,7 @@ Every model also carries `source`, the mutually exclusive origin of the model
|
|
|
262
262
|
| `source` | Meaning | Suggested group |
|
|
263
263
|
| --- | --- | --- |
|
|
264
264
|
| `"local"` | Runs on this device | Local Models |
|
|
265
|
-
| `"platform"` | Remote model provided by the AgentOS platform | Platform Models, plus `Remote · System · {
|
|
265
|
+
| `"platform"` | Remote model provided by the AgentOS platform | Platform Models, plus `Remote · System · {cardName}` for each benefit card (see below) |
|
|
266
266
|
| `"custom"` | Remote model configured by the user | Custom Models |
|
|
267
267
|
| `"app"` | Registered by a third-party app | `App · {appName}` (one group per app) |
|
|
268
268
|
|
|
@@ -282,24 +282,25 @@ one, so fall back to `appBundleId`). Against gateways that predate `source`, or
|
|
|
282
282
|
when it holds an unknown value, `source` is derived from the legacy flags with
|
|
283
283
|
the gateway's rules.
|
|
284
284
|
|
|
285
|
+
Platform models also carry the billing fields of the AgentOS server's model list,
|
|
286
|
+
with the same names and values: `billingType` (`"free"`, `"in plan"`,
|
|
287
|
+
`"pay as you go"` or `"benefit card"`), `cardName` (the benefit card, only for
|
|
288
|
+
`"benefit card"`) and `planNameZh` / `planNameEn` (the plan, only for `"free"` and
|
|
289
|
+
`"in plan"`). They are omitted when unknown and for local, custom and app models.
|
|
290
|
+
|
|
285
291
|
Models served through a benefit card keep `source` `"platform"` and their plain
|
|
286
|
-
`name` / `alias
|
|
287
|
-
`
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
each card as its own group:
|
|
292
|
+
`name` / `alias`. The same model can be listed once for the plan and once per
|
|
293
|
+
card, so tell them apart by `id`, `billingType` or `cardName`. `cardName` is the
|
|
294
|
+
only identifier of a card: show each card as its own group named after it, and
|
|
295
|
+
mark each billing type with a small badge:
|
|
291
296
|
|
|
292
297
|
```python
|
|
293
298
|
def system_group_title(model: dict) -> str:
|
|
294
|
-
if model.get("
|
|
295
|
-
return f"Remote · System · {model.get('
|
|
299
|
+
if model.get("billingType") == "benefit card":
|
|
300
|
+
return f"Remote · System · {model.get('cardName') or 'Benefit card'}"
|
|
296
301
|
return "Remote · System"
|
|
297
302
|
```
|
|
298
303
|
|
|
299
|
-
System models that are not benefit card models also report `billingType`
|
|
300
|
-
(`"free"`, `"plan"` or `"payAsYouGo"`; omitted when unknown and for every other
|
|
301
|
-
model), so a picker can mark each type with a small badge.
|
|
302
|
-
|
|
303
304
|
Model dicts also carry `contextWindowSize` and `maxOutputTokens` (the maximum
|
|
304
305
|
number of tokens the model can generate in one response); `maxOutputTokens` is
|
|
305
306
|
only present when the gateway reports it. Only chat models report
|
|
@@ -307,7 +308,7 @@ only present when the gateway reports it. Only chat models report
|
|
|
307
308
|
text, so the key is absent for them); a chat model that reports
|
|
308
309
|
`contextWindowSize` reports `maxOutputTokens` too, using the same number when it
|
|
309
310
|
has no value of its own. Apps can set both when registering a model
|
|
310
|
-
(`register_app_model(request={"name": ..., "contextWindowSize": 32768,
|
|
311
|
+
(`register_app_model(request={"name": ..., "baseUrl": ..., "endpointProtocol": ..., "contextWindowSize": 32768,
|
|
311
312
|
"maxOutputTokens": 4096})`); app model records report them back, and
|
|
312
313
|
`update_app_model` can change them.
|
|
313
314
|
|
|
@@ -387,11 +388,12 @@ your model. A `name` is unique within your app; different apps may use the same
|
|
|
387
388
|
async with AgentOSSDK() as sdk:
|
|
388
389
|
await sdk.agentos.register_bundle({"bundleId": "com.example.app"})
|
|
389
390
|
|
|
390
|
-
# Register (or replace) a model.
|
|
391
|
+
# Register (or replace) a model. The required fields are `name`, `baseUrl` and `endpointProtocol`.
|
|
391
392
|
result = await sdk.modelkit.register_app_model(
|
|
392
393
|
request={
|
|
393
394
|
"name": "my-router",
|
|
394
395
|
"task": "decision",
|
|
396
|
+
"endpointProtocol": "/v1/systemone",
|
|
395
397
|
"baseUrl": "http://127.0.0.1:9000",
|
|
396
398
|
"apiKey": "upstream-secret", # stored by the server, never returned
|
|
397
399
|
}
|
|
@@ -533,26 +535,29 @@ async with AgentOSSDK() as sdk:
|
|
|
533
535
|
|
|
534
536
|
## DiscoveryKit
|
|
535
537
|
|
|
538
|
+
Device-level discovery of nearby AgentOS devices. Apps can query nearby devices
|
|
539
|
+
and the current device's info; they are never advertised to other devices.
|
|
540
|
+
|
|
536
541
|
```python
|
|
537
542
|
async with AgentOSSDK() as sdk:
|
|
538
543
|
await sdk.agentos.register_bundle({"bundleId": "com.demo.app"})
|
|
539
544
|
|
|
540
|
-
await sdk.discoverykit.register({"receivePolicy": "autoAccept"})
|
|
541
|
-
|
|
542
545
|
peers = await sdk.discoverykit.get_peers()
|
|
543
546
|
print(peers)
|
|
544
547
|
|
|
545
548
|
self_info = await sdk.discoverykit.get_self()
|
|
546
|
-
print(self_info["deviceName"], self_info["
|
|
549
|
+
print(self_info["deviceName"], self_info["nearbyTransferEnabled"])
|
|
547
550
|
|
|
548
551
|
async for event in sdk.discoverykit.stream_peers():
|
|
549
552
|
print(event["type"], event["device"]["name"])
|
|
550
|
-
|
|
551
|
-
await sdk.discoverykit.unregister()
|
|
552
553
|
```
|
|
553
554
|
|
|
554
555
|
## TransferKit
|
|
555
556
|
|
|
557
|
+
Sends files to a nearby AgentOS device. The receiving device handles the
|
|
558
|
+
incoming files in its built-in nearby transfer UI. Apps can send files and track
|
|
559
|
+
or cancel their own transfers.
|
|
560
|
+
|
|
556
561
|
```python
|
|
557
562
|
async with AgentOSSDK() as sdk:
|
|
558
563
|
await sdk.agentos.register_bundle({"bundleId": "com.demo.app"})
|
|
@@ -573,12 +578,6 @@ async with AgentOSSDK() as sdk:
|
|
|
573
578
|
transfer_id=session["transferId"]
|
|
574
579
|
):
|
|
575
580
|
print(progress["progress"])
|
|
576
|
-
|
|
577
|
-
await sdk.transferkit.set_policy(request={"policy": "autoAccept"})
|
|
578
|
-
policy = await sdk.transferkit.get_policy()
|
|
579
|
-
|
|
580
|
-
history = await sdk.transferkit.get_history()
|
|
581
|
-
await sdk.transferkit.clear_history()
|
|
582
581
|
```
|
|
583
582
|
|
|
584
583
|
`list_tool()` is typed as `list[ToolDto]` and exposes daemon 0.5 metadata. Its
|
|
@@ -227,7 +227,7 @@ async with AgentOSSDK() as sdk:
|
|
|
227
227
|
| `source` | 含义 | 建议分组 |
|
|
228
228
|
| --- | --- | --- |
|
|
229
229
|
| `"local"` | 在本机运行 | 本地模型 |
|
|
230
|
-
| `"platform"` | AgentOS 平台提供的远端模型 | 平台模型,另为每张权益卡单独分组 `远端 · 系统 · {
|
|
230
|
+
| `"platform"` | AgentOS 平台提供的远端模型 | 平台模型,另为每张权益卡单独分组 `远端 · 系统 · {cardName}`(见下) |
|
|
231
231
|
| `"custom"` | 用户自行配置的远端模型 | 自定义模型 |
|
|
232
232
|
| `"app"` | 第三方 app 注册的模型 | `App · {appName}`(每个 app 一组) |
|
|
233
233
|
|
|
@@ -245,27 +245,28 @@ app 模型还会带有 `appBundleId` 与 `appName`(app 的可读名称,用
|
|
|
245
245
|
`appName` 仅在网关返回时才有值,缺失时请回退到 `appBundleId`)。对于尚未提供
|
|
246
246
|
`source` 的旧网关,或 `source` 为未知值时,会按网关的规则由旧布尔字段推导。
|
|
247
247
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
248
|
+
平台模型还带有 AgentOS 服务端模型列表里的计费字段,名称与取值都与服务端一致:`billingType`
|
|
249
|
+
(`"free"`、`"in plan"`、`"pay as you go"` 或 `"benefit card"`)、`cardName`(权益卡名称,仅
|
|
250
|
+
`"benefit card"` 带有)以及 `planNameZh` / `planNameEn`(套餐名称,仅 `"free"` 与 `"in plan"` 带有)。
|
|
251
|
+
未知时,以及本地、自定义和 App 模型,均不包含这些键。
|
|
252
|
+
|
|
253
|
+
由权益卡提供的模型仍保持 `source` 为 `"platform"` 与原样的 `name` / `alias`。同一个模型可能在套餐
|
|
254
|
+
和每张权益卡下各出现一次,请用 `id`、`billingType` 或 `cardName` 区分。`cardName` 是权益卡的唯一标识:
|
|
255
|
+
请让每张权益卡按其名称各自成组,并为每种计费类型加一个小标识:
|
|
252
256
|
|
|
253
257
|
```python
|
|
254
258
|
def system_group_title(model: dict) -> str:
|
|
255
|
-
if model.get("
|
|
256
|
-
return f"远端 · 系统 · {model.get('
|
|
259
|
+
if model.get("billingType") == "benefit card":
|
|
260
|
+
return f"远端 · 系统 · {model.get('cardName') or '权益卡'}"
|
|
257
261
|
return "远端 · 系统"
|
|
258
262
|
```
|
|
259
263
|
|
|
260
|
-
非权益卡的系统模型还会带有 `billingType`(`"free"`、`"plan"` 或 `"payAsYouGo"`;未知时以及其他模型均不包含该键),
|
|
261
|
-
选择器可以为每种类型加一个小标识。
|
|
262
|
-
|
|
263
264
|
模型字典还会带有 `contextWindowSize` 与 `maxOutputTokens`(模型单次响应最多可生成的
|
|
264
265
|
token 数);`maxOutputTokens` 仅在网关返回时才存在。只有 chat 模型才会返回
|
|
265
266
|
`maxOutputTokens`(embedding、ASR、TTS、decision 模型不生成文本,不包含该键);返回了
|
|
266
267
|
`contextWindowSize` 的 chat 模型一定会返回 `maxOutputTokens`,模型自身没有该值时与
|
|
267
268
|
`contextWindowSize` 相同。App 注册模型时可同时设置两者
|
|
268
|
-
(`register_app_model(request={"name": ..., "contextWindowSize": 32768,
|
|
269
|
+
(`register_app_model(request={"name": ..., "baseUrl": ..., "endpointProtocol": ..., "contextWindowSize": 32768,
|
|
269
270
|
"maxOutputTokens": 4096})`);app 模型记录会原样返回,`update_app_model` 也可以修改。
|
|
270
271
|
|
|
271
272
|
ModelKit 还支持:
|
|
@@ -341,11 +342,12 @@ App 可以把自己的模型注册到网关。注册后的模型会出现在 `li
|
|
|
341
342
|
async with AgentOSSDK() as sdk:
|
|
342
343
|
await sdk.agentos.register_bundle({"bundleId": "com.example.app"})
|
|
343
344
|
|
|
344
|
-
#
|
|
345
|
+
# 注册(或替换)模型,必填字段为 `name`、`baseUrl` 和 `endpointProtocol`。
|
|
345
346
|
result = await sdk.modelkit.register_app_model(
|
|
346
347
|
request={
|
|
347
348
|
"name": "my-router",
|
|
348
349
|
"task": "decision",
|
|
350
|
+
"endpointProtocol": "/v1/systemone",
|
|
349
351
|
"baseUrl": "http://127.0.0.1:9000",
|
|
350
352
|
"apiKey": "upstream-secret", # 由服务端保存,不会再返回
|
|
351
353
|
}
|
|
@@ -480,26 +482,27 @@ async with AgentOSSDK() as sdk:
|
|
|
480
482
|
|
|
481
483
|
## DiscoveryKit
|
|
482
484
|
|
|
485
|
+
附近 AgentOS 设备的设备级发现。App 可以查询附近设备和本机设备信息,不会被广播给其他设备。
|
|
486
|
+
|
|
483
487
|
```python
|
|
484
488
|
async with AgentOSSDK() as sdk:
|
|
485
489
|
await sdk.agentos.register_bundle({"bundleId": "com.demo.app"})
|
|
486
490
|
|
|
487
|
-
await sdk.discoverykit.register({"receivePolicy": "autoAccept"})
|
|
488
|
-
|
|
489
491
|
peers = await sdk.discoverykit.get_peers()
|
|
490
492
|
print(peers)
|
|
491
493
|
|
|
492
494
|
self_info = await sdk.discoverykit.get_self()
|
|
493
|
-
print(self_info["deviceName"], self_info["
|
|
495
|
+
print(self_info["deviceName"], self_info["nearbyTransferEnabled"])
|
|
494
496
|
|
|
495
497
|
async for event in sdk.discoverykit.stream_peers():
|
|
496
498
|
print(event["type"], event["device"]["name"])
|
|
497
|
-
|
|
498
|
-
await sdk.discoverykit.unregister()
|
|
499
499
|
```
|
|
500
500
|
|
|
501
501
|
## TransferKit
|
|
502
502
|
|
|
503
|
+
向附近的 AgentOS 设备发送文件,接收设备在其内置的附近传输界面中处理收到的文件。
|
|
504
|
+
App 可以发送文件,并跟踪或取消自己发起的传输。
|
|
505
|
+
|
|
503
506
|
```python
|
|
504
507
|
async with AgentOSSDK() as sdk:
|
|
505
508
|
await sdk.agentos.register_bundle({"bundleId": "com.demo.app"})
|
|
@@ -520,12 +523,6 @@ async with AgentOSSDK() as sdk:
|
|
|
520
523
|
transfer_id=session["transferId"]
|
|
521
524
|
):
|
|
522
525
|
print(progress["progress"])
|
|
523
|
-
|
|
524
|
-
await sdk.transferkit.set_policy(request={"policy": "autoAccept"})
|
|
525
|
-
policy = await sdk.transferkit.get_policy()
|
|
526
|
-
|
|
527
|
-
history = await sdk.transferkit.get_history()
|
|
528
|
-
await sdk.transferkit.clear_history()
|
|
529
526
|
```
|
|
530
527
|
|
|
531
528
|
`list_tool()` 的返回类型为 `list[ToolDto]`,并暴露 daemon 0.5 元数据。可选
|
|
@@ -228,7 +228,7 @@ Every model also carries `source`, the mutually exclusive origin of the model
|
|
|
228
228
|
| `source` | Meaning | Suggested group |
|
|
229
229
|
| --- | --- | --- |
|
|
230
230
|
| `"local"` | Runs on this device | Local Models |
|
|
231
|
-
| `"platform"` | Remote model provided by the AgentOS platform | Platform Models, plus `Remote · System · {
|
|
231
|
+
| `"platform"` | Remote model provided by the AgentOS platform | Platform Models, plus `Remote · System · {cardName}` for each benefit card (see below) |
|
|
232
232
|
| `"custom"` | Remote model configured by the user | Custom Models |
|
|
233
233
|
| `"app"` | Registered by a third-party app | `App · {appName}` (one group per app) |
|
|
234
234
|
|
|
@@ -248,24 +248,25 @@ one, so fall back to `appBundleId`). Against gateways that predate `source`, or
|
|
|
248
248
|
when it holds an unknown value, `source` is derived from the legacy flags with
|
|
249
249
|
the gateway's rules.
|
|
250
250
|
|
|
251
|
+
Platform models also carry the billing fields of the AgentOS server's model list,
|
|
252
|
+
with the same names and values: `billingType` (`"free"`, `"in plan"`,
|
|
253
|
+
`"pay as you go"` or `"benefit card"`), `cardName` (the benefit card, only for
|
|
254
|
+
`"benefit card"`) and `planNameZh` / `planNameEn` (the plan, only for `"free"` and
|
|
255
|
+
`"in plan"`). They are omitted when unknown and for local, custom and app models.
|
|
256
|
+
|
|
251
257
|
Models served through a benefit card keep `source` `"platform"` and their plain
|
|
252
|
-
`name` / `alias
|
|
253
|
-
`
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
each card as its own group:
|
|
258
|
+
`name` / `alias`. The same model can be listed once for the plan and once per
|
|
259
|
+
card, so tell them apart by `id`, `billingType` or `cardName`. `cardName` is the
|
|
260
|
+
only identifier of a card: show each card as its own group named after it, and
|
|
261
|
+
mark each billing type with a small badge:
|
|
257
262
|
|
|
258
263
|
```python
|
|
259
264
|
def system_group_title(model: dict) -> str:
|
|
260
|
-
if model.get("
|
|
261
|
-
return f"Remote · System · {model.get('
|
|
265
|
+
if model.get("billingType") == "benefit card":
|
|
266
|
+
return f"Remote · System · {model.get('cardName') or 'Benefit card'}"
|
|
262
267
|
return "Remote · System"
|
|
263
268
|
```
|
|
264
269
|
|
|
265
|
-
System models that are not benefit card models also report `billingType`
|
|
266
|
-
(`"free"`, `"plan"` or `"payAsYouGo"`; omitted when unknown and for every other
|
|
267
|
-
model), so a picker can mark each type with a small badge.
|
|
268
|
-
|
|
269
270
|
Model dicts also carry `contextWindowSize` and `maxOutputTokens` (the maximum
|
|
270
271
|
number of tokens the model can generate in one response); `maxOutputTokens` is
|
|
271
272
|
only present when the gateway reports it. Only chat models report
|
|
@@ -273,7 +274,7 @@ only present when the gateway reports it. Only chat models report
|
|
|
273
274
|
text, so the key is absent for them); a chat model that reports
|
|
274
275
|
`contextWindowSize` reports `maxOutputTokens` too, using the same number when it
|
|
275
276
|
has no value of its own. Apps can set both when registering a model
|
|
276
|
-
(`register_app_model(request={"name": ..., "contextWindowSize": 32768,
|
|
277
|
+
(`register_app_model(request={"name": ..., "baseUrl": ..., "endpointProtocol": ..., "contextWindowSize": 32768,
|
|
277
278
|
"maxOutputTokens": 4096})`); app model records report them back, and
|
|
278
279
|
`update_app_model` can change them.
|
|
279
280
|
|
|
@@ -353,11 +354,12 @@ your model. A `name` is unique within your app; different apps may use the same
|
|
|
353
354
|
async with AgentOSSDK() as sdk:
|
|
354
355
|
await sdk.agentos.register_bundle({"bundleId": "com.example.app"})
|
|
355
356
|
|
|
356
|
-
# Register (or replace) a model.
|
|
357
|
+
# Register (or replace) a model. The required fields are `name`, `baseUrl` and `endpointProtocol`.
|
|
357
358
|
result = await sdk.modelkit.register_app_model(
|
|
358
359
|
request={
|
|
359
360
|
"name": "my-router",
|
|
360
361
|
"task": "decision",
|
|
362
|
+
"endpointProtocol": "/v1/systemone",
|
|
361
363
|
"baseUrl": "http://127.0.0.1:9000",
|
|
362
364
|
"apiKey": "upstream-secret", # stored by the server, never returned
|
|
363
365
|
}
|
|
@@ -499,26 +501,29 @@ async with AgentOSSDK() as sdk:
|
|
|
499
501
|
|
|
500
502
|
## DiscoveryKit
|
|
501
503
|
|
|
504
|
+
Device-level discovery of nearby AgentOS devices. Apps can query nearby devices
|
|
505
|
+
and the current device's info; they are never advertised to other devices.
|
|
506
|
+
|
|
502
507
|
```python
|
|
503
508
|
async with AgentOSSDK() as sdk:
|
|
504
509
|
await sdk.agentos.register_bundle({"bundleId": "com.demo.app"})
|
|
505
510
|
|
|
506
|
-
await sdk.discoverykit.register({"receivePolicy": "autoAccept"})
|
|
507
|
-
|
|
508
511
|
peers = await sdk.discoverykit.get_peers()
|
|
509
512
|
print(peers)
|
|
510
513
|
|
|
511
514
|
self_info = await sdk.discoverykit.get_self()
|
|
512
|
-
print(self_info["deviceName"], self_info["
|
|
515
|
+
print(self_info["deviceName"], self_info["nearbyTransferEnabled"])
|
|
513
516
|
|
|
514
517
|
async for event in sdk.discoverykit.stream_peers():
|
|
515
518
|
print(event["type"], event["device"]["name"])
|
|
516
|
-
|
|
517
|
-
await sdk.discoverykit.unregister()
|
|
518
519
|
```
|
|
519
520
|
|
|
520
521
|
## TransferKit
|
|
521
522
|
|
|
523
|
+
Sends files to a nearby AgentOS device. The receiving device handles the
|
|
524
|
+
incoming files in its built-in nearby transfer UI. Apps can send files and track
|
|
525
|
+
or cancel their own transfers.
|
|
526
|
+
|
|
522
527
|
```python
|
|
523
528
|
async with AgentOSSDK() as sdk:
|
|
524
529
|
await sdk.agentos.register_bundle({"bundleId": "com.demo.app"})
|
|
@@ -539,12 +544,6 @@ async with AgentOSSDK() as sdk:
|
|
|
539
544
|
transfer_id=session["transferId"]
|
|
540
545
|
):
|
|
541
546
|
print(progress["progress"])
|
|
542
|
-
|
|
543
|
-
await sdk.transferkit.set_policy(request={"policy": "autoAccept"})
|
|
544
|
-
policy = await sdk.transferkit.get_policy()
|
|
545
|
-
|
|
546
|
-
history = await sdk.transferkit.get_history()
|
|
547
|
-
await sdk.transferkit.clear_history()
|
|
548
547
|
```
|
|
549
548
|
|
|
550
549
|
`list_tool()` is typed as `list[ToolDto]` and exposes daemon 0.5 metadata. Its
|
|
@@ -12,8 +12,8 @@ The Python import package remains `agentos_sdk`.
|
|
|
12
12
|
```bash
|
|
13
13
|
.venv/bin/python -m pytest -q
|
|
14
14
|
.venv/bin/ruff check .
|
|
15
|
-
.venv/bin/python -m build --no-isolation --outdir dist/
|
|
16
|
-
.venv/bin/python -m twine check dist/
|
|
15
|
+
.venv/bin/python -m build --no-isolation --outdir dist/3.0.0
|
|
16
|
+
.venv/bin/python -m twine check --strict dist/3.0.0/*
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## TestPyPI
|
|
@@ -21,7 +21,7 @@ The Python import package remains `agentos_sdk`.
|
|
|
21
21
|
Upload to TestPyPI first:
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
.venv/bin/python -m twine upload --repository testpypi dist/
|
|
24
|
+
.venv/bin/python -m twine upload --repository testpypi dist/3.0.0/*
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
Install from TestPyPI in a clean environment:
|
|
@@ -31,7 +31,7 @@ python3 -m venv /tmp/agentos-sdk-python-test
|
|
|
31
31
|
/tmp/agentos-sdk-python-test/bin/python -m pip install \
|
|
32
32
|
--index-url https://test.pypi.org/simple/ \
|
|
33
33
|
--extra-index-url https://pypi.org/simple/ \
|
|
34
|
-
agentos-sdk-python==
|
|
34
|
+
agentos-sdk-python==3.0.0
|
|
35
35
|
/tmp/agentos-sdk-python-test/bin/python -c "from agentos_sdk import AgentOSSDK; print(AgentOSSDK)"
|
|
36
36
|
```
|
|
37
37
|
|
|
@@ -40,14 +40,14 @@ python3 -m venv /tmp/agentos-sdk-python-test
|
|
|
40
40
|
Upload to PyPI:
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
.venv/bin/python -m twine upload dist/
|
|
43
|
+
.venv/bin/python -m twine upload dist/3.0.0/*
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
Tag the released commit:
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
|
-
git tag
|
|
50
|
-
git push github
|
|
49
|
+
git tag v3.0.0
|
|
50
|
+
git push github v3.0.0
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
## Authentication
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
|
-
from typing import Any, AsyncGenerator
|
|
4
|
+
from typing import Any, AsyncGenerator
|
|
5
5
|
|
|
6
6
|
from agentos_sdk.transport import ApiClient, iter_sse
|
|
7
7
|
|
|
@@ -33,24 +33,6 @@ class DiscoveryKitClient:
|
|
|
33
33
|
headers=_auth(bearer_token),
|
|
34
34
|
)
|
|
35
35
|
|
|
36
|
-
async def register(
|
|
37
|
-
self, bearer_token: str, request: Mapping[str, Any] | None = None
|
|
38
|
-
) -> dict[str, Any]:
|
|
39
|
-
return await self.api_client.request(
|
|
40
|
-
"/discoverykit/register",
|
|
41
|
-
method="POST",
|
|
42
|
-
headers=_auth(bearer_token),
|
|
43
|
-
data=dict(request) if request else {},
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
async def unregister(self, bearer_token: str) -> dict[str, Any]:
|
|
47
|
-
return await self.api_client.request(
|
|
48
|
-
"/discoverykit/unregister",
|
|
49
|
-
method="POST",
|
|
50
|
-
headers=_auth(bearer_token),
|
|
51
|
-
data={},
|
|
52
|
-
)
|
|
53
|
-
|
|
54
36
|
getPeers = get_peers
|
|
55
37
|
streamPeers = stream_peers
|
|
56
38
|
getSelf = get_self
|
|
@@ -10,6 +10,7 @@ from agentos_sdk.normalizers import (
|
|
|
10
10
|
normalize_model_info,
|
|
11
11
|
serialize_chat_request,
|
|
12
12
|
)
|
|
13
|
+
from agentos_sdk.protocol import AppModelRegistration, AppModelUpdate
|
|
13
14
|
from agentos_sdk.transport import ApiClient, iter_sse
|
|
14
15
|
|
|
15
16
|
|
|
@@ -163,7 +164,7 @@ class ModelKitClient:
|
|
|
163
164
|
return [normalize_app_model(item) for item in data]
|
|
164
165
|
|
|
165
166
|
async def register_app_model(
|
|
166
|
-
self, bearer_token: str, request:
|
|
167
|
+
self, bearer_token: str, request: AppModelRegistration
|
|
167
168
|
) -> dict[str, Any]:
|
|
168
169
|
"""Register (or replace) an app model (``POST /modelkit/app-models``).
|
|
169
170
|
|
|
@@ -187,7 +188,7 @@ class ModelKitClient:
|
|
|
187
188
|
)
|
|
188
189
|
|
|
189
190
|
async def update_app_model(
|
|
190
|
-
self, bearer_token: str, model_id: str, request:
|
|
191
|
+
self, bearer_token: str, model_id: str, request: AppModelUpdate
|
|
191
192
|
) -> dict[str, Any]:
|
|
192
193
|
"""Partially update an owned app model (``PUT /modelkit/app-models/<id>``).
|
|
193
194
|
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from typing import Any, AsyncGenerator, Mapping
|
|
5
|
+
|
|
6
|
+
from agentos_sdk.transport import ApiClient, iter_sse
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TransferKitClient:
|
|
10
|
+
def __init__(self, api_client: ApiClient | None = None) -> None:
|
|
11
|
+
self.api_client = api_client or ApiClient()
|
|
12
|
+
|
|
13
|
+
async def send(
|
|
14
|
+
self, bearer_token: str, request: Mapping[str, Any]
|
|
15
|
+
) -> dict[str, Any]:
|
|
16
|
+
return await self.api_client.request(
|
|
17
|
+
"/transferkit/send",
|
|
18
|
+
method="POST",
|
|
19
|
+
headers=_auth(bearer_token),
|
|
20
|
+
data=dict(request),
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
async def list_transfers(self, bearer_token: str) -> list[dict[str, Any]]:
|
|
24
|
+
return await self.api_client.request(
|
|
25
|
+
"/transferkit/transfers",
|
|
26
|
+
headers=_auth(bearer_token),
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
async def get_status(
|
|
30
|
+
self, bearer_token: str, transfer_id: str
|
|
31
|
+
) -> dict[str, Any]:
|
|
32
|
+
return await self.api_client.request(
|
|
33
|
+
f"/transferkit/transfers/{transfer_id}/status",
|
|
34
|
+
headers=_auth(bearer_token),
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
async def stream_progress(
|
|
38
|
+
self, bearer_token: str, transfer_id: str
|
|
39
|
+
) -> AsyncGenerator[dict[str, Any], None]:
|
|
40
|
+
response = await self.api_client.request_stream(
|
|
41
|
+
f"/transferkit/transfers/{transfer_id}/stream",
|
|
42
|
+
headers=_auth(bearer_token),
|
|
43
|
+
)
|
|
44
|
+
async for event in iter_sse(response):
|
|
45
|
+
if event.data:
|
|
46
|
+
yield json.loads(event.data)
|
|
47
|
+
|
|
48
|
+
async def cancel(
|
|
49
|
+
self, bearer_token: str, transfer_id: str
|
|
50
|
+
) -> dict[str, Any]:
|
|
51
|
+
return await self.api_client.request(
|
|
52
|
+
f"/transferkit/transfers/{transfer_id}/cancel",
|
|
53
|
+
method="POST",
|
|
54
|
+
headers=_auth(bearer_token),
|
|
55
|
+
data={},
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
listTransfers = list_transfers
|
|
59
|
+
getStatus = get_status
|
|
60
|
+
streamProgress = stream_progress
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _auth(token: str) -> dict[str, str]:
|
|
64
|
+
return {"authorization": f"Bearer {token}"}
|
|
@@ -94,11 +94,11 @@ def normalize_agent_event_name(event_type: str) -> str:
|
|
|
94
94
|
return event_type
|
|
95
95
|
|
|
96
96
|
|
|
97
|
-
MODEL_TASKS = {"chat", "embedding", "asr", "tts", "decision"}
|
|
97
|
+
MODEL_TASKS = {"chat", "embedding", "asr", "tts", "decision", "image", "video", "music"}
|
|
98
98
|
MODALITIES = {"text", "image", "audio", "video", "decisions"}
|
|
99
99
|
MODEL_SOURCES = {"local", "platform", "custom", "app"}
|
|
100
|
-
# Wire values of ``billingType
|
|
101
|
-
MODEL_BILLING_TYPES = {"free"
|
|
100
|
+
# Wire values of ``billingType`` (the same as the AgentOS server's model list); parsing is case-insensitive.
|
|
101
|
+
MODEL_BILLING_TYPES = {"free", "in plan", "pay as you go", "benefit card"}
|
|
102
102
|
|
|
103
103
|
|
|
104
104
|
def _model_task(value: Any) -> str:
|
|
@@ -166,19 +166,18 @@ def normalize_model_info(item: Mapping[str, Any]) -> dict[str, Any]:
|
|
|
166
166
|
app_name = str(item["appName"]).strip() if item.get("appName") is not None else ""
|
|
167
167
|
if app_name:
|
|
168
168
|
result["appName"] = app_name
|
|
169
|
-
#
|
|
170
|
-
#
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
169
|
+
# The billing fields are the server's own: only system models carry them, and missing, blank and
|
|
170
|
+
# unknown values are dropped. Benefit card models keep source "platform"; ``cardName`` names the card.
|
|
171
|
+
billing_type = str(item.get("billingType") or "").strip().lower()
|
|
172
|
+
if billing_type in MODEL_BILLING_TYPES:
|
|
173
|
+
result["billingType"] = billing_type
|
|
174
|
+
for key in ("cardName", "planNameZh", "planNameEn"):
|
|
174
175
|
value = str(item[key]).strip() if item.get(key) is not None else ""
|
|
175
176
|
if value:
|
|
176
177
|
result[key] = value
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if billing_type:
|
|
181
|
-
result["billingType"] = billing_type
|
|
178
|
+
for key in ("endpointProtocol", "provider"):
|
|
179
|
+
if item.get(key):
|
|
180
|
+
result[key] = str(item[key])
|
|
182
181
|
return result
|
|
183
182
|
|
|
184
183
|
|
|
@@ -209,6 +208,8 @@ def normalize_app_model(item: Mapping[str, Any]) -> dict[str, Any]:
|
|
|
209
208
|
result["contextWindowSize"] = item["contextWindowSize"]
|
|
210
209
|
if item.get("maxOutputTokens") is not None:
|
|
211
210
|
result["maxOutputTokens"] = item["maxOutputTokens"]
|
|
211
|
+
if item.get("endpointProtocol"):
|
|
212
|
+
result["endpointProtocol"] = str(item["endpointProtocol"])
|
|
212
213
|
return result
|
|
213
214
|
|
|
214
215
|
|