@kanyun-ai-infra/agenthub 1.0.0 → 1.0.1
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.
- package/README.md +15 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,15 +80,22 @@ const version = await agenthub.agents.publishVersion({
|
|
|
80
80
|
},
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
// 4. Session
|
|
83
|
+
// 4. Session:通过 stage 槽位分配一次运行时。setDefault:true 首次发布已自动
|
|
84
|
+
// 创建 test 槽位,直接用即可(stage 与 versionId 互斥,见下方 API 参考)。
|
|
84
85
|
const session = await agenthub.sessions.create({
|
|
85
86
|
projectId: project.id,
|
|
86
|
-
agentId: version.agentId,
|
|
87
|
+
agentId: version.agentId,
|
|
88
|
+
stage: "test",
|
|
87
89
|
});
|
|
88
90
|
|
|
89
91
|
const ready = await agenthub.sessions.wait(session.sessionId); // status === "ready" 时返回
|
|
90
92
|
```
|
|
91
93
|
|
|
94
|
+
> Environment(k8s 配置底座:资源规格 / envVars / TTL)上面还没有登场——test 槽位
|
|
95
|
+
> 目前落在裸 revision 快照上,本地联调、smoke test 够用。真实上线到 production,
|
|
96
|
+
> 要额外给槽位绑一个 Environment,才有资源规格定制、canary 灰度、drift 检测、
|
|
97
|
+
> 一键回滚这些能力:完整走一遍见下方 [发布闭环](#发布闭环)。
|
|
98
|
+
|
|
92
99
|
## 核心模型
|
|
93
100
|
|
|
94
101
|
```text
|
|
@@ -102,10 +109,11 @@ Project → Agent → Version → Session
|
|
|
102
109
|
标记 project/agent 默认版本。
|
|
103
110
|
- **Session**:基于某个 Version 发起的一次 startup/runtime allocation。
|
|
104
111
|
|
|
105
|
-
上面这条链路是"定义"
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
112
|
+
上面这条链路是"定义"层面的(发布了什么);Session 已经通过 **Stage** 槽位
|
|
113
|
+
(`test`/`production`,指向当前生效的 Version,可选绑定 **Environment**)
|
|
114
|
+
跑起来了——但这个槽位目前没绑 Environment(k8s 配置底座:资源规格 / envVars /
|
|
115
|
+
TTL),落的是裸 revision 快照。给槽位绑定 Environment、晋级到 production、
|
|
116
|
+
canary 灰度、drift 检测、一键回滚——完整闭环见 [发布闭环](#发布闭环)。
|
|
109
117
|
|
|
110
118
|
Agents 和 runtime templates 都是 **project-scoped**。Version 必须在同一个 Project
|
|
111
119
|
内解析到 Agent 和 runtime source;唯一例外是下文的 platform-shared templates。
|
|
@@ -223,7 +231,7 @@ TTL)——它本身不是"部署目标";`test`/`production` 才是部署目
|
|
|
223
231
|
|
|
224
232
|
| 方法 | 说明 |
|
|
225
233
|
| --- | --- |
|
|
226
|
-
| `create({ projectId, agentId, versionId?, configValues?, metadata?, idempotencyKey?, resources?, ... })` | 启动 Session
|
|
234
|
+
| `create({ projectId, agentId, stage?, versionId?, configValues?, metadata?, idempotencyKey?, resources?, ... })` | 启动 Session。**推荐传 `stage`**(`"test"` \| `"production"`)——透过槽位解析出当前部署的 revision + environment;槽位不存在时抛 `STAGE_NOT_DEPLOYED`。`stage` 与 `versionId`/`revisionId` 互斥(同传抛 `STAGE_REVISION_MUTEX`)——后者是钉死某个 revision、绕开槽位解析的特殊路径。都省略时退化为 Agent 的 `defaultRevisionId`。`agentId`/`versionId` 也可写成 `workloadId`/`revisionId`(互斥)。`resources` 注入 Model A 只读输入文件(见下)。返回 `{ sessionId, status }`。 |
|
|
227
235
|
| `get(sessionId)` | 读取 Session 快照(`{ session: { id, status, ... } }`,字段为服务端原样返回)。 |
|
|
228
236
|
| `wait(sessionId, { intervalMs?, timeoutMs?, signal? })` | 轮询到 `status === "ready"`;遇到 `failed` 或超时会抛错。 |
|
|
229
237
|
| `releaseSandbox(sessionId)` | 释放 Session 当前 sandbox(保留 session,下一轮 turn 自动 revive 到新 sandbox)。需 `runs:create`。返回 `{ released, sandboxId, sandboxDestroyed, destroyError? }`;`sandboxDestroyed:false` 不代表失败(watcher 会兜底销毁)。 |
|