agentos-sdk-python 1.1.0__py3-none-any.whl → 2.0.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.
- agentos_sdk/__init__.py +10 -0
- agentos_sdk/clients/discoverykit.py +1 -19
- agentos_sdk/clients/harnesskit.py +18 -0
- agentos_sdk/clients/modelkit.py +18 -5
- agentos_sdk/clients/transferkit.py +0 -85
- agentos_sdk/normalizers.py +53 -3
- agentos_sdk/protocol.py +59 -6
- agentos_sdk/sdk.py +27 -73
- {agentos_sdk_python-1.1.0.dist-info → agentos_sdk_python-2.0.0.dist-info}/METADATA +163 -32
- {agentos_sdk_python-1.1.0.dist-info → agentos_sdk_python-2.0.0.dist-info}/RECORD +12 -12
- {agentos_sdk_python-1.1.0.dist-info → agentos_sdk_python-2.0.0.dist-info}/WHEEL +0 -0
- {agentos_sdk_python-1.1.0.dist-info → agentos_sdk_python-2.0.0.dist-info}/licenses/LICENSE +0 -0
agentos_sdk/__init__.py
CHANGED
|
@@ -34,6 +34,8 @@ from .protocol import (
|
|
|
34
34
|
HarnessKitHealth,
|
|
35
35
|
HarnessKitLlmConfig,
|
|
36
36
|
HarnessKitOperationalSnapshot,
|
|
37
|
+
HarnessKitPrivateToolsRegistration,
|
|
38
|
+
HarnessKitPrivateToolsRegistrationResult,
|
|
37
39
|
HarnessKitRunAccepted,
|
|
38
40
|
HarnessKitRunError,
|
|
39
41
|
HarnessKitRunRequest,
|
|
@@ -44,9 +46,12 @@ from .protocol import (
|
|
|
44
46
|
HarnessKitThreadMessage,
|
|
45
47
|
HarnessKitThreadRenameResult,
|
|
46
48
|
HarnessKitThreadSnapshot,
|
|
49
|
+
HarnessKitToolPolicy,
|
|
47
50
|
HistoryTurnStatus,
|
|
48
51
|
HistoryTurnSummary,
|
|
49
52
|
Modality,
|
|
53
|
+
ModelBillingType,
|
|
54
|
+
ModelSource,
|
|
50
55
|
ModelTask,
|
|
51
56
|
NotifyKitEvent,
|
|
52
57
|
NotifyKitLevel,
|
|
@@ -106,6 +111,8 @@ __all__ = [
|
|
|
106
111
|
"HarnessKitHealth",
|
|
107
112
|
"HarnessKitLlmConfig",
|
|
108
113
|
"HarnessKitOperationalSnapshot",
|
|
114
|
+
"HarnessKitPrivateToolsRegistration",
|
|
115
|
+
"HarnessKitPrivateToolsRegistrationResult",
|
|
109
116
|
"HarnessKitRunAccepted",
|
|
110
117
|
"HarnessKitRunError",
|
|
111
118
|
"HarnessKitRunRequest",
|
|
@@ -116,9 +123,12 @@ __all__ = [
|
|
|
116
123
|
"HarnessKitThreadMessage",
|
|
117
124
|
"HarnessKitThreadRenameResult",
|
|
118
125
|
"HarnessKitThreadSnapshot",
|
|
126
|
+
"HarnessKitToolPolicy",
|
|
119
127
|
"HistoryTurnStatus",
|
|
120
128
|
"HistoryTurnSummary",
|
|
121
129
|
"Modality",
|
|
130
|
+
"ModelBillingType",
|
|
131
|
+
"ModelSource",
|
|
122
132
|
"ModelTask",
|
|
123
133
|
"NotifyKitEvent",
|
|
124
134
|
"NotifyKitLevel",
|
|
@@ -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
|
|
@@ -16,6 +16,7 @@ from agentos_sdk.protocol import (
|
|
|
16
16
|
HarnessKitEvent,
|
|
17
17
|
HarnessKitHealth,
|
|
18
18
|
HarnessKitOperationalSnapshot,
|
|
19
|
+
HarnessKitPrivateToolsRegistrationResult,
|
|
19
20
|
HarnessKitRunAccepted,
|
|
20
21
|
HarnessKitRunResult,
|
|
21
22
|
HarnessKitRuntimeInfo,
|
|
@@ -88,6 +89,22 @@ class HarnessKitClient:
|
|
|
88
89
|
"""Delete an idle thread (``DELETE /v1/threads/{threadId}``)."""
|
|
89
90
|
return await self.request(bearer_token, _thread_path(thread_id), method="DELETE")
|
|
90
91
|
|
|
92
|
+
async def register_private_tools(
|
|
93
|
+
self, bearer_token: str, thread_id: str, registration: Mapping[str, Any]
|
|
94
|
+
) -> HarnessKitPrivateToolsRegistrationResult:
|
|
95
|
+
"""Register or replace a local App's OpenTool callbacks for a thread.
|
|
96
|
+
|
|
97
|
+
``registration`` contains the callback ``endpoint``, callback ``token``
|
|
98
|
+
and OpenTool ``specification``. The callback token is separate from the
|
|
99
|
+
AppKit bearer token. Returns the registered ``toolId``.
|
|
100
|
+
"""
|
|
101
|
+
return await self.request(
|
|
102
|
+
bearer_token,
|
|
103
|
+
f"{_thread_path(thread_id)}/private-tools",
|
|
104
|
+
method="PUT",
|
|
105
|
+
data=dict(registration),
|
|
106
|
+
)
|
|
107
|
+
|
|
91
108
|
async def start_run(
|
|
92
109
|
self, bearer_token: str, thread_id: str, request: Mapping[str, Any]
|
|
93
110
|
) -> HarnessKitRunAccepted:
|
|
@@ -237,6 +254,7 @@ class HarnessKitClient:
|
|
|
237
254
|
getThread = get_thread
|
|
238
255
|
renameThread = rename_thread
|
|
239
256
|
deleteThread = delete_thread
|
|
257
|
+
registerPrivateTools = register_private_tools
|
|
240
258
|
startRun = start_run
|
|
241
259
|
submitCommand = submit_command
|
|
242
260
|
openEvents = open_events
|
agentos_sdk/clients/modelkit.py
CHANGED
|
@@ -167,10 +167,17 @@ class ModelKitClient:
|
|
|
167
167
|
) -> dict[str, Any]:
|
|
168
168
|
"""Register (or replace) an app model (``POST /modelkit/app-models``).
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
170
|
+
The gateway generates the model id from the app's bundle ID and the
|
|
171
|
+
model ``name`` and returns it as ``id``; store it to maintain the model
|
|
172
|
+
and as the ``model`` of requests. Registering a ``name`` the app already
|
|
173
|
+
registered replaces that model and returns the same id (``updated`` is
|
|
174
|
+
true).
|
|
175
|
+
|
|
176
|
+
Raises ``ApiError`` with status 401 (missing/invalid token), 403
|
|
177
|
+
(``appBundleId`` mismatch), 409 (the id derived from ``name`` is still
|
|
178
|
+
held by a renamed model of the same app) or 400 (invalid body, missing
|
|
179
|
+
``name``, unknown ``task``, or a bundle ID outside ``[A-Za-z0-9._-]`` or
|
|
180
|
+
over 128 characters).
|
|
174
181
|
"""
|
|
175
182
|
return await self.api_client.request(
|
|
176
183
|
"/modelkit/app-models",
|
|
@@ -182,7 +189,13 @@ class ModelKitClient:
|
|
|
182
189
|
async def update_app_model(
|
|
183
190
|
self, bearer_token: str, model_id: str, request: Mapping[str, Any]
|
|
184
191
|
) -> dict[str, Any]:
|
|
185
|
-
"""Partially update an owned app model (``PUT /modelkit/app-models/<id>``).
|
|
192
|
+
"""Partially update an owned app model (``PUT /modelkit/app-models/<id>``).
|
|
193
|
+
|
|
194
|
+
``model_id`` is the id returned by ``register_app_model``, looked up only
|
|
195
|
+
among the calling app's models; an unknown id is a 404. Renaming the
|
|
196
|
+
model keeps its id; a ``name`` already used by another model of the app
|
|
197
|
+
is a 409.
|
|
198
|
+
"""
|
|
186
199
|
return await self.api_client.request(
|
|
187
200
|
_app_model_path(model_id),
|
|
188
201
|
method="PUT",
|
|
@@ -55,94 +55,9 @@ class TransferKitClient:
|
|
|
55
55
|
data={},
|
|
56
56
|
)
|
|
57
57
|
|
|
58
|
-
async def respond(
|
|
59
|
-
self, bearer_token: str, transfer_id: str, request: Mapping[str, Any]
|
|
60
|
-
) -> dict[str, Any]:
|
|
61
|
-
return await self.api_client.request(
|
|
62
|
-
f"/transferkit/transfers/{transfer_id}/respond",
|
|
63
|
-
method="POST",
|
|
64
|
-
headers=_auth(bearer_token),
|
|
65
|
-
data=dict(request),
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
async def receive_stream(
|
|
69
|
-
self, bearer_token: str
|
|
70
|
-
) -> AsyncGenerator[dict[str, Any], None]:
|
|
71
|
-
response = await self.api_client.request_stream(
|
|
72
|
-
"/transferkit/receive/stream",
|
|
73
|
-
headers=_auth(bearer_token),
|
|
74
|
-
)
|
|
75
|
-
async for event in iter_sse(response):
|
|
76
|
-
if event.data:
|
|
77
|
-
yield json.loads(event.data)
|
|
78
|
-
|
|
79
|
-
async def set_policy(
|
|
80
|
-
self, bearer_token: str, request: Mapping[str, Any]
|
|
81
|
-
) -> dict[str, Any]:
|
|
82
|
-
return await self.api_client.request(
|
|
83
|
-
"/transferkit/receive/policy",
|
|
84
|
-
method="PUT",
|
|
85
|
-
headers=_auth(bearer_token),
|
|
86
|
-
data=dict(request),
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
async def get_policy(self, bearer_token: str) -> dict[str, Any]:
|
|
90
|
-
return await self.api_client.request(
|
|
91
|
-
"/transferkit/receive/policy",
|
|
92
|
-
headers=_auth(bearer_token),
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
async def get_history(
|
|
96
|
-
self,
|
|
97
|
-
bearer_token: str,
|
|
98
|
-
*,
|
|
99
|
-
device_id: str | None = None,
|
|
100
|
-
user_id: str | None = None,
|
|
101
|
-
) -> list[dict[str, Any]]:
|
|
102
|
-
return await self.api_client.request(
|
|
103
|
-
"/transferkit/history",
|
|
104
|
-
query={"deviceId": device_id, "userId": user_id},
|
|
105
|
-
headers=_auth(bearer_token),
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
async def delete_history(
|
|
109
|
-
self,
|
|
110
|
-
bearer_token: str,
|
|
111
|
-
record_id: str,
|
|
112
|
-
*,
|
|
113
|
-
device_id: str | None = None,
|
|
114
|
-
user_id: str | None = None,
|
|
115
|
-
) -> dict[str, Any]:
|
|
116
|
-
return await self.api_client.request(
|
|
117
|
-
f"/transferkit/history/{record_id}",
|
|
118
|
-
method="DELETE",
|
|
119
|
-
query={"deviceId": device_id, "userId": user_id},
|
|
120
|
-
headers=_auth(bearer_token),
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
async def clear_history(
|
|
124
|
-
self,
|
|
125
|
-
bearer_token: str,
|
|
126
|
-
*,
|
|
127
|
-
device_id: str | None = None,
|
|
128
|
-
user_id: str | None = None,
|
|
129
|
-
) -> dict[str, Any]:
|
|
130
|
-
return await self.api_client.request(
|
|
131
|
-
"/transferkit/history",
|
|
132
|
-
method="DELETE",
|
|
133
|
-
query={"deviceId": device_id, "userId": user_id},
|
|
134
|
-
headers=_auth(bearer_token),
|
|
135
|
-
)
|
|
136
|
-
|
|
137
58
|
listTransfers = list_transfers
|
|
138
59
|
getStatus = get_status
|
|
139
60
|
streamProgress = stream_progress
|
|
140
|
-
receiveStream = receive_stream
|
|
141
|
-
setPolicy = set_policy
|
|
142
|
-
getPolicy = get_policy
|
|
143
|
-
getHistory = get_history
|
|
144
|
-
deleteHistory = delete_history
|
|
145
|
-
clearHistory = clear_history
|
|
146
61
|
|
|
147
62
|
|
|
148
63
|
def _auth(token: str) -> dict[str, str]:
|
agentos_sdk/normalizers.py
CHANGED
|
@@ -96,6 +96,9 @@ def normalize_agent_event_name(event_type: str) -> str:
|
|
|
96
96
|
|
|
97
97
|
MODEL_TASKS = {"chat", "embedding", "asr", "tts", "decision"}
|
|
98
98
|
MODALITIES = {"text", "image", "audio", "video", "decisions"}
|
|
99
|
+
MODEL_SOURCES = {"local", "platform", "custom", "app"}
|
|
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"}
|
|
99
102
|
|
|
100
103
|
|
|
101
104
|
def _model_task(value: Any) -> str:
|
|
@@ -103,9 +106,33 @@ def _model_task(value: Any) -> str:
|
|
|
103
106
|
return task if task in MODEL_TASKS else "chat"
|
|
104
107
|
|
|
105
108
|
|
|
109
|
+
def _model_source(
|
|
110
|
+
value: Any, *, is_remote: bool, is_custom: bool, is_app_model: bool
|
|
111
|
+
) -> str:
|
|
112
|
+
"""Return the model's mutually exclusive origin.
|
|
113
|
+
|
|
114
|
+
The gateway's ``source`` wins. When it is missing or unknown (older
|
|
115
|
+
gateways), derive it from the legacy flags with the gateway's rules: an app
|
|
116
|
+
model is always ``app``; otherwise a non-remote model is ``local``, a remote
|
|
117
|
+
custom model is ``custom`` and any other remote model is ``platform``.
|
|
118
|
+
"""
|
|
119
|
+
if value is not None:
|
|
120
|
+
parsed = str(value).strip().lower()
|
|
121
|
+
if parsed in MODEL_SOURCES:
|
|
122
|
+
return parsed
|
|
123
|
+
if is_app_model:
|
|
124
|
+
return "app"
|
|
125
|
+
if not is_remote:
|
|
126
|
+
return "local"
|
|
127
|
+
return "custom" if is_custom else "platform"
|
|
128
|
+
|
|
129
|
+
|
|
106
130
|
def normalize_model_info(item: Mapping[str, Any]) -> dict[str, Any]:
|
|
107
131
|
task = _model_task(item.get("task", item.get("type", "")))
|
|
108
132
|
raw_caps = item.get("capabilities") if isinstance(item.get("capabilities"), dict) else {}
|
|
133
|
+
is_remote = bool(item.get("isRemote", False))
|
|
134
|
+
is_custom = bool(item.get("isCustom", False))
|
|
135
|
+
is_app_model = bool(item.get("isAppModel", False))
|
|
109
136
|
result: dict[str, Any] = {
|
|
110
137
|
"id": str(item.get("id", "")),
|
|
111
138
|
"name": str(item.get("name", "")),
|
|
@@ -121,12 +148,33 @@ def normalize_model_info(item: Mapping[str, Any]) -> dict[str, Any]:
|
|
|
121
148
|
"stream": bool(raw_caps.get("stream", True)),
|
|
122
149
|
"reasoning": bool(raw_caps.get("reasoning", False)),
|
|
123
150
|
},
|
|
124
|
-
"isRemote":
|
|
125
|
-
"isCustom":
|
|
126
|
-
"
|
|
151
|
+
"isRemote": is_remote,
|
|
152
|
+
"isCustom": is_custom,
|
|
153
|
+
"source": _model_source(
|
|
154
|
+
item.get("source"),
|
|
155
|
+
is_remote=is_remote,
|
|
156
|
+
is_custom=is_custom,
|
|
157
|
+
is_app_model=is_app_model,
|
|
158
|
+
),
|
|
159
|
+
"isAppModel": is_app_model,
|
|
127
160
|
}
|
|
161
|
+
if item.get("maxOutputTokens") is not None:
|
|
162
|
+
result["maxOutputTokens"] = item["maxOutputTokens"]
|
|
128
163
|
if item.get("appBundleId") is not None:
|
|
129
164
|
result["appBundleId"] = str(item["appBundleId"])
|
|
165
|
+
# 网关没有给出(或为空白)的 appName 不臆造,调用方可回退到 appBundleId。
|
|
166
|
+
app_name = str(item["appName"]).strip() if item.get("appName") is not None else ""
|
|
167
|
+
if app_name:
|
|
168
|
+
result["appName"] = app_name
|
|
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"):
|
|
175
|
+
value = str(item[key]).strip() if item.get(key) is not None else ""
|
|
176
|
+
if value:
|
|
177
|
+
result[key] = value
|
|
130
178
|
return result
|
|
131
179
|
|
|
132
180
|
|
|
@@ -155,6 +203,8 @@ def normalize_app_model(item: Mapping[str, Any]) -> dict[str, Any]:
|
|
|
155
203
|
result["baseUrl"] = str(item["baseUrl"])
|
|
156
204
|
if item.get("contextWindowSize") is not None:
|
|
157
205
|
result["contextWindowSize"] = item["contextWindowSize"]
|
|
206
|
+
if item.get("maxOutputTokens") is not None:
|
|
207
|
+
result["maxOutputTokens"] = item["maxOutputTokens"]
|
|
158
208
|
return result
|
|
159
209
|
|
|
160
210
|
|
agentos_sdk/protocol.py
CHANGED
|
@@ -8,6 +8,10 @@ JsonMap = dict[str, Any]
|
|
|
8
8
|
ContentType = Literal["text", "imageUrl"]
|
|
9
9
|
ModelTask = Literal["chat", "embedding", "asr", "tts", "decision"]
|
|
10
10
|
Modality = Literal["text", "image", "audio", "video", "decisions"]
|
|
11
|
+
# 模型互斥的来源,对应网关 ``/modelkit/models`` 的 ``source`` 字段。
|
|
12
|
+
ModelSource = Literal["local", "platform", "custom", "app"]
|
|
13
|
+
# 系统模型的计费类型,对应网关 ``/modelkit/models`` 的 ``billingType`` 字段,取值与服务端模型列表一致。
|
|
14
|
+
ModelBillingType = Literal["free", "in plan", "pay as you go", "benefit card"]
|
|
11
15
|
ToolContentState = Literal["unknown", "current", "updatePending", "broken"]
|
|
12
16
|
OpenToolRegistrationStatusValue = Literal["running", "starting", "notFound"]
|
|
13
17
|
HistoryTurnStatusValue = Literal["running", "done", "error", "stopped"]
|
|
@@ -304,6 +308,12 @@ class AppModel(TypedDict):
|
|
|
304
308
|
"""A model registered by a third-party app (``GET /modelkit/app-models``).
|
|
305
309
|
|
|
306
310
|
The API key is never returned; ``hasApiKey`` only tells whether one is stored.
|
|
311
|
+
|
|
312
|
+
``id`` is the model ID: a 12-character hashid the gateway generated from
|
|
313
|
+
``appBundleId + name`` when the app registered the model. It is identical to
|
|
314
|
+
the model's ``id`` in ``list_models()``. Use it for ``update_app_model`` /
|
|
315
|
+
``unregister_app_model`` / ``toggle_app_model`` and as the ``model`` of
|
|
316
|
+
requests to route to exactly this model.
|
|
307
317
|
"""
|
|
308
318
|
|
|
309
319
|
id: str
|
|
@@ -318,6 +328,8 @@ class AppModel(TypedDict):
|
|
|
318
328
|
baseUrl: NotRequired[str]
|
|
319
329
|
hasApiKey: bool
|
|
320
330
|
contextWindowSize: NotRequired[int]
|
|
331
|
+
# Maximum number of tokens the model can generate in one response.
|
|
332
|
+
maxOutputTokens: NotRequired[int]
|
|
321
333
|
isDisabled: bool
|
|
322
334
|
appBundleId: str
|
|
323
335
|
appName: str
|
|
@@ -326,11 +338,15 @@ class AppModel(TypedDict):
|
|
|
326
338
|
class AppModelRegistration(TypedDict):
|
|
327
339
|
"""Request body of ``register_app_model``.
|
|
328
340
|
|
|
329
|
-
Only ``
|
|
330
|
-
|
|
341
|
+
Only ``name`` is required; unset fields are omitted so the server applies
|
|
342
|
+
its own defaults. The model id is not part of the request: the gateway
|
|
343
|
+
generates it and returns it in ``AppModelWriteResult.id``.
|
|
344
|
+
|
|
345
|
+
``name`` is unique among the models of this app. The gateway derives the
|
|
346
|
+
model id from ``appBundleId + name``, so registering the same name again
|
|
347
|
+
replaces the model and returns the same id.
|
|
331
348
|
"""
|
|
332
349
|
|
|
333
|
-
id: str
|
|
334
350
|
name: str
|
|
335
351
|
alias: NotRequired[str]
|
|
336
352
|
description: NotRequired[str]
|
|
@@ -342,6 +358,8 @@ class AppModelRegistration(TypedDict):
|
|
|
342
358
|
baseUrl: NotRequired[str]
|
|
343
359
|
apiKey: NotRequired[str]
|
|
344
360
|
contextWindowSize: NotRequired[int]
|
|
361
|
+
# Maximum number of tokens the model can generate in one response.
|
|
362
|
+
maxOutputTokens: NotRequired[int]
|
|
345
363
|
appBundleId: NotRequired[str]
|
|
346
364
|
appName: NotRequired[str]
|
|
347
365
|
|
|
@@ -366,6 +384,7 @@ class AppModelUpdate(TypedDict, total=False):
|
|
|
366
384
|
baseUrl: str
|
|
367
385
|
apiKey: str
|
|
368
386
|
contextWindowSize: int
|
|
387
|
+
maxOutputTokens: int
|
|
369
388
|
appName: str
|
|
370
389
|
|
|
371
390
|
|
|
@@ -373,6 +392,10 @@ class AppModelWriteResult(TypedDict):
|
|
|
373
392
|
"""Result of an app-model write call (register / update / unregister / toggle)."""
|
|
374
393
|
|
|
375
394
|
success: bool
|
|
395
|
+
# The model id generated by the gateway; returned by register only. Store
|
|
396
|
+
# it: it maintains the model (``update_app_model`` / ``unregister_app_model``
|
|
397
|
+
# / ``toggle_app_model``) and is the ``model`` of requests that route to
|
|
398
|
+
# exactly this model.
|
|
376
399
|
id: NotRequired[str]
|
|
377
400
|
updated: NotRequired[bool]
|
|
378
401
|
|
|
@@ -391,8 +414,7 @@ class HarnessKitHealth(TypedDict):
|
|
|
391
414
|
class HarnessKitRuntimeInfo(TypedDict):
|
|
392
415
|
"""Response of ``GET /harnesskit/v1/runtime/harness-engine``.
|
|
393
416
|
|
|
394
|
-
``status`` is ``starting``, ``ready`` or ``switching``.
|
|
395
|
-
Harness App may read or change the runtime engine.
|
|
417
|
+
``status`` is ``starting``, ``ready`` or ``switching``.
|
|
396
418
|
"""
|
|
397
419
|
|
|
398
420
|
status: str
|
|
@@ -451,6 +473,22 @@ class HarnessKitThreadDeleteResult(TypedDict):
|
|
|
451
473
|
threadId: str
|
|
452
474
|
|
|
453
475
|
|
|
476
|
+
class HarnessKitPrivateToolsRegistration(TypedDict):
|
|
477
|
+
"""Local callback and OpenTool specification to register for a thread.
|
|
478
|
+
|
|
479
|
+
``token`` authenticates requests to the callback service and is separate
|
|
480
|
+
from the AppKit token used to call HarnessKit.
|
|
481
|
+
"""
|
|
482
|
+
|
|
483
|
+
endpoint: str
|
|
484
|
+
token: str
|
|
485
|
+
specification: dict[str, Any]
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
class HarnessKitPrivateToolsRegistrationResult(TypedDict):
|
|
489
|
+
toolId: str
|
|
490
|
+
|
|
491
|
+
|
|
454
492
|
class HarnessKitLlmConfig(TypedDict):
|
|
455
493
|
"""Model configuration of a run. Only ``model`` is required.
|
|
456
494
|
|
|
@@ -473,17 +511,31 @@ class HarnessKitLlmConfig(TypedDict):
|
|
|
473
511
|
supportsReasoning: NotRequired[bool]
|
|
474
512
|
|
|
475
513
|
|
|
514
|
+
class HarnessKitToolPolicy(TypedDict):
|
|
515
|
+
"""Tool visibility and approval rules for a run or turn.
|
|
516
|
+
|
|
517
|
+
A null or absent ``allowedToolIds`` leaves tools unrestricted; an empty
|
|
518
|
+
list allows no tools. Denied tools take precedence over allowed tools.
|
|
519
|
+
"""
|
|
520
|
+
|
|
521
|
+
allowedToolIds: NotRequired[list[str] | None]
|
|
522
|
+
deniedToolIds: NotRequired[list[str]]
|
|
523
|
+
approvalMode: NotRequired[str]
|
|
524
|
+
requireApprovalForSideEffects: NotRequired[bool]
|
|
525
|
+
|
|
526
|
+
|
|
476
527
|
class HarnessKitRunRequest(TypedDict):
|
|
477
528
|
"""Request body of ``start_run``.
|
|
478
529
|
|
|
479
530
|
The minimum useful fields are ``requestId``, ``goal`` and ``llmConfig.model``.
|
|
480
|
-
Newer Harness fields (``
|
|
531
|
+
Newer Harness fields (``limits``, ``plan``, ...) are passed
|
|
481
532
|
through at runtime even though they are not declared here.
|
|
482
533
|
"""
|
|
483
534
|
|
|
484
535
|
requestId: str
|
|
485
536
|
goal: str
|
|
486
537
|
llmConfig: HarnessKitLlmConfig
|
|
538
|
+
toolPolicy: NotRequired[HarnessKitToolPolicy | None]
|
|
487
539
|
actorId: NotRequired[str]
|
|
488
540
|
messages: NotRequired[list[HarnessKitThreadMessage]]
|
|
489
541
|
context: NotRequired[dict[str, Any]]
|
|
@@ -509,6 +561,7 @@ class HarnessKitCommand(TypedDict):
|
|
|
509
561
|
type: str
|
|
510
562
|
commandId: str
|
|
511
563
|
threadId: NotRequired[str]
|
|
564
|
+
toolPolicy: NotRequired[HarnessKitToolPolicy | None]
|
|
512
565
|
|
|
513
566
|
|
|
514
567
|
class HarnessKitCommandReceipt(TypedDict):
|
agentos_sdk/sdk.py
CHANGED
|
@@ -39,6 +39,7 @@ from agentos_sdk.protocol import (
|
|
|
39
39
|
HarnessKitEvent,
|
|
40
40
|
HarnessKitHealth,
|
|
41
41
|
HarnessKitOperationalSnapshot,
|
|
42
|
+
HarnessKitPrivateToolsRegistrationResult,
|
|
42
43
|
HarnessKitRunAccepted,
|
|
43
44
|
HarnessKitRunResult,
|
|
44
45
|
HarnessKitRuntimeInfo,
|
|
@@ -186,6 +187,13 @@ class AgentOSSDK:
|
|
|
186
187
|
return info["token"]
|
|
187
188
|
|
|
188
189
|
def _should_recover_app_auth(self, error: Exception) -> bool:
|
|
190
|
+
if isinstance(error, ApiError) and error.status == 403 and isinstance(error.data, Mapping):
|
|
191
|
+
details = error.data.get("error")
|
|
192
|
+
if (
|
|
193
|
+
isinstance(details, Mapping)
|
|
194
|
+
and details.get("code") == "harness_host_access_forbidden"
|
|
195
|
+
):
|
|
196
|
+
return False
|
|
189
197
|
if isinstance(error, ApiError) and error.status in {401, 403}:
|
|
190
198
|
return True
|
|
191
199
|
text = _collect_error_text(error).lower()
|
|
@@ -835,16 +843,6 @@ class DiscoveryKitModule:
|
|
|
835
843
|
lambda token: self._sdk.discoveryKit.get_self(token)
|
|
836
844
|
)
|
|
837
845
|
|
|
838
|
-
async def register(self, request: Mapping[str, Any] | None = None) -> dict[str, Any]:
|
|
839
|
-
return await self._sdk._with_app_auth_retry(
|
|
840
|
-
lambda token: self._sdk.discoveryKit.register(token, request)
|
|
841
|
-
)
|
|
842
|
-
|
|
843
|
-
async def unregister(self) -> dict[str, Any]:
|
|
844
|
-
return await self._sdk._with_app_auth_retry(
|
|
845
|
-
lambda token: self._sdk.discoveryKit.unregister(token)
|
|
846
|
-
)
|
|
847
|
-
|
|
848
846
|
getPeers = get_peers
|
|
849
847
|
streamPeers = stream_peers
|
|
850
848
|
getSelf = get_self
|
|
@@ -881,68 +879,9 @@ class TransferKitModule:
|
|
|
881
879
|
lambda token: self._sdk.transferKit.cancel(token, transfer_id)
|
|
882
880
|
)
|
|
883
881
|
|
|
884
|
-
async def respond(
|
|
885
|
-
self, *, transfer_id: str, request: Mapping[str, Any]
|
|
886
|
-
) -> dict[str, Any]:
|
|
887
|
-
return await self._sdk._with_app_auth_retry(
|
|
888
|
-
lambda token: self._sdk.transferKit.respond(token, transfer_id, request)
|
|
889
|
-
)
|
|
890
|
-
|
|
891
|
-
async def receive_stream(self) -> AsyncGenerator[dict[str, Any], None]:
|
|
892
|
-
context = await self._sdk._require_auth_context()
|
|
893
|
-
async for event in self._sdk.transferKit.receive_stream(context.token):
|
|
894
|
-
yield event
|
|
895
|
-
|
|
896
|
-
async def set_policy(self, *, request: Mapping[str, Any]) -> dict[str, Any]:
|
|
897
|
-
return await self._sdk._with_app_auth_retry(
|
|
898
|
-
lambda token: self._sdk.transferKit.set_policy(token, request)
|
|
899
|
-
)
|
|
900
|
-
|
|
901
|
-
async def get_policy(self) -> dict[str, Any]:
|
|
902
|
-
return await self._sdk._with_app_auth_retry(
|
|
903
|
-
lambda token: self._sdk.transferKit.get_policy(token)
|
|
904
|
-
)
|
|
905
|
-
|
|
906
|
-
async def get_history(
|
|
907
|
-
self, *, device_id: str | None = None, user_id: str | None = None
|
|
908
|
-
) -> list[dict[str, Any]]:
|
|
909
|
-
return await self._sdk._with_app_auth_retry(
|
|
910
|
-
lambda token: self._sdk.transferKit.get_history(
|
|
911
|
-
token, device_id=device_id, user_id=user_id
|
|
912
|
-
)
|
|
913
|
-
)
|
|
914
|
-
|
|
915
|
-
async def delete_history(
|
|
916
|
-
self,
|
|
917
|
-
*,
|
|
918
|
-
record_id: str,
|
|
919
|
-
device_id: str | None = None,
|
|
920
|
-
user_id: str | None = None,
|
|
921
|
-
) -> dict[str, Any]:
|
|
922
|
-
return await self._sdk._with_app_auth_retry(
|
|
923
|
-
lambda token: self._sdk.transferKit.delete_history(
|
|
924
|
-
token, record_id, device_id=device_id, user_id=user_id
|
|
925
|
-
)
|
|
926
|
-
)
|
|
927
|
-
|
|
928
|
-
async def clear_history(
|
|
929
|
-
self, *, device_id: str | None = None, user_id: str | None = None
|
|
930
|
-
) -> dict[str, Any]:
|
|
931
|
-
return await self._sdk._with_app_auth_retry(
|
|
932
|
-
lambda token: self._sdk.transferKit.clear_history(
|
|
933
|
-
token, device_id=device_id, user_id=user_id
|
|
934
|
-
)
|
|
935
|
-
)
|
|
936
|
-
|
|
937
882
|
listTransfers = list_transfers
|
|
938
883
|
getStatus = get_status
|
|
939
884
|
streamProgress = stream_progress
|
|
940
|
-
receiveStream = receive_stream
|
|
941
|
-
setPolicy = set_policy
|
|
942
|
-
getPolicy = get_policy
|
|
943
|
-
getHistory = get_history
|
|
944
|
-
deleteHistory = delete_history
|
|
945
|
-
clearHistory = clear_history
|
|
946
885
|
|
|
947
886
|
|
|
948
887
|
class HarnessKitModule:
|
|
@@ -950,10 +889,10 @@ class HarnessKitModule:
|
|
|
950
889
|
|
|
951
890
|
Call ``agentos.register_bundle()`` first. Every method uses the active app
|
|
952
891
|
token and, after an authentication failure, re-registers the bundle once and
|
|
953
|
-
retries.
|
|
954
|
-
|
|
955
|
-
``get_operational_snapshot`` are reserved for the built-in Harness App;
|
|
956
|
-
Apps get an ``ApiError`` with status 403.
|
|
892
|
+
retries. The Gateway normally routes Apps to a shared Harness runtime and
|
|
893
|
+
scopes their data by bundle ID. ``switch_engine`` and
|
|
894
|
+
``get_operational_snapshot`` are reserved for the built-in Harness App;
|
|
895
|
+
other Apps get an ``ApiError`` with status 403.
|
|
957
896
|
"""
|
|
958
897
|
|
|
959
898
|
def __init__(self, sdk: AgentOSSDK) -> None:
|
|
@@ -1003,6 +942,20 @@ class HarnessKitModule:
|
|
|
1003
942
|
lambda token: self._sdk.harnessKit.delete_thread(token, thread_id)
|
|
1004
943
|
)
|
|
1005
944
|
|
|
945
|
+
async def register_private_tools(
|
|
946
|
+
self, *, thread_id: str, registration: Mapping[str, Any]
|
|
947
|
+
) -> HarnessKitPrivateToolsRegistrationResult:
|
|
948
|
+
"""Register or replace a local App's OpenTool callbacks for a thread.
|
|
949
|
+
|
|
950
|
+
The callback token in ``registration`` is separate from the AppKit token.
|
|
951
|
+
The Gateway requires a direct local connection from an external App.
|
|
952
|
+
"""
|
|
953
|
+
return await self._sdk._with_app_auth_retry(
|
|
954
|
+
lambda token: self._sdk.harnessKit.register_private_tools(
|
|
955
|
+
token, thread_id, registration
|
|
956
|
+
)
|
|
957
|
+
)
|
|
958
|
+
|
|
1006
959
|
async def start_run(
|
|
1007
960
|
self, *, thread_id: str, request: Mapping[str, Any]
|
|
1008
961
|
) -> HarnessKitRunAccepted:
|
|
@@ -1099,6 +1052,7 @@ class HarnessKitModule:
|
|
|
1099
1052
|
getThread = get_thread
|
|
1100
1053
|
renameThread = rename_thread
|
|
1101
1054
|
deleteThread = delete_thread
|
|
1055
|
+
registerPrivateTools = register_private_tools
|
|
1102
1056
|
startRun = start_run
|
|
1103
1057
|
submitCommand = submit_command
|
|
1104
1058
|
getRunResult = get_run_result
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agentos-sdk-python
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.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
|
|
@@ -255,6 +255,63 @@ Normalized model capabilities include `vision`, `tool_call`, `stream`, and
|
|
|
255
255
|
`reasoning` booleans. `reasoning` reflects only the server-provided
|
|
256
256
|
`capabilities.reasoning` value and defaults to `False` when omitted.
|
|
257
257
|
|
|
258
|
+
Every model also carries `source`, the mutually exclusive origin of the model
|
|
259
|
+
(`ModelSource`). Group and label models by it instead of combining `isRemote` /
|
|
260
|
+
`isCustom` / `isAppModel`:
|
|
261
|
+
|
|
262
|
+
| `source` | Meaning | Suggested group |
|
|
263
|
+
| --- | --- | --- |
|
|
264
|
+
| `"local"` | Runs on this device | Local Models |
|
|
265
|
+
| `"platform"` | Remote model provided by the AgentOS platform | Platform Models, plus `Remote · System · {cardName}` for each benefit card (see below) |
|
|
266
|
+
| `"custom"` | Remote model configured by the user | Custom Models |
|
|
267
|
+
| `"app"` | Registered by a third-party app | `App · {appName}` (one group per app) |
|
|
268
|
+
|
|
269
|
+
```python
|
|
270
|
+
groups: dict[str, list[dict]] = {}
|
|
271
|
+
for model in await sdk.modelkit.list_models():
|
|
272
|
+
if model["source"] == "app":
|
|
273
|
+
title = f"App · {model.get('appName') or model.get('appBundleId')}"
|
|
274
|
+
else:
|
|
275
|
+
title = model["source"]
|
|
276
|
+
groups.setdefault(title, []).append(model)
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
App models additionally report `appBundleId` and `appName` (the human-readable
|
|
280
|
+
app name, for group titles; `appName` is only present when the gateway reports
|
|
281
|
+
one, so fall back to `appBundleId`). Against gateways that predate `source`, or
|
|
282
|
+
when it holds an unknown value, `source` is derived from the legacy flags with
|
|
283
|
+
the gateway's rules.
|
|
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
|
+
|
|
291
|
+
Models served through a benefit card keep `source` `"platform"` and their plain
|
|
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:
|
|
296
|
+
|
|
297
|
+
```python
|
|
298
|
+
def system_group_title(model: dict) -> str:
|
|
299
|
+
if model.get("billingType") == "benefit card":
|
|
300
|
+
return f"Remote · System · {model.get('cardName') or 'Benefit card'}"
|
|
301
|
+
return "Remote · System"
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
Model dicts also carry `contextWindowSize` and `maxOutputTokens` (the maximum
|
|
305
|
+
number of tokens the model can generate in one response); `maxOutputTokens` is
|
|
306
|
+
only present when the gateway reports it. Only chat models report
|
|
307
|
+
`maxOutputTokens` (embedding, ASR, TTS and decision models do not generate
|
|
308
|
+
text, so the key is absent for them); a chat model that reports
|
|
309
|
+
`contextWindowSize` reports `maxOutputTokens` too, using the same number when it
|
|
310
|
+
has no value of its own. Apps can set both when registering a model
|
|
311
|
+
(`register_app_model(request={"name": ..., "contextWindowSize": 32768,
|
|
312
|
+
"maxOutputTokens": 4096})`); app model records report them back, and
|
|
313
|
+
`update_app_model` can change them.
|
|
314
|
+
|
|
258
315
|
ModelKit also supports:
|
|
259
316
|
|
|
260
317
|
- `sdk.modelkit.embedding.create(...)`
|
|
@@ -316,44 +373,58 @@ and related `TypedDict` definitions for annotations.
|
|
|
316
373
|
### App models
|
|
317
374
|
|
|
318
375
|
Apps can register their own models into the gateway. Registered models show up
|
|
319
|
-
in `list_models()` / `list_models_by_task()` with `
|
|
320
|
-
owning `appBundleId`.
|
|
376
|
+
in `list_models()` / `list_models_by_task()` with `source: "app"`,
|
|
377
|
+
`isAppModel: True`, the owning `appBundleId` and its `appName`.
|
|
378
|
+
|
|
379
|
+
You do not choose the model id: the gateway generates a 12-character hashid from
|
|
380
|
+
your bundle ID and the model `name` and returns it when you register. That same
|
|
381
|
+
id is the model `id` in `list_models()` and `list_app_models()`. Store it: it
|
|
382
|
+
maintains the model (`update_app_model` / `toggle_app_model` /
|
|
383
|
+
`unregister_app_model`) and is the `model` of requests that must reach exactly
|
|
384
|
+
your model. A `name` is unique within your app; different apps may use the same
|
|
385
|
+
`name` and get different ids.
|
|
321
386
|
|
|
322
387
|
```python
|
|
323
388
|
async with AgentOSSDK() as sdk:
|
|
324
389
|
await sdk.agentos.register_bundle({"bundleId": "com.example.app"})
|
|
325
390
|
|
|
326
|
-
# Register (or replace) a model. Only "
|
|
391
|
+
# Register (or replace) a model. Only "name" is required.
|
|
327
392
|
result = await sdk.modelkit.register_app_model(
|
|
328
393
|
request={
|
|
329
|
-
"id": "my-router",
|
|
330
394
|
"name": "my-router",
|
|
331
395
|
"task": "decision",
|
|
332
396
|
"baseUrl": "http://127.0.0.1:9000",
|
|
333
397
|
"apiKey": "upstream-secret", # stored by the server, never returned
|
|
334
398
|
}
|
|
335
399
|
)
|
|
400
|
+
model_id = result["id"] # e.g. "6f78dcce6717": maintain the model with it, or use it as `model` in requests
|
|
336
401
|
print(result.get("updated")) # True when an existing model of this app was replaced
|
|
337
402
|
|
|
338
403
|
# Partial update: unset fields stay unchanged.
|
|
339
404
|
await sdk.modelkit.update_app_model(
|
|
340
|
-
model_id=
|
|
405
|
+
model_id=model_id, request={"description": "Routes support tickets"}
|
|
341
406
|
)
|
|
342
407
|
|
|
343
408
|
# Enable/disable without deleting.
|
|
344
|
-
await sdk.modelkit.toggle_app_model(model_id=
|
|
409
|
+
await sdk.modelkit.toggle_app_model(model_id=model_id)
|
|
345
410
|
|
|
346
411
|
# List every app-registered model (public, no token needed).
|
|
347
412
|
for model in await sdk.modelkit.list_app_models():
|
|
348
|
-
print(model["id"], model["
|
|
413
|
+
print(model["id"], model["isDisabled"])
|
|
349
414
|
|
|
350
|
-
await sdk.modelkit.unregister_app_model(model_id=
|
|
415
|
+
await sdk.modelkit.unregister_app_model(model_id=model_id)
|
|
351
416
|
```
|
|
352
417
|
|
|
353
418
|
Write calls attach the app token automatically and refresh it once on `401`.
|
|
354
419
|
They raise `ApiError` carrying the server status: `401` invalid token, `403`
|
|
355
|
-
|
|
356
|
-
|
|
420
|
+
`appBundleId` mismatch, `404` unknown id (`model_id` is looked up only among your
|
|
421
|
+
app's models), `409` the id derived from `name` is still held by a renamed model
|
|
422
|
+
of your app (or `update_app_model` renames a model to a `name` another model of
|
|
423
|
+
your app already uses), `400` invalid body, missing `name`, unknown `task`, or a
|
|
424
|
+
bundle ID outside the allowed characters or length.
|
|
425
|
+
|
|
426
|
+
Registering a `name` you already registered replaces that model and returns the
|
|
427
|
+
same id; renaming a model with `update_app_model` keeps its id.
|
|
357
428
|
|
|
358
429
|
Decision models are normalized by the server: input `text` (+ optional
|
|
359
430
|
`image`), output `decisions`, and `stream` / `tool_call` / `reasoning` all
|
|
@@ -463,26 +534,29 @@ async with AgentOSSDK() as sdk:
|
|
|
463
534
|
|
|
464
535
|
## DiscoveryKit
|
|
465
536
|
|
|
537
|
+
Device-level discovery of nearby AgentOS devices. Apps can query nearby devices
|
|
538
|
+
and the current device's info; they are never advertised to other devices.
|
|
539
|
+
|
|
466
540
|
```python
|
|
467
541
|
async with AgentOSSDK() as sdk:
|
|
468
542
|
await sdk.agentos.register_bundle({"bundleId": "com.demo.app"})
|
|
469
543
|
|
|
470
|
-
await sdk.discoverykit.register({"receivePolicy": "autoAccept"})
|
|
471
|
-
|
|
472
544
|
peers = await sdk.discoverykit.get_peers()
|
|
473
545
|
print(peers)
|
|
474
546
|
|
|
475
547
|
self_info = await sdk.discoverykit.get_self()
|
|
476
|
-
print(self_info["deviceName"], self_info["
|
|
548
|
+
print(self_info["deviceName"], self_info["nearbyTransferEnabled"])
|
|
477
549
|
|
|
478
550
|
async for event in sdk.discoverykit.stream_peers():
|
|
479
551
|
print(event["type"], event["device"]["name"])
|
|
480
|
-
|
|
481
|
-
await sdk.discoverykit.unregister()
|
|
482
552
|
```
|
|
483
553
|
|
|
484
554
|
## TransferKit
|
|
485
555
|
|
|
556
|
+
Sends files to a nearby AgentOS device. The receiving device handles the
|
|
557
|
+
incoming files in its built-in nearby transfer UI. Apps can send files and track
|
|
558
|
+
or cancel their own transfers.
|
|
559
|
+
|
|
486
560
|
```python
|
|
487
561
|
async with AgentOSSDK() as sdk:
|
|
488
562
|
await sdk.agentos.register_bundle({"bundleId": "com.demo.app"})
|
|
@@ -503,12 +577,6 @@ async with AgentOSSDK() as sdk:
|
|
|
503
577
|
transfer_id=session["transferId"]
|
|
504
578
|
):
|
|
505
579
|
print(progress["progress"])
|
|
506
|
-
|
|
507
|
-
await sdk.transferkit.set_policy(request={"policy": "autoAccept"})
|
|
508
|
-
policy = await sdk.transferkit.get_policy()
|
|
509
|
-
|
|
510
|
-
history = await sdk.transferkit.get_history()
|
|
511
|
-
await sdk.transferkit.clear_history()
|
|
512
580
|
```
|
|
513
581
|
|
|
514
582
|
`list_tool()` is typed as `list[ToolDto]` and exposes daemon 0.5 metadata. Its
|
|
@@ -518,12 +586,10 @@ optional `server` identity uses `namespace`, `name`, and `version`;
|
|
|
518
586
|
|
|
519
587
|
## HarnessKit
|
|
520
588
|
|
|
521
|
-
HarnessKit forwards requests through the Gateway to the
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
host's default runtime. All `sdk.harnesskit` methods use the active AppKit token
|
|
526
|
-
and retry once after an authentication failure.
|
|
589
|
+
HarnessKit forwards requests through the Gateway to the shared host runtime.
|
|
590
|
+
Register the app with `sdk.agentos.register_bundle()` first. The Gateway scopes
|
|
591
|
+
external Apps' threads, runs and events by their bundle ID. All `sdk.harnesskit`
|
|
592
|
+
methods use the active AppKit token and retry once after an authentication failure.
|
|
527
593
|
|
|
528
594
|
| Method | Parameters | Description |
|
|
529
595
|
| --- | --- | --- |
|
|
@@ -531,6 +597,7 @@ and retry once after an authentication failure.
|
|
|
531
597
|
| `get_runtime()` / `switch_engine(engine=...)` | `engine` | Reads the runtime engine or requests an engine switch. |
|
|
532
598
|
| `list_threads()` / `get_thread(thread_id=...)` | `thread_id` | Lists durable threads or reads one thread snapshot. |
|
|
533
599
|
| `rename_thread(thread_id=..., title=...)` / `delete_thread(thread_id=...)` | `thread_id`, `title` | Updates a thread title or deletes an idle thread. |
|
|
600
|
+
| `register_private_tools(thread_id=..., registration=...)` | `thread_id`, `HarnessKitPrivateToolsRegistration` | Registers or replaces a local App's OpenTool callbacks for a thread. |
|
|
534
601
|
| `start_run(thread_id=..., request=...)` | `thread_id`, run request | Starts a Harness run and returns its `runId`. |
|
|
535
602
|
| `submit_command(thread_id=..., command=...)` | `thread_id`, command | Submits work or control commands; rejected commands return their receipt. |
|
|
536
603
|
| `events(thread_id=..., after_sequence=0, run_id=None)` | `thread_id`, `after_sequence`, `run_id` | Opens a resumable SSE stream of typed events. |
|
|
@@ -596,10 +663,10 @@ through untouched; the exported `HarnessKit*` `TypedDict`s (for example
|
|
|
596
663
|
- A command the Harness rejects comes back as HTTP `400` with a receipt body.
|
|
597
664
|
`submit_command()` returns that receipt (`status == "rejected"`) instead of
|
|
598
665
|
raising; every other error raises `ApiError`.
|
|
599
|
-
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
666
|
+
- `switch_engine()` and `get_operational_snapshot()` are reserved for the
|
|
667
|
+
built-in Harness App. Other Apps receive an `ApiError` with status `403`.
|
|
668
|
+
`get_operational_snapshot()` also answers `501` when the configured engine
|
|
669
|
+
does not expose the optional reader.
|
|
603
670
|
- Thread and run IDs are percent-encoded. Empty IDs and `.` / `..` raise
|
|
604
671
|
`ValueError` before any request is sent.
|
|
605
672
|
- `request()` and `request_stream()` accept paths relative to the Harness API
|
|
@@ -608,6 +675,70 @@ through untouched; the exported `HarnessKit*` `TypedDict`s (for example
|
|
|
608
675
|
caller-supplied `authorization` header is replaced by the AppKit token. A query
|
|
609
676
|
string in `path` is kept; keys in `query` override the same keys there.
|
|
610
677
|
|
|
678
|
+
### Register private App tools
|
|
679
|
+
|
|
680
|
+
An external App can register OpenTool functions for its own thread over a direct
|
|
681
|
+
local connection to the Gateway. Start the App's HTTP callback service first and
|
|
682
|
+
use its UUID-shaped callback token in the registration. The callback token is
|
|
683
|
+
separate from the AppKit token used to authenticate the Gateway request.
|
|
684
|
+
|
|
685
|
+
```python
|
|
686
|
+
import uuid
|
|
687
|
+
|
|
688
|
+
from agentos_sdk import AgentOSSDK
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
async def run_with_app_tools(callback_token: str):
|
|
692
|
+
async with AgentOSSDK(base_url="http://127.0.0.1:8888") as sdk:
|
|
693
|
+
await sdk.agentos.register_bundle({"bundleId": "com.example.app"})
|
|
694
|
+
binding = await sdk.harnesskit.register_private_tools(
|
|
695
|
+
thread_id="research-thread",
|
|
696
|
+
registration={
|
|
697
|
+
"endpoint": "http://127.0.0.1:8123/",
|
|
698
|
+
"token": callback_token,
|
|
699
|
+
"specification": {
|
|
700
|
+
"opentool": "1.0.0",
|
|
701
|
+
"info": {"title": "App tools", "version": "1.0.0"},
|
|
702
|
+
"functions": [{
|
|
703
|
+
"name": "list_assets",
|
|
704
|
+
"description": "List the app assets",
|
|
705
|
+
"parameters": [],
|
|
706
|
+
"return": {"name": "result", "schema": {"type": "object"}},
|
|
707
|
+
}],
|
|
708
|
+
},
|
|
709
|
+
},
|
|
710
|
+
)
|
|
711
|
+
return await sdk.harnesskit.start_run(
|
|
712
|
+
thread_id="research-thread",
|
|
713
|
+
request={
|
|
714
|
+
"requestId": str(uuid.uuid4()),
|
|
715
|
+
"goal": "List the app assets",
|
|
716
|
+
"llmConfig": {"model": "your-model"},
|
|
717
|
+
"toolPolicy": {"allowedToolIds": [binding["toolId"]]},
|
|
718
|
+
},
|
|
719
|
+
)
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
The endpoint must be an `http://127.0.0.1:<port>/` root URL. The callback
|
|
723
|
+
service must accept `Authorization: Bearer <token>` and provide these routes.
|
|
724
|
+
|
|
725
|
+
- `GET /private-tools/opentool/version` returns HTTP `200` for health checks.
|
|
726
|
+
- `POST /private-tools/opentool/call` accepts JSON with `jsonrpc: "2.0.0"`,
|
|
727
|
+
`id`, `method` and `params`. Return HTTP `200` with the same `jsonrpc` and
|
|
728
|
+
`id`, plus a `result` or `error`.
|
|
729
|
+
- `POST /private-tools/opentool/streamCall` serves streaming functions as SSE
|
|
730
|
+
data events with the same JSON response format, followed by a `DONE` event.
|
|
731
|
+
|
|
732
|
+
The returned `toolId` identifies the thread's registered tools. Add it to
|
|
733
|
+
`toolPolicy.allowedToolIds` when using an allow-list. Omitting the allow-list or
|
|
734
|
+
setting it to `None` leaves tools unrestricted, while an empty list allows no
|
|
735
|
+
tools. A new registration replaces the thread's existing binding. Bindings are
|
|
736
|
+
removed when the thread is deleted or the callback repeatedly fails health
|
|
737
|
+
checks. Register again after a Harness restart or when a binding is removed.
|
|
738
|
+
The Gateway rejects remote registrations and registrations from the built-in
|
|
739
|
+
Harness App with HTTP `403` and `harness_host_access_forbidden`. That error does
|
|
740
|
+
not trigger an AppKit token refresh.
|
|
741
|
+
|
|
611
742
|
## NotifyKit
|
|
612
743
|
|
|
613
744
|
NotifyKit lets an App submit user-facing events to the AgentOS notification
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
agentos_sdk/__init__.py,sha256
|
|
1
|
+
agentos_sdk/__init__.py,sha256=MDJAptD0tCknYk1HYeHKLtrrw3MnI8EVEp2qQoShlUo,3741
|
|
2
2
|
agentos_sdk/handlers.py,sha256=0LVT-IQlu-bNbRRxMp4Ei3nMwT1OuQcuvsF4cDQKYTM,3435
|
|
3
|
-
agentos_sdk/normalizers.py,sha256=
|
|
4
|
-
agentos_sdk/protocol.py,sha256=
|
|
3
|
+
agentos_sdk/normalizers.py,sha256=2vXefTdVPmhu2najeCmpAo17YrLBq4-4Y7ATt9ZaDmg,8308
|
|
4
|
+
agentos_sdk/protocol.py,sha256=Tq2YBqeYbvj-6lpY_AkeZGxgkZYHZJ36lH_fc33x0lw,18290
|
|
5
5
|
agentos_sdk/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
6
|
-
agentos_sdk/sdk.py,sha256=
|
|
6
|
+
agentos_sdk/sdk.py,sha256=8Tw9X9LtU7o1HBhG2DIaEFJZV8jyhMFAMnjlHkoo2e0,41157
|
|
7
7
|
agentos_sdk/transport.py,sha256=MHUOdejTmTzJuS1TXYK4J5wd-LORyg54Q4FAfF3bm3w,6995
|
|
8
8
|
agentos_sdk/clients/__init__.py,sha256=rhutJ_h6C8omVjul-Z-JVS1xjf-Utfq295HGk2_SV2s,682
|
|
9
9
|
agentos_sdk/clients/agentkit.py,sha256=D83yaccY2W1ZgHb-XDTlAoqzSlx5Y47x2iVoFgdOZog,5991
|
|
10
10
|
agentos_sdk/clients/appkit.py,sha256=4j5VRuxiX88y7y2rlVQoJCRUxj2pKox9Tvt9zhBoCls,867
|
|
11
11
|
agentos_sdk/clients/authkit.py,sha256=9TYDwQUxO9HDS7qrTUMnSerlP2p-LCda3zmcLaA5UDg,1849
|
|
12
12
|
agentos_sdk/clients/cronkit.py,sha256=DiprjNhV3VEXXY5i15Ghgj5WgjHeoVfIEqs2zhuTRcY,4858
|
|
13
|
-
agentos_sdk/clients/discoverykit.py,sha256=
|
|
14
|
-
agentos_sdk/clients/harnesskit.py,sha256=
|
|
15
|
-
agentos_sdk/clients/modelkit.py,sha256=
|
|
13
|
+
agentos_sdk/clients/discoverykit.py,sha256=KdkkCC_BNNbnqNfHBxe0UPuwMOHq7zyqZYNoOvm_nHk,1245
|
|
14
|
+
agentos_sdk/clients/harnesskit.py,sha256=Mp01B9ifyj9E4AE5DcugkDS6apM8xj9Cx5X2vOQTux8,15265
|
|
15
|
+
agentos_sdk/clients/modelkit.py,sha256=ELy3-4_vS5RrKiMvE9sfOum6eNIPU49lafwP1s1Rv5Y,8838
|
|
16
16
|
agentos_sdk/clients/notifykit.py,sha256=YClS7r4TsndTLceAXD_EG-ZPr2E3_xd5r5pSzseTvGI,1795
|
|
17
17
|
agentos_sdk/clients/systemkit.py,sha256=1afOdJ_SUuMLP6b28FG2E2POf9OZisNHHBcm8YW0b6s,641
|
|
18
18
|
agentos_sdk/clients/toolkit.py,sha256=wWv4AJYlJfOrC9eVqxSAAYm-xYNca-lvT49SwxWp8VY,5277
|
|
19
|
-
agentos_sdk/clients/transferkit.py,sha256=
|
|
20
|
-
agentos_sdk_python-
|
|
21
|
-
agentos_sdk_python-
|
|
22
|
-
agentos_sdk_python-
|
|
23
|
-
agentos_sdk_python-
|
|
19
|
+
agentos_sdk/clients/transferkit.py,sha256=IpTy56HD-xv509w--SXfTQZgDKgKPFlWfrkaTdrCa14,1978
|
|
20
|
+
agentos_sdk_python-2.0.0.dist-info/METADATA,sha256=s6renAJ2fPoZKoXOUbqR15UHwXZK6rhozVfDtaiaisw,31787
|
|
21
|
+
agentos_sdk_python-2.0.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
22
|
+
agentos_sdk_python-2.0.0.dist-info/licenses/LICENSE,sha256=oarEto4UtUv6Y2Yeph34qL9zLBJEp0ZjuXrrwQ9uVdg,1064
|
|
23
|
+
agentos_sdk_python-2.0.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|