hibot 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.
- hibot-1.0.0/.gitignore +172 -0
- hibot-1.0.0/PKG-INFO +217 -0
- hibot-1.0.0/README.md +205 -0
- hibot-1.0.0/hibot/__init__.py +84 -0
- hibot-1.0.0/hibot/_config.py +60 -0
- hibot-1.0.0/hibot/_request.py +207 -0
- hibot-1.0.0/hibot/_response.py +74 -0
- hibot-1.0.0/hibot/_signer.py +143 -0
- hibot-1.0.0/hibot/_sse.py +109 -0
- hibot-1.0.0/hibot/_version.py +20 -0
- hibot-1.0.0/hibot/client.py +46 -0
- hibot-1.0.0/hibot/v1/__init__.py +75 -0
- hibot-1.0.0/hibot/v1/_client.py +62 -0
- hibot-1.0.0/hibot/v1/_helpers.py +133 -0
- hibot-1.0.0/hibot/v1/_server_service.py +41 -0
- hibot-1.0.0/hibot/v1/agents.py +232 -0
- hibot-1.0.0/hibot/v1/base_models.py +120 -0
- hibot-1.0.0/hibot/v1/channels.py +112 -0
- hibot-1.0.0/hibot/v1/cron_jobs.py +175 -0
- hibot-1.0.0/hibot/v1/environments.py +129 -0
- hibot-1.0.0/hibot/v1/mcps.py +247 -0
- hibot-1.0.0/hibot/v1/memories.py +156 -0
- hibot-1.0.0/hibot/v1/metrics.py +95 -0
- hibot-1.0.0/hibot/v1/models.py +286 -0
- hibot-1.0.0/hibot/v1/observations.py +53 -0
- hibot-1.0.0/hibot/v1/overview.py +17 -0
- hibot-1.0.0/hibot/v1/prompts.py +67 -0
- hibot-1.0.0/hibot/v1/resources.py +238 -0
- hibot-1.0.0/hibot/v1/runs.py +36 -0
- hibot-1.0.0/hibot/v1/runtime_api_keys.py +80 -0
- hibot-1.0.0/hibot/v1/sessions.py +459 -0
- hibot-1.0.0/hibot/v1/skills.py +308 -0
- hibot-1.0.0/hibot/v1/stream.py +278 -0
- hibot-1.0.0/hibot/v1/types.py +2078 -0
- hibot-1.0.0/hibot/v1/uploads.py +39 -0
- hibot-1.0.0/pyproject.toml +32 -0
- hibot-1.0.0/testdata/runbook.md +43 -0
- hibot-1.0.0/testdata/skill/SKILL.md +36 -0
hibot-1.0.0/.gitignore
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
### Python template
|
|
2
|
+
# Byte-compiled / optimized / DLL files
|
|
3
|
+
__pycache__/
|
|
4
|
+
*.py[cod]
|
|
5
|
+
*$py.class
|
|
6
|
+
|
|
7
|
+
# C extensions
|
|
8
|
+
*.so
|
|
9
|
+
|
|
10
|
+
# Distribution / packaging
|
|
11
|
+
.Python
|
|
12
|
+
build/
|
|
13
|
+
develop-eggs/
|
|
14
|
+
dist/
|
|
15
|
+
downloads/
|
|
16
|
+
eggs/
|
|
17
|
+
.eggs/
|
|
18
|
+
lib/
|
|
19
|
+
lib64/
|
|
20
|
+
parts/
|
|
21
|
+
sdist/
|
|
22
|
+
var/
|
|
23
|
+
.codex/
|
|
24
|
+
wheels/
|
|
25
|
+
share/python-wheels/
|
|
26
|
+
*.egg-info/
|
|
27
|
+
.installed.cfg
|
|
28
|
+
*.egg
|
|
29
|
+
MANIFEST
|
|
30
|
+
|
|
31
|
+
# PyInstaller
|
|
32
|
+
# Usually these files are written by a python script from a template
|
|
33
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
34
|
+
*.manifest
|
|
35
|
+
*.spec
|
|
36
|
+
|
|
37
|
+
# Installer logs
|
|
38
|
+
pip-log.txt
|
|
39
|
+
pip-delete-this-directory.txt
|
|
40
|
+
|
|
41
|
+
# Unit test / coverage reports
|
|
42
|
+
htmlcov/
|
|
43
|
+
.tox/
|
|
44
|
+
.nox/
|
|
45
|
+
.coverage
|
|
46
|
+
.coverage.*
|
|
47
|
+
.cache
|
|
48
|
+
nosetests.xml
|
|
49
|
+
coverage.xml
|
|
50
|
+
*.cover
|
|
51
|
+
*.py,cover
|
|
52
|
+
.hypothesis/
|
|
53
|
+
.pytest_cache/
|
|
54
|
+
cover/
|
|
55
|
+
|
|
56
|
+
# Translations
|
|
57
|
+
*.mo
|
|
58
|
+
*.pot
|
|
59
|
+
|
|
60
|
+
# Django stuff:
|
|
61
|
+
*.log
|
|
62
|
+
local_settings.py
|
|
63
|
+
db.sqlite3
|
|
64
|
+
db.sqlite3-journal
|
|
65
|
+
|
|
66
|
+
# Flask stuff:
|
|
67
|
+
instance/
|
|
68
|
+
.webassets-cache
|
|
69
|
+
|
|
70
|
+
# Scrapy stuff:
|
|
71
|
+
.scrapy
|
|
72
|
+
|
|
73
|
+
# Sphinx documentation
|
|
74
|
+
docs/_build/
|
|
75
|
+
|
|
76
|
+
# PyBuilder
|
|
77
|
+
.pybuilder/
|
|
78
|
+
target/
|
|
79
|
+
|
|
80
|
+
# Jupyter Notebook
|
|
81
|
+
.ipynb_checkpoints
|
|
82
|
+
|
|
83
|
+
# IPython
|
|
84
|
+
profile_default/
|
|
85
|
+
ipython_config.py
|
|
86
|
+
|
|
87
|
+
# pyenv
|
|
88
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
89
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
90
|
+
# .python-version
|
|
91
|
+
|
|
92
|
+
# pipenv
|
|
93
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
94
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
95
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
96
|
+
# install all needed dependencies.
|
|
97
|
+
#Pipfile.lock
|
|
98
|
+
|
|
99
|
+
# poetry
|
|
100
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
101
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
102
|
+
# commonly ignored for libraries.
|
|
103
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
104
|
+
#poetry.lock
|
|
105
|
+
|
|
106
|
+
# pdm
|
|
107
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
108
|
+
#pdm.lock
|
|
109
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
110
|
+
# in version control.
|
|
111
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
112
|
+
.pdm.toml
|
|
113
|
+
.pdm-python
|
|
114
|
+
.pdm-build/
|
|
115
|
+
|
|
116
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
117
|
+
__pypackages__/
|
|
118
|
+
|
|
119
|
+
# Celery stuff
|
|
120
|
+
celerybeat-schedule
|
|
121
|
+
celerybeat.pid
|
|
122
|
+
|
|
123
|
+
# SageMath parsed files
|
|
124
|
+
*.sage.py
|
|
125
|
+
|
|
126
|
+
# Environments
|
|
127
|
+
.env
|
|
128
|
+
.venv
|
|
129
|
+
env/
|
|
130
|
+
venv/
|
|
131
|
+
ENV/
|
|
132
|
+
env.bak/
|
|
133
|
+
venv.bak/
|
|
134
|
+
|
|
135
|
+
# Spyder project settings
|
|
136
|
+
.spyderproject
|
|
137
|
+
.spyproject
|
|
138
|
+
|
|
139
|
+
# Rope project settings
|
|
140
|
+
.ropeproject
|
|
141
|
+
|
|
142
|
+
# mkdocs documentation
|
|
143
|
+
/site
|
|
144
|
+
|
|
145
|
+
# mypy
|
|
146
|
+
.mypy_cache/
|
|
147
|
+
.dmypy.json
|
|
148
|
+
dmypy.json
|
|
149
|
+
|
|
150
|
+
# Pyre type checker
|
|
151
|
+
.pyre/
|
|
152
|
+
|
|
153
|
+
# pytype static type analyzer
|
|
154
|
+
.pytype/
|
|
155
|
+
|
|
156
|
+
# Cython debug symbols
|
|
157
|
+
cython_debug/
|
|
158
|
+
|
|
159
|
+
# PyCharm
|
|
160
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
161
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
162
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
163
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
164
|
+
#.idea/
|
|
165
|
+
|
|
166
|
+
chainlit.md
|
|
167
|
+
.chainlit/
|
|
168
|
+
.vscode
|
|
169
|
+
.idea
|
|
170
|
+
license.py
|
|
171
|
+
.DS_Store
|
|
172
|
+
.trae/
|
hibot-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: hibot
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Hibot Managed Agent Python SDK
|
|
5
|
+
Author: Hibot SDK Maintainers
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Requires-Dist: httpx>=0.28.1
|
|
9
|
+
Provides-Extra: dev
|
|
10
|
+
Requires-Dist: pytest>=9; extra == 'dev'
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# Hibot Python SDK
|
|
14
|
+
|
|
15
|
+
Python client for the Hibot Managed Agent platform. The public API is aligned
|
|
16
|
+
to `hibot_engine/api/idl/server.thrift`: every Hibot Action is signed for
|
|
17
|
+
`hibot-server` at version `2026-04-23`; artifact uploads use the separate `up`
|
|
18
|
+
service. The SDK also preserves VOLC v4 signing and SSE event normalization.
|
|
19
|
+
|
|
20
|
+
> Distribution name: `hibot` (PyPI). Top-level import: `hibot`.
|
|
21
|
+
>
|
|
22
|
+
> Requires **Python 3.10+**, depends on `httpx>=0.28.1`.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# editable / dev (recommended for source checkout):
|
|
30
|
+
python -m venv .venv
|
|
31
|
+
source .venv/bin/activate
|
|
32
|
+
pip install -e ".[dev]"
|
|
33
|
+
|
|
34
|
+
# or as a wheel:
|
|
35
|
+
pip install hibot
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Quick start
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import hibot
|
|
42
|
+
|
|
43
|
+
cfg = hibot.Config(
|
|
44
|
+
endpoint="https://open.volcengineapi.com",
|
|
45
|
+
access_key="AKLT...",
|
|
46
|
+
secret_key="...",
|
|
47
|
+
workspace_id="WS-12345",
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
with hibot.Hibot(cfg) as client:
|
|
51
|
+
# 1. Pick a base model (no Provider/Type filter ⇒ first match)
|
|
52
|
+
model = client.v1.models.get(hibot.V1ModelGetParams(
|
|
53
|
+
model_name="doubao-seed-2-0-pro-260215",
|
|
54
|
+
))
|
|
55
|
+
|
|
56
|
+
# 2. Create an agent (default Environment auto-selected)
|
|
57
|
+
agent = client.v1.agents.create(hibot.V1AgentNewParams(
|
|
58
|
+
name="weather-bot",
|
|
59
|
+
system="You are a weather assistant.",
|
|
60
|
+
model=hibot.V1ManagedAgentModelConfigParams(id=model.id),
|
|
61
|
+
))
|
|
62
|
+
|
|
63
|
+
# 3. Open a session (Peer auto-injected: webchat / system / agent_id)
|
|
64
|
+
session = client.v1.sessions.create(
|
|
65
|
+
hibot.V1SessionNewParams(agent_id=agent.id)
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
# 4a. Streaming chat
|
|
69
|
+
with client.v1.sessions.chat_streaming(
|
|
70
|
+
session.id,
|
|
71
|
+
hibot.V1SessionChatParams(input="What's the weather?"),
|
|
72
|
+
) as stream:
|
|
73
|
+
for event in stream:
|
|
74
|
+
if event.type == "delta":
|
|
75
|
+
print(event.delta.text, end="", flush=True)
|
|
76
|
+
elif event.type == "completed":
|
|
77
|
+
print() # newline at end
|
|
78
|
+
final = stream.final_message()
|
|
79
|
+
|
|
80
|
+
# 4b. Or block until completion
|
|
81
|
+
msg = client.v1.sessions.chat(
|
|
82
|
+
session.id,
|
|
83
|
+
hibot.V1SessionChatParams(input="Same question."),
|
|
84
|
+
)
|
|
85
|
+
print(msg.content)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Public surface
|
|
89
|
+
|
|
90
|
+
Top-level (`hibot`):
|
|
91
|
+
|
|
92
|
+
| Symbol | Description |
|
|
93
|
+
| ----------------------------- | ---------------------------------------------------------- |
|
|
94
|
+
| `Hibot` / `Client` | Main SDK client (alias) |
|
|
95
|
+
| `Config` | Endpoint + AK/SK + WorkspaceID + region/services overrides |
|
|
96
|
+
| `APIError` | Raised on non-2xx or non-empty `ResponseMetadata.Error` |
|
|
97
|
+
| `V1*` types | All resource & param dataclasses (re-exported from `v1`) |
|
|
98
|
+
| `BASE_MODELS` / `BASE_MODEL_*`| Built-in model catalog & constants |
|
|
99
|
+
|
|
100
|
+
Resource services live under `client.v1.*`:
|
|
101
|
+
|
|
102
|
+
- `client.v1.uploads` — `upload_blob` (routes to `/up` subpath via `up` service)
|
|
103
|
+
- `client.v1.environments` — `create / list / get / update / delete / default / list_workspace_specs`
|
|
104
|
+
- `client.v1.models` — `get / list / create / update / delete / list_providers / list_model_providers / get_model_provider / get_model_provider_credential_schema`
|
|
105
|
+
- `client.v1.prompts` — `create / list / update / delete`
|
|
106
|
+
- `client.v1.resources` — resource/directory CRUD plus `batch_create / batch_get / move`
|
|
107
|
+
- `client.v1.mcps` — CRUD plus `batch_get / test_connection / resolve`
|
|
108
|
+
- `client.v1.skills` — CRUD/version resolution plus parse, batch-get, and Ark Skill Hub operations
|
|
109
|
+
- `client.v1.agents` — CRUD, batch-get, and `retry_create / stop / resume`
|
|
110
|
+
- `client.v1.channels` — channel CRUD
|
|
111
|
+
- `client.v1.sessions` — session/message CRUD, batch-get, timeline history, `chat / chat_streaming / chat_resume / approve / cancel_run`
|
|
112
|
+
- `client.v1.runtime_api_keys` — runtime key create/list/reveal/update/delete
|
|
113
|
+
- `client.v1.runs` — persisted Run list/detail read model
|
|
114
|
+
- `client.v1.cron_jobs` — Cron CRUD, run history/sync, toggle, and run-now
|
|
115
|
+
- `client.v1.observations` — Trace list, Span list, and Span detail
|
|
116
|
+
- `client.v1.overview` — workspace overview aggregation
|
|
117
|
+
- `client.v1.metrics` — overview, trend, TopK, and breakdown queries
|
|
118
|
+
- `client.v1.memories` — MemoryStore and MemoryFile CRUD/search
|
|
119
|
+
|
|
120
|
+
## Routing & versioning
|
|
121
|
+
|
|
122
|
+
| Domain | Service (default) | Version |
|
|
123
|
+
| ------------------------------ | ------------------ | ------------ |
|
|
124
|
+
| Hibot API (CRUD/model/chat) | `hibot-server` | `2026-04-23` |
|
|
125
|
+
| Uploads | `up` (under `/up`) | `2022-01-01` |
|
|
126
|
+
|
|
127
|
+
The active service identifiers can be overridden on `Config` for private
|
|
128
|
+
deployments (`server_service` / `up_service`). The deprecated
|
|
129
|
+
`gateway_service` and `model_service` inputs remain as compatibility aliases
|
|
130
|
+
but all Hibot Actions are signed and routed with `server_service`.
|
|
131
|
+
|
|
132
|
+
The SDK injects `WorkspaceID` only at the **top level** of each Action body
|
|
133
|
+
(never inside `Payload`), matching the current server IDL.
|
|
134
|
+
|
|
135
|
+
## Stream events
|
|
136
|
+
|
|
137
|
+
`V1SessionChatStream` normalizes the server’s several event-name dialects
|
|
138
|
+
(message.chunk / message_delta / run_completed / message.failed / run_failed /
|
|
139
|
+
tool_started / tool_completed / …) into the canonical three-state set:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
delta — incremental token chunk; access via event.delta.text
|
|
143
|
+
completed — final V1Message; access via event.message or stream.final_message()
|
|
144
|
+
failed — populated event.error.code / event.error.message
|
|
145
|
+
tool_start — tool invocation began
|
|
146
|
+
tool_complete — tool invocation finished
|
|
147
|
+
approval_request / approval_responded / run_cancelling / run_cancelled — passthrough
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Two helpers are available on the stream:
|
|
151
|
+
|
|
152
|
+
- `accumulate()` — drains the stream, concatenates all `delta.text`, returns the
|
|
153
|
+
final `V1Message` (server-supplied content takes precedence).
|
|
154
|
+
- `final_message()` — returns the last `completed` message or raises if none.
|
|
155
|
+
|
|
156
|
+
## Failure semantics
|
|
157
|
+
|
|
158
|
+
`Config.__post_init__` performs **fail-fast** validation: missing
|
|
159
|
+
`endpoint` / `access_key` / `secret_key` / `workspace_id` raises immediately.
|
|
160
|
+
|
|
161
|
+
Service methods reject empty required identifiers (e.g. `agent_id`, `session_id`)
|
|
162
|
+
the same way the Go SDK does.
|
|
163
|
+
|
|
164
|
+
## Field alignment with Hibot server
|
|
165
|
+
|
|
166
|
+
The wire-format JSON schema is identical: response classes deserialize from
|
|
167
|
+
PascalCase keys (e.g. `ID`, `WorkspaceID`, `CreatedAt`). Notable mappings that
|
|
168
|
+
deviate from a literal field name:
|
|
169
|
+
|
|
170
|
+
| Python attribute | JSON key on the wire |
|
|
171
|
+
| ---------------------- | ------------------------------------------ |
|
|
172
|
+
| `V1MCP.endpoint` | `URL` (server stores as URL) |
|
|
173
|
+
| `V1Prompt.content` | `SystemPrompt` (the action payload field) |
|
|
174
|
+
| `V1ManagedAgentSkillToolParams.skill_version_id` → `Skills[].ID` (binding refs the version) |
|
|
175
|
+
|
|
176
|
+
Skill bindings use the **version ID** in the `Skills[].ID` slot — pass the
|
|
177
|
+
`SkillVersion.ID` from `client.v1.skills.list_versions` / `resolve_version`.
|
|
178
|
+
|
|
179
|
+
## Running tests
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
pytest -q
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
The normal suite is offline: it uses `httpx.MockTransport` to inspect
|
|
186
|
+
URL/Action/Version/Authorization headers and request bodies, plus simulated
|
|
187
|
+
SSE payloads to exercise the chat stream.
|
|
188
|
+
|
|
189
|
+
Real create → runtime-ready → session → streaming Chat → synchronous Chat →
|
|
190
|
+
cleanup tests are enabled when these variables are present:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
export HIBOT_ENDPOINT="http://..."
|
|
194
|
+
export HIBOT_AK="..."
|
|
195
|
+
export HIBOT_SK="..."
|
|
196
|
+
export HIBOT_WORKSPACE_ID="..."
|
|
197
|
+
pytest -q libs/hibot/tests/test_real_env.py -s
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
`HIBOT_E2E_ENV_IMAGE_TYPE` and `HIBOT_E2E_MODEL_ID` can select a known-good
|
|
201
|
+
runtime and model. The real test fails unless the Agent reaches
|
|
202
|
+
`RuntimeStatus.Ready` and both Chat modes complete; created resources are
|
|
203
|
+
removed in `finally` blocks.
|
|
204
|
+
|
|
205
|
+
## Differences from the Go SDK
|
|
206
|
+
|
|
207
|
+
The Python SDK aims for behavioural parity but is implemented as a single
|
|
208
|
+
synchronous client (no goroutine-style ctx). Other notable differences:
|
|
209
|
+
|
|
210
|
+
- **No `context.Context`.** `httpx.Client.timeout` (set on `Config.timeout`)
|
|
211
|
+
governs total request time. Streaming chat disables the per-call timeout
|
|
212
|
+
(parity with Go's `DoStream`).
|
|
213
|
+
- **dataclasses, not pydantic.** Result classes use Python `dataclass` with
|
|
214
|
+
field metadata for JSON name mapping; param classes use `dataclass` with
|
|
215
|
+
snake_case Python attributes. (See `hibot/v1/types.py`.)
|
|
216
|
+
- **No async client** is provided in this MVP. The `async_http_client` slot
|
|
217
|
+
on `Config` is reserved for future use.
|
hibot-1.0.0/README.md
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# Hibot Python SDK
|
|
2
|
+
|
|
3
|
+
Python client for the Hibot Managed Agent platform. The public API is aligned
|
|
4
|
+
to `hibot_engine/api/idl/server.thrift`: every Hibot Action is signed for
|
|
5
|
+
`hibot-server` at version `2026-04-23`; artifact uploads use the separate `up`
|
|
6
|
+
service. The SDK also preserves VOLC v4 signing and SSE event normalization.
|
|
7
|
+
|
|
8
|
+
> Distribution name: `hibot` (PyPI). Top-level import: `hibot`.
|
|
9
|
+
>
|
|
10
|
+
> Requires **Python 3.10+**, depends on `httpx>=0.28.1`.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# editable / dev (recommended for source checkout):
|
|
18
|
+
python -m venv .venv
|
|
19
|
+
source .venv/bin/activate
|
|
20
|
+
pip install -e ".[dev]"
|
|
21
|
+
|
|
22
|
+
# or as a wheel:
|
|
23
|
+
pip install hibot
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick start
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
import hibot
|
|
30
|
+
|
|
31
|
+
cfg = hibot.Config(
|
|
32
|
+
endpoint="https://open.volcengineapi.com",
|
|
33
|
+
access_key="AKLT...",
|
|
34
|
+
secret_key="...",
|
|
35
|
+
workspace_id="WS-12345",
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
with hibot.Hibot(cfg) as client:
|
|
39
|
+
# 1. Pick a base model (no Provider/Type filter ⇒ first match)
|
|
40
|
+
model = client.v1.models.get(hibot.V1ModelGetParams(
|
|
41
|
+
model_name="doubao-seed-2-0-pro-260215",
|
|
42
|
+
))
|
|
43
|
+
|
|
44
|
+
# 2. Create an agent (default Environment auto-selected)
|
|
45
|
+
agent = client.v1.agents.create(hibot.V1AgentNewParams(
|
|
46
|
+
name="weather-bot",
|
|
47
|
+
system="You are a weather assistant.",
|
|
48
|
+
model=hibot.V1ManagedAgentModelConfigParams(id=model.id),
|
|
49
|
+
))
|
|
50
|
+
|
|
51
|
+
# 3. Open a session (Peer auto-injected: webchat / system / agent_id)
|
|
52
|
+
session = client.v1.sessions.create(
|
|
53
|
+
hibot.V1SessionNewParams(agent_id=agent.id)
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
# 4a. Streaming chat
|
|
57
|
+
with client.v1.sessions.chat_streaming(
|
|
58
|
+
session.id,
|
|
59
|
+
hibot.V1SessionChatParams(input="What's the weather?"),
|
|
60
|
+
) as stream:
|
|
61
|
+
for event in stream:
|
|
62
|
+
if event.type == "delta":
|
|
63
|
+
print(event.delta.text, end="", flush=True)
|
|
64
|
+
elif event.type == "completed":
|
|
65
|
+
print() # newline at end
|
|
66
|
+
final = stream.final_message()
|
|
67
|
+
|
|
68
|
+
# 4b. Or block until completion
|
|
69
|
+
msg = client.v1.sessions.chat(
|
|
70
|
+
session.id,
|
|
71
|
+
hibot.V1SessionChatParams(input="Same question."),
|
|
72
|
+
)
|
|
73
|
+
print(msg.content)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Public surface
|
|
77
|
+
|
|
78
|
+
Top-level (`hibot`):
|
|
79
|
+
|
|
80
|
+
| Symbol | Description |
|
|
81
|
+
| ----------------------------- | ---------------------------------------------------------- |
|
|
82
|
+
| `Hibot` / `Client` | Main SDK client (alias) |
|
|
83
|
+
| `Config` | Endpoint + AK/SK + WorkspaceID + region/services overrides |
|
|
84
|
+
| `APIError` | Raised on non-2xx or non-empty `ResponseMetadata.Error` |
|
|
85
|
+
| `V1*` types | All resource & param dataclasses (re-exported from `v1`) |
|
|
86
|
+
| `BASE_MODELS` / `BASE_MODEL_*`| Built-in model catalog & constants |
|
|
87
|
+
|
|
88
|
+
Resource services live under `client.v1.*`:
|
|
89
|
+
|
|
90
|
+
- `client.v1.uploads` — `upload_blob` (routes to `/up` subpath via `up` service)
|
|
91
|
+
- `client.v1.environments` — `create / list / get / update / delete / default / list_workspace_specs`
|
|
92
|
+
- `client.v1.models` — `get / list / create / update / delete / list_providers / list_model_providers / get_model_provider / get_model_provider_credential_schema`
|
|
93
|
+
- `client.v1.prompts` — `create / list / update / delete`
|
|
94
|
+
- `client.v1.resources` — resource/directory CRUD plus `batch_create / batch_get / move`
|
|
95
|
+
- `client.v1.mcps` — CRUD plus `batch_get / test_connection / resolve`
|
|
96
|
+
- `client.v1.skills` — CRUD/version resolution plus parse, batch-get, and Ark Skill Hub operations
|
|
97
|
+
- `client.v1.agents` — CRUD, batch-get, and `retry_create / stop / resume`
|
|
98
|
+
- `client.v1.channels` — channel CRUD
|
|
99
|
+
- `client.v1.sessions` — session/message CRUD, batch-get, timeline history, `chat / chat_streaming / chat_resume / approve / cancel_run`
|
|
100
|
+
- `client.v1.runtime_api_keys` — runtime key create/list/reveal/update/delete
|
|
101
|
+
- `client.v1.runs` — persisted Run list/detail read model
|
|
102
|
+
- `client.v1.cron_jobs` — Cron CRUD, run history/sync, toggle, and run-now
|
|
103
|
+
- `client.v1.observations` — Trace list, Span list, and Span detail
|
|
104
|
+
- `client.v1.overview` — workspace overview aggregation
|
|
105
|
+
- `client.v1.metrics` — overview, trend, TopK, and breakdown queries
|
|
106
|
+
- `client.v1.memories` — MemoryStore and MemoryFile CRUD/search
|
|
107
|
+
|
|
108
|
+
## Routing & versioning
|
|
109
|
+
|
|
110
|
+
| Domain | Service (default) | Version |
|
|
111
|
+
| ------------------------------ | ------------------ | ------------ |
|
|
112
|
+
| Hibot API (CRUD/model/chat) | `hibot-server` | `2026-04-23` |
|
|
113
|
+
| Uploads | `up` (under `/up`) | `2022-01-01` |
|
|
114
|
+
|
|
115
|
+
The active service identifiers can be overridden on `Config` for private
|
|
116
|
+
deployments (`server_service` / `up_service`). The deprecated
|
|
117
|
+
`gateway_service` and `model_service` inputs remain as compatibility aliases
|
|
118
|
+
but all Hibot Actions are signed and routed with `server_service`.
|
|
119
|
+
|
|
120
|
+
The SDK injects `WorkspaceID` only at the **top level** of each Action body
|
|
121
|
+
(never inside `Payload`), matching the current server IDL.
|
|
122
|
+
|
|
123
|
+
## Stream events
|
|
124
|
+
|
|
125
|
+
`V1SessionChatStream` normalizes the server’s several event-name dialects
|
|
126
|
+
(message.chunk / message_delta / run_completed / message.failed / run_failed /
|
|
127
|
+
tool_started / tool_completed / …) into the canonical three-state set:
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
delta — incremental token chunk; access via event.delta.text
|
|
131
|
+
completed — final V1Message; access via event.message or stream.final_message()
|
|
132
|
+
failed — populated event.error.code / event.error.message
|
|
133
|
+
tool_start — tool invocation began
|
|
134
|
+
tool_complete — tool invocation finished
|
|
135
|
+
approval_request / approval_responded / run_cancelling / run_cancelled — passthrough
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Two helpers are available on the stream:
|
|
139
|
+
|
|
140
|
+
- `accumulate()` — drains the stream, concatenates all `delta.text`, returns the
|
|
141
|
+
final `V1Message` (server-supplied content takes precedence).
|
|
142
|
+
- `final_message()` — returns the last `completed` message or raises if none.
|
|
143
|
+
|
|
144
|
+
## Failure semantics
|
|
145
|
+
|
|
146
|
+
`Config.__post_init__` performs **fail-fast** validation: missing
|
|
147
|
+
`endpoint` / `access_key` / `secret_key` / `workspace_id` raises immediately.
|
|
148
|
+
|
|
149
|
+
Service methods reject empty required identifiers (e.g. `agent_id`, `session_id`)
|
|
150
|
+
the same way the Go SDK does.
|
|
151
|
+
|
|
152
|
+
## Field alignment with Hibot server
|
|
153
|
+
|
|
154
|
+
The wire-format JSON schema is identical: response classes deserialize from
|
|
155
|
+
PascalCase keys (e.g. `ID`, `WorkspaceID`, `CreatedAt`). Notable mappings that
|
|
156
|
+
deviate from a literal field name:
|
|
157
|
+
|
|
158
|
+
| Python attribute | JSON key on the wire |
|
|
159
|
+
| ---------------------- | ------------------------------------------ |
|
|
160
|
+
| `V1MCP.endpoint` | `URL` (server stores as URL) |
|
|
161
|
+
| `V1Prompt.content` | `SystemPrompt` (the action payload field) |
|
|
162
|
+
| `V1ManagedAgentSkillToolParams.skill_version_id` → `Skills[].ID` (binding refs the version) |
|
|
163
|
+
|
|
164
|
+
Skill bindings use the **version ID** in the `Skills[].ID` slot — pass the
|
|
165
|
+
`SkillVersion.ID` from `client.v1.skills.list_versions` / `resolve_version`.
|
|
166
|
+
|
|
167
|
+
## Running tests
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
pytest -q
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
The normal suite is offline: it uses `httpx.MockTransport` to inspect
|
|
174
|
+
URL/Action/Version/Authorization headers and request bodies, plus simulated
|
|
175
|
+
SSE payloads to exercise the chat stream.
|
|
176
|
+
|
|
177
|
+
Real create → runtime-ready → session → streaming Chat → synchronous Chat →
|
|
178
|
+
cleanup tests are enabled when these variables are present:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
export HIBOT_ENDPOINT="http://..."
|
|
182
|
+
export HIBOT_AK="..."
|
|
183
|
+
export HIBOT_SK="..."
|
|
184
|
+
export HIBOT_WORKSPACE_ID="..."
|
|
185
|
+
pytest -q libs/hibot/tests/test_real_env.py -s
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
`HIBOT_E2E_ENV_IMAGE_TYPE` and `HIBOT_E2E_MODEL_ID` can select a known-good
|
|
189
|
+
runtime and model. The real test fails unless the Agent reaches
|
|
190
|
+
`RuntimeStatus.Ready` and both Chat modes complete; created resources are
|
|
191
|
+
removed in `finally` blocks.
|
|
192
|
+
|
|
193
|
+
## Differences from the Go SDK
|
|
194
|
+
|
|
195
|
+
The Python SDK aims for behavioural parity but is implemented as a single
|
|
196
|
+
synchronous client (no goroutine-style ctx). Other notable differences:
|
|
197
|
+
|
|
198
|
+
- **No `context.Context`.** `httpx.Client.timeout` (set on `Config.timeout`)
|
|
199
|
+
governs total request time. Streaming chat disables the per-call timeout
|
|
200
|
+
(parity with Go's `DoStream`).
|
|
201
|
+
- **dataclasses, not pydantic.** Result classes use Python `dataclass` with
|
|
202
|
+
field metadata for JSON name mapping; param classes use `dataclass` with
|
|
203
|
+
snake_case Python attributes. (See `hibot/v1/types.py`.)
|
|
204
|
+
- **No async client** is provided in this MVP. The `async_http_client` slot
|
|
205
|
+
on `Config` is reserved for future use.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""Hibot Managed Agent Python SDK.
|
|
2
|
+
|
|
3
|
+
Public surface: :class:`Hibot` / :class:`Client` constructors, :class:`Config`,
|
|
4
|
+
:class:`APIError`, plus the entire :mod:`hibot.v1` namespace re-exported
|
|
5
|
+
under the ``V1*`` prefix for convenience::
|
|
6
|
+
|
|
7
|
+
import hibot
|
|
8
|
+
|
|
9
|
+
cfg = hibot.Config(
|
|
10
|
+
endpoint="https://open.volcengineapi.com",
|
|
11
|
+
access_key="AK",
|
|
12
|
+
secret_key="SK",
|
|
13
|
+
workspace_id="WS123",
|
|
14
|
+
)
|
|
15
|
+
with hibot.Hibot(cfg) as client:
|
|
16
|
+
agents = client.v1.agents.list()
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
from . import v1
|
|
22
|
+
from ._config import Config
|
|
23
|
+
from ._response import APIError
|
|
24
|
+
from ._version import (
|
|
25
|
+
AIGW_SERVICE,
|
|
26
|
+
CHAT_VERSION,
|
|
27
|
+
DEFAULT_REGION,
|
|
28
|
+
GATEWAY_SERVICE,
|
|
29
|
+
MODEL_VERSION,
|
|
30
|
+
SERVER_SERVICE,
|
|
31
|
+
SERVER_VERSION,
|
|
32
|
+
UP_SERVICE,
|
|
33
|
+
UP_VERSION,
|
|
34
|
+
)
|
|
35
|
+
from .client import Client, Hibot
|
|
36
|
+
from .v1 import ( # noqa: F401 — re-export public types
|
|
37
|
+
BASE_MODEL_PROVIDER_BYTEPLUS,
|
|
38
|
+
BASE_MODEL_PROVIDER_OPENAI,
|
|
39
|
+
BASE_MODEL_PROVIDER_VOLCENGINE,
|
|
40
|
+
BASE_MODEL_PROVIDER_VOLCENGINE_AICC,
|
|
41
|
+
BASE_MODEL_TYPE_AUDIO,
|
|
42
|
+
BASE_MODEL_TYPE_EMBEDDINGS,
|
|
43
|
+
BASE_MODEL_TYPE_RERANKING,
|
|
44
|
+
BASE_MODEL_TYPE_TEXT_GENERATION,
|
|
45
|
+
BASE_MODEL_TYPE_VISION,
|
|
46
|
+
BASE_MODELS,
|
|
47
|
+
Services,
|
|
48
|
+
V1Client,
|
|
49
|
+
V1SessionChatStream,
|
|
50
|
+
)
|
|
51
|
+
from .v1.types import * # noqa: F401,F403
|
|
52
|
+
|
|
53
|
+
__version__ = "1.0.0"
|
|
54
|
+
|
|
55
|
+
__all__ = [
|
|
56
|
+
"Hibot",
|
|
57
|
+
"Client",
|
|
58
|
+
"Config",
|
|
59
|
+
"APIError",
|
|
60
|
+
"v1",
|
|
61
|
+
"Services",
|
|
62
|
+
"V1Client",
|
|
63
|
+
"V1SessionChatStream",
|
|
64
|
+
"BASE_MODELS",
|
|
65
|
+
"BASE_MODEL_TYPE_TEXT_GENERATION",
|
|
66
|
+
"BASE_MODEL_TYPE_EMBEDDINGS",
|
|
67
|
+
"BASE_MODEL_TYPE_VISION",
|
|
68
|
+
"BASE_MODEL_TYPE_AUDIO",
|
|
69
|
+
"BASE_MODEL_TYPE_RERANKING",
|
|
70
|
+
"BASE_MODEL_PROVIDER_VOLCENGINE",
|
|
71
|
+
"BASE_MODEL_PROVIDER_BYTEPLUS",
|
|
72
|
+
"BASE_MODEL_PROVIDER_VOLCENGINE_AICC",
|
|
73
|
+
"BASE_MODEL_PROVIDER_OPENAI",
|
|
74
|
+
"DEFAULT_REGION",
|
|
75
|
+
"SERVER_SERVICE",
|
|
76
|
+
"GATEWAY_SERVICE",
|
|
77
|
+
"AIGW_SERVICE",
|
|
78
|
+
"UP_SERVICE",
|
|
79
|
+
"SERVER_VERSION",
|
|
80
|
+
"CHAT_VERSION",
|
|
81
|
+
"MODEL_VERSION",
|
|
82
|
+
"UP_VERSION",
|
|
83
|
+
"__version__",
|
|
84
|
+
]
|