@kanyun-ai-infra/agenthub 0.1.1 → 0.3.0
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 +170 -142
- package/dist/index.cjs +3365 -2976
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1437 -465
- package/dist/index.d.ts +1437 -465
- package/dist/index.js +3373 -2989
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,51 +1,52 @@
|
|
|
1
1
|
# @kanyun-ai-infra/agenthub
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
用于 **agenthub Control Plane API** 的类型化 TypeScript 客户端。
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
`project → workload → revision → session` lifecycle programmatically.
|
|
5
|
+
它直接调用 agenthub Control Plane,适合后端服务、CI 和工具以编程方式驱动
|
|
6
|
+
`project → agent → version → session` 生命周期。
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
接入时会遇到两个入口:
|
|
10
9
|
|
|
11
|
-
|
|
|
10
|
+
| 入口 | URL | 用途 |
|
|
12
11
|
| --- | --- | --- |
|
|
13
|
-
| **Control Plane API** | `https://agenthub-plane.zhenguanyu.com` |
|
|
14
|
-
|
|
|
12
|
+
| **Control Plane API** | `https://agenthub-plane.zhenguanyu.com` | SDK / 你的服务调用。作为 `controlPlaneUrl` 传入。 |
|
|
13
|
+
| **管理门户** | `https://agenthub.zhenguanyu.com` | 人工发布和管理 agent,并在这里**签发 API token**。 |
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
issued from the portal with the `agenthub-plane` Control Plane URL.
|
|
15
|
+
两者使用不同的 token audience:Portal 登录态 token 不能调用 Control Plane,反过来也一样。
|
|
16
|
+
请始终把管理门户签发的 platform-api token 和 `agenthub-plane` Control Plane URL 配套使用。
|
|
19
17
|
|
|
20
|
-
##
|
|
18
|
+
## 安装
|
|
21
19
|
|
|
22
20
|
```bash
|
|
23
21
|
pnpm add @kanyun-ai-infra/agenthub
|
|
24
|
-
#
|
|
22
|
+
# 或:npm i @kanyun-ai-infra/agenthub
|
|
25
23
|
```
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
需要 Node 18+,因为 SDK 使用全局 `fetch`。
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
如果调用方是 Java、Python、Go 或 Shell,请优先看 raw HTTP 指南和 REST 参考:
|
|
28
|
+
[`docs/user-guide/agenthub-http-quickstart.md`](../../docs/user-guide/agenthub-http-quickstart.md),
|
|
29
|
+
[`docs/user-guide/agenthub-rest-api.md`](../../docs/user-guide/agenthub-rest-api.md)。
|
|
30
|
+
|
|
31
|
+
## 快速开始
|
|
30
32
|
|
|
31
33
|
```ts
|
|
32
34
|
import { PilotPlatformClient } from "@kanyun-ai-infra/agenthub";
|
|
33
35
|
|
|
34
36
|
const agenthub = new PilotPlatformClient({
|
|
35
37
|
controlPlaneUrl: "https://agenthub-plane.zhenguanyu.com",
|
|
36
|
-
token: process.env.PILOT_TOKEN, // platform-api token
|
|
38
|
+
token: process.env.PILOT_TOKEN, // 管理门户签发的 platform-api token
|
|
37
39
|
});
|
|
38
40
|
|
|
39
|
-
// 1. Project
|
|
40
|
-
// callers publish revisions without picking one each time (see below).
|
|
41
|
+
// 1. Project:租户 / 根分组。默认 runtime template 让发布 Version 时不必每次手选模板。
|
|
41
42
|
const project = await agenthub.projects.create({
|
|
42
43
|
slug: "acme",
|
|
43
44
|
displayName: "Acme",
|
|
44
45
|
defaultRuntimeTemplateRefName: "pilot-v2-pod-agent",
|
|
45
46
|
});
|
|
46
47
|
|
|
47
|
-
// 2.
|
|
48
|
-
await agenthub.
|
|
48
|
+
// 2. Agent:Project 下一个可运行的 agent。
|
|
49
|
+
await agenthub.agents.create({
|
|
49
50
|
projectId: project.id,
|
|
50
51
|
slug: "support-bot",
|
|
51
52
|
displayName: "Support Bot",
|
|
@@ -56,11 +57,10 @@ await agenthub.workloads.create({
|
|
|
56
57
|
},
|
|
57
58
|
});
|
|
58
59
|
|
|
59
|
-
// 3.
|
|
60
|
-
|
|
61
|
-
const revision = await agenthub.workloads.publishRevision({
|
|
60
|
+
// 3. Version:Agent 的不可变发布版本。Runtime source 默认继承 Project default。
|
|
61
|
+
const version = await agenthub.agents.publishVersion({
|
|
62
62
|
projectId: project.id,
|
|
63
|
-
|
|
63
|
+
agentSlug: "support-bot",
|
|
64
64
|
version: "v1",
|
|
65
65
|
workerContract: { kind: "managed_agent" },
|
|
66
66
|
setDefault: true,
|
|
@@ -70,144 +70,175 @@ const revision = await agenthub.workloads.publishRevision({
|
|
|
70
70
|
},
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
// 4. Session
|
|
73
|
+
// 4. Session:基于默认 Version(或指定 Version)分配一次运行时。
|
|
74
74
|
const session = await agenthub.sessions.create({
|
|
75
75
|
projectId: project.id,
|
|
76
|
-
|
|
76
|
+
agentId: version.agentId, // 用默认 Version;指定版本传 versionId
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
const ready = await agenthub.sessions.wait(session.sessionId); //
|
|
79
|
+
const ready = await agenthub.sessions.wait(session.sessionId); // status === "ready" 时返回
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
-
##
|
|
82
|
+
## 核心模型
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
```text
|
|
85
|
+
Project → Agent → Version → Session
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
- **Project**:租户 / 根分组,拥有 agents 和 runtime templates。
|
|
89
|
+
- **Agent**:一个逻辑可运行应用。`kind` 是 `"managed_agent"`(平台基于
|
|
90
|
+
`model` + `systemPrompt` 运行 agent loop)或 `"self_managed"`(你自己提供 worker)。
|
|
91
|
+
- **Version**:Agent 的不可变发布版本,绑定一个 runtime source。用 `setDefault`
|
|
92
|
+
标记 project/agent 默认版本。
|
|
93
|
+
- **Session**:基于某个 Version 发起的一次 startup/runtime allocation。
|
|
85
94
|
|
|
86
|
-
|
|
95
|
+
Agents 和 runtime templates 都是 **project-scoped**。Version 必须在同一个 Project
|
|
96
|
+
内解析到 Agent 和 runtime source;唯一例外是下文的 platform-shared templates。
|
|
97
|
+
|
|
98
|
+
> 本文一律用主词汇 **agent / version**;它们是底层 wire 名 `workload` / `revision`
|
|
99
|
+
> 的别名,SDK 两套都接受,细节见 [术语别名](#术语别名agent--version)。
|
|
100
|
+
|
|
101
|
+
### 术语别名(agent / version)
|
|
102
|
+
|
|
103
|
+
| 主词汇(推荐) | 等价的底层名 | 说明 |
|
|
87
104
|
| --- | --- | --- |
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
91
|
-
| `
|
|
92
|
-
| `defaultHeaders` | no | Extra headers merged into every request. |
|
|
93
|
-
| `userAgent` | no | Overrides the default `@kanyun-ai-infra/agenthub/<version>` UA. |
|
|
94
|
-
| `pilotApiVersion` | no | Pins the `x-pilot-api-version` header (defaults to the v2 wire version). |
|
|
105
|
+
| `agenthub.agents` | `agenthub.workloads` | **同一个资源实例**(`agents === workloads`),方法两边都能调。 |
|
|
106
|
+
| `agents.publishVersion({ agentSlug })` | `workloads.publishRevision({ workloadSlug })` | 同一个调用;wire body 完全一致。 |
|
|
107
|
+
| `sessions.create({ agentId, versionId })` | `sessions.create({ workloadId, revisionId })` | 入参别名,内部映射回规范名后再发出。 |
|
|
108
|
+
| 返回字段 `result.agentId` / `result.versionId` | `result.workloadId` / `result.revisionId` | 返回对象**同时带**两套字段(别名 = 规范值)。 |
|
|
95
109
|
|
|
96
|
-
|
|
97
|
-
`KANYUN_PILOT_CONTROL_PLANE_URL`; `token` falls back to `PILOT_TOKEN`. Missing
|
|
98
|
-
either produces a typed SDK error before any request is sent.
|
|
110
|
+
规则:
|
|
99
111
|
|
|
100
|
-
|
|
112
|
+
- **互斥**:一对里只能传一个,规范名和别名同传会抛 `ALIAS_CONFLICT`,避免笔误被静默忽略
|
|
113
|
+
(`sessions.create` 的 `agentId`/`workloadId`、`versionId`/`revisionId`,
|
|
114
|
+
`applyRevisionManifest` 的 `agentSlug`/`workloadSlug`)。
|
|
115
|
+
- 入参别名**不进 wire**:发请求前映射回 `workloadId`/`revisionId`,body 永远是规范名。
|
|
116
|
+
- 返回别名是 SDK 派生的可枚举字段(`JSON.stringify` / 日志都带得上),不回传服务端。
|
|
117
|
+
- 底层名(`workloads` / `publishRevision` / `workloadId`)一直保留、行为不变,挑读着顺的那套写即可。
|
|
118
|
+
- 异步事件 payload、日志 / Trace 里的关联 ID 仍是 `workloadId`/`revisionId`(属 control-plane 范畴,不在 SDK 改名范围内)。
|
|
101
119
|
|
|
102
|
-
|
|
103
|
-
**platform-api token**. That token is scoped to the Control Plane API
|
|
104
|
-
(`agenthub-plane.zhenguanyu.com`); store it as `PILOT_TOKEN` (or pass it as
|
|
105
|
-
`token`). Tokens are bearer credentials — keep them out of source control and
|
|
106
|
-
rotate from the portal if leaked.
|
|
120
|
+
## API 参考
|
|
107
121
|
|
|
108
|
-
|
|
122
|
+
### `agenthub.projects`
|
|
109
123
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
124
|
+
| 方法 | 说明 |
|
|
125
|
+
| --- | --- |
|
|
126
|
+
| `create({ slug, displayName, description?, defaultRuntimeTemplateRefName? })` | 创建 Project。slug 重复时返回 `409 PROJECT_SLUG_CONFLICT`。 |
|
|
127
|
+
| `list()` | 列出 token 有效 scope 内的 Project。 |
|
|
128
|
+
| `get(projectId)` | 查询单个 Project。 |
|
|
129
|
+
|
|
130
|
+
### `agenthub.agents`(别名 `agenthub.workloads`)
|
|
113
131
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
- **Session** — a startup/runtime allocation against a revision.
|
|
132
|
+
| 方法 | 说明 |
|
|
133
|
+
| --- | --- |
|
|
134
|
+
| `create(req, { dryRun? })` | 创建 Agent。返回 `{ mode, status, agentId?/workloadId?, workload }`。 |
|
|
135
|
+
| `publishVersion(req, { dryRun? })` | 发布 Version(别名 `publishRevision`,用 `workloadSlug`)。返回 `{ mode, status, agentId/workloadId, versionId?/revisionId?, runtimeTemplateId, resolved }`。 |
|
|
136
|
+
| `applyManifest({ projectId, manifest, dryRun? })` | 高级 / GitOps:apply raw agent manifest。 |
|
|
137
|
+
| `applyRevisionManifest({ projectId, agentSlug \| workloadSlug, manifest, dryRun? })` | 高级 / GitOps:apply raw version manifest。两个 slug 拼写都接受(互斥)。 |
|
|
121
138
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
139
|
+
`create` / `publishVersion` 的 `req` 结构和 managed-agent 全部配置项(`model` /
|
|
140
|
+
`systemPrompt` / `enabledSkills` / `enabledMcpServers` / `agentOptions` 安全约束 /
|
|
141
|
+
`runtime` / `startup` 等),见
|
|
142
|
+
[`specs/features/agenthub-sdk.md`](../../specs/features/agenthub-sdk.md)
|
|
143
|
+
的 "Managed-Agent Configuration"、"Workload API Contract"、"Revision Publish Contract" 章节。
|
|
125
144
|
|
|
126
|
-
|
|
145
|
+
> **`agentOptions` 安全约束(高频踩坑)**:`agentOptions` **只能收紧 / 限额**,不能放宽。
|
|
146
|
+
> `allowedTools` 与平台基线**取交集**(只会更窄)、`disallowedTools` 叠加平台黑名单且
|
|
147
|
+
> **不能移除**平台守卫工具;`permissionMode` / `env` / `mcpServers` / `hooks` /
|
|
148
|
+
> `plugins` / 原始 `sdkOptions` 等可能越权或逃逸 sandbox 的字段**一律不开放**(见 issue #840)。
|
|
149
|
+
> 字段全表见上述 spec。
|
|
127
150
|
|
|
128
|
-
|
|
151
|
+
`apply*` 方法里的 `manifest` 可以是 manifest 对象、`{ yaml }` 或 `{ json }`。
|
|
152
|
+
|
|
153
|
+
### `agenthub.sessions`
|
|
129
154
|
|
|
130
|
-
|
|
|
155
|
+
| 方法 | 说明 |
|
|
131
156
|
| --- | --- |
|
|
132
|
-
| `create({
|
|
133
|
-
| `
|
|
134
|
-
| `
|
|
157
|
+
| `create({ projectId, agentId, versionId?, configValues?, metadata?, idempotencyKey?, resources?, ... })` | 启动 Session。省略 `versionId` 时使用 Agent 默认 Version。`agentId`/`versionId` 也可写成 `workloadId`/`revisionId`(互斥)。`resources` 注入 Model A 只读输入文件(见下)。返回 `{ sessionId, status }`。 |
|
|
158
|
+
| `get(sessionId)` | 读取 Session 快照(`{ session: { id, status, ... } }`,字段为服务端原样返回)。 |
|
|
159
|
+
| `wait(sessionId, { intervalMs?, timeoutMs?, signal? })` | 轮询到 `status === "ready"`;遇到 `failed` 或超时会抛错。 |
|
|
135
160
|
|
|
136
|
-
|
|
161
|
+
Session `status` 取值为 `created`、`provisioning`、`starting`、`ready`、`failed`。
|
|
137
162
|
|
|
138
|
-
|
|
163
|
+
### `agenthub.files`
|
|
164
|
+
|
|
165
|
+
| 方法 | 说明 |
|
|
139
166
|
| --- | --- |
|
|
140
|
-
| `
|
|
141
|
-
| `publishRevision(req, { dryRun? })` | Publish a revision. Returns `{ mode, status, workloadId, revisionId?, runtimeTemplateId, resolved }`. |
|
|
142
|
-
| `applyManifest({ projectId, manifest, dryRun? })` | Advanced/GitOps: apply a raw workload manifest. |
|
|
143
|
-
| `applyRevisionManifest({ projectId, workloadSlug, manifest, dryRun? })` | Advanced/GitOps: apply a raw revision manifest. |
|
|
167
|
+
| `upload({ projectId, file, filename?, contentType? })` | 上传单个文件,返回 `{ ossUrl, url, filename, size, mediaType, mimeType }`。`file` 接受 `Blob` / `File` / `Uint8Array` / `ArrayBuffer`;非具名 `File` 时必须传 `filename`。 |
|
|
144
168
|
|
|
145
|
-
`
|
|
169
|
+
文件落在 `pilot/attachments/<projectId>/`,与 Session 资源 scope 校验同一 keyspace —— 为某 Project
|
|
170
|
+
上传的文件无法挂到另一个 Project 的 Session。`url` 是 ~1h 的 presigned GET(仅预览用);
|
|
171
|
+
要持久引用的是 `ossUrl`。
|
|
146
172
|
|
|
147
|
-
|
|
148
|
-
{
|
|
149
|
-
projectId: string;
|
|
150
|
-
slug: string;
|
|
151
|
-
displayName: string;
|
|
152
|
-
kind: "managed_agent" | "self_managed";
|
|
153
|
-
defaults?: {
|
|
154
|
-
model?: string;
|
|
155
|
-
systemPrompt?: string;
|
|
156
|
-
workerContract?: { name?: string; version?: string };
|
|
157
|
-
configValues?: Record<string, string>;
|
|
158
|
-
enabledSkills?: EnabledSkill[];
|
|
159
|
-
enabledMcpServers?: EnabledMcpServer[];
|
|
160
|
-
};
|
|
161
|
-
ui?: { /* Default-UI hints */ };
|
|
162
|
-
}
|
|
163
|
-
```
|
|
173
|
+
#### Model A 只读输入文件(session resources)
|
|
164
174
|
|
|
165
|
-
|
|
175
|
+
把文件作为 **Session 级只读输入**挂进 sandbox 的 `/workspace/.session/inputs/`(每次
|
|
176
|
+
provision / revival 重新物化),用 `files.upload` + `sessions.create({ resources })`:
|
|
166
177
|
|
|
167
178
|
```ts
|
|
168
|
-
{
|
|
169
|
-
projectId
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
+
const up = await agenthub.files.upload({
|
|
180
|
+
projectId,
|
|
181
|
+
file: new Blob([await fs.promises.readFile("spec.md")]),
|
|
182
|
+
filename: "spec.md",
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// `up` 是 SessionFileResource 的超集,只多一个预览用的 `url`;解构掉它,
|
|
186
|
+
// 剩下的 `meta`(ossUrl/filename/size/mediaType/mimeType)正是一个资源条目。
|
|
187
|
+
const { url, ...meta } = up;
|
|
188
|
+
|
|
189
|
+
const { sessionId } = await agenthub.sessions.create({
|
|
190
|
+
projectId,
|
|
191
|
+
agentId,
|
|
192
|
+
resources: {
|
|
193
|
+
version: "v1",
|
|
194
|
+
files: [{ ...meta, mountPath: "docs/spec.md" }], // mountPath 可省略 → 用文件名
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
// agent 在 /workspace/.session/inputs/docs/spec.md 只读看到该文件
|
|
179
198
|
```
|
|
180
199
|
|
|
181
|
-
|
|
182
|
-
|
|
200
|
+
约束:每 Session ≤ 20 个文件;`mountPath` 必须是 `.session/inputs/` 下的相对子路径
|
|
201
|
+
(拒绝绝对路径与 `..`);只读。
|
|
183
202
|
|
|
184
|
-
|
|
203
|
+
## Client 配置
|
|
185
204
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
|
189
|
-
|
|
|
190
|
-
| `
|
|
205
|
+
`new PilotPlatformClient(config)`
|
|
206
|
+
|
|
207
|
+
| 选项 | 必填 | 说明 |
|
|
208
|
+
| --- | --- | --- |
|
|
209
|
+
| `controlPlaneUrl` | 是¹ | Control Plane 源地址。相对路径会拼到它下面;跨 origin 路径会在发 token 前被拒绝。 |
|
|
210
|
+
| `token` | 是¹ | Platform-api token。每个请求都会作为 `Authorization: Bearer <token>` 发送。 |
|
|
211
|
+
| `fetch` | 否 | 自定义 `fetch` 实现,默认使用全局 `fetch`。 |
|
|
212
|
+
| `signal` | 否 | 应用于每个请求的默认 `AbortSignal`。 |
|
|
213
|
+
| `defaultHeaders` | 否 | 合并到每个请求的额外 header。 |
|
|
214
|
+
| `userAgent` | 否 | 覆盖默认 `@kanyun-ai-infra/agenthub/<version>` UA。 |
|
|
215
|
+
| `pilotApiVersion` | 否 | 固定 `x-pilot-api-version` header,默认使用 v2 wire version。 |
|
|
216
|
+
|
|
217
|
+
¹ `controlPlaneUrl` 会依次回退到 `PILOT_CONTROL_PLANE_URL`、
|
|
218
|
+
`KANYUN_PILOT_CONTROL_PLANE_URL`;`token` 会回退到 `PILOT_TOKEN`。任意一项缺失时,
|
|
219
|
+
SDK 会在发送请求前抛出类型化错误。
|
|
220
|
+
|
|
221
|
+
### 获取 token
|
|
191
222
|
|
|
192
|
-
|
|
193
|
-
|
|
223
|
+
登录 **管理门户** <https://agenthub.zhenguanyu.com> 并签发 **platform-api token**。
|
|
224
|
+
该 token 的作用域是 Control Plane API(`agenthub-plane.zhenguanyu.com`);可以存为
|
|
225
|
+
`PILOT_TOKEN`,也可以显式传给 `token`。Token 是 Bearer 凭据,请不要提交到代码仓库;
|
|
226
|
+
泄露后需要在门户里轮换。
|
|
194
227
|
|
|
195
|
-
## Runtime
|
|
228
|
+
## Runtime template
|
|
196
229
|
|
|
197
|
-
|
|
198
|
-
|
|
230
|
+
managed-agent Version 运行在一个 **runtime template**(已注册的 runtime source)上。
|
|
231
|
+
Control Plane 按以下顺序解析:
|
|
199
232
|
|
|
200
|
-
1.
|
|
201
|
-
2.
|
|
202
|
-
3.
|
|
233
|
+
1. version `runtime.profileRef`(structured)/ `spec.runtime.profileRef`
|
|
234
|
+
2. version `spec.runtimeTemplateRef`(manifest)
|
|
235
|
+
3. agent defaults `spec.defaults.runtimeTemplateRef`(manifest)
|
|
203
236
|
4. project `defaultRuntimeTemplateRefName`
|
|
204
237
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
`RUNTIME_TEMPLATE_NOT_FOUND`.
|
|
238
|
+
如果都解析不到,返回 `PROJECT_DEFAULT_RUNTIME_MISSING`。如果指定模板在当前 Project
|
|
239
|
+
或 platform-shared templates 中不存在,返回 `RUNTIME_TEMPLATE_NOT_FOUND`。
|
|
208
240
|
|
|
209
|
-
|
|
210
|
-
a template:
|
|
241
|
+
主路径建议在创建 Project 时设置默认模板,这样发布 Version 时不需要手选:
|
|
211
242
|
|
|
212
243
|
```ts
|
|
213
244
|
await agenthub.projects.create({
|
|
@@ -217,21 +248,19 @@ await agenthub.projects.create({
|
|
|
217
248
|
});
|
|
218
249
|
```
|
|
219
250
|
|
|
220
|
-
|
|
221
|
-
`runtime: { profileRef: { name: "..." } }`.
|
|
251
|
+
否则需要在每个 Version 上显式指定:`runtime: { profileRef: { name: "..." } }`。
|
|
222
252
|
|
|
223
|
-
**Platform-shared templates
|
|
224
|
-
|
|
225
|
-
Platform Default
|
|
226
|
-
|
|
227
|
-
echo-only template useful for smoke tests — it does **not** run an LLM.
|
|
253
|
+
**Platform-shared templates。** Platform Default project 拥有的模板(例如
|
|
254
|
+
`pilot-v2-pod-agent`)是共享基础设施:当调用方 Project 内找不到同名模板时,解析会回退到
|
|
255
|
+
Platform Default,因此任意 Project 的 Version 都可以按名称引用它们。`echo-bot`
|
|
256
|
+
是内置 echo-only 模板,适合 smoke test;它**不会**运行 LLM。
|
|
228
257
|
|
|
229
|
-
##
|
|
258
|
+
## 模型
|
|
230
259
|
|
|
231
|
-
`model`
|
|
232
|
-
|
|
260
|
+
`model` 接受完整 id(`claude-opus-4-7`、`claude-sonnet-4-6`、`claude-haiku-4-5`),
|
|
261
|
+
也接受会映射到完整 id 的历史别名:
|
|
233
262
|
|
|
234
|
-
| Alias |
|
|
263
|
+
| Alias | 解析为 |
|
|
235
264
|
| --- | --- |
|
|
236
265
|
| `opus` | `claude-opus-4-7` |
|
|
237
266
|
| `sonnet` | `claude-sonnet-4-6` |
|
|
@@ -239,15 +268,14 @@ echo-only template useful for smoke tests — it does **not** run an LLM.
|
|
|
239
268
|
|
|
240
269
|
## Dry runs
|
|
241
270
|
|
|
242
|
-
`
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
271
|
+
`agents.create`、`publishVersion` 和 `apply*` 方法都接受 `{ dryRun: true }`。
|
|
272
|
+
dry run 会校验并解析请求,但不持久化;返回 `mode: "dry_run"` 和
|
|
273
|
+
`would_create` / `would_update` 状态;Version 已存在且内容一致时可能返回
|
|
274
|
+
`existing`。正式发布前可以用它确认 runtime template 能正确解析。
|
|
246
275
|
|
|
247
|
-
##
|
|
276
|
+
## 错误
|
|
248
277
|
|
|
249
|
-
|
|
250
|
-
`requestId`:
|
|
278
|
+
所有 API 请求失败都会抛出类型化错误,错误对象带 `status`、`code` 和 `requestId`:
|
|
251
279
|
|
|
252
280
|
| Class | HTTP |
|
|
253
281
|
| --- | --- |
|
|
@@ -255,7 +283,7 @@ All API failures throw a typed error carrying `status`, `code`, and
|
|
|
255
283
|
| `PilotPlatformForbiddenError` | 403 |
|
|
256
284
|
| `PilotPlatformNotFoundError` | 404 |
|
|
257
285
|
| `PilotPlatformServerError` | 5xx |
|
|
258
|
-
| `PilotPlatformApiError` |
|
|
286
|
+
| `PilotPlatformApiError` | 上述错误的基类 |
|
|
259
287
|
|
|
260
288
|
```ts
|
|
261
289
|
import { PilotPlatformNotFoundError } from "@kanyun-ai-infra/agenthub";
|