@kanyun-ai-infra/agenthub 1.8.0 → 1.10.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 CHANGED
@@ -50,12 +50,10 @@ const agenthub = new PilotPlatformClient({
50
50
  // controlPlaneUrl 可省略——默认打线上地址;打 test 等环境再显式传(或设 PILOT_CONTROL_PLANE_URL)。
51
51
  });
52
52
 
53
- // 1. Project:租户 / 根分组。默认 runtime template 让发布 Version 时不必每次手选模板。
54
- const project = await agenthub.projects.create({
55
- slug: "acme",
56
- displayName: "Acme",
57
- defaultRuntimeTemplateRefName: "pilot-v2-pod-agent",
58
- });
53
+ // 1. Project:租户 / 根分组。模型服务按 Project 归属、目前只能在门户「凭证与集成」→「模型服务」
54
+ // 里配,所以这里用一个已经配好模型服务的 Project。新建用 agenthub.projects.create({ slug,
55
+ // displayName, defaultRuntimeTemplateRefName }),建完先去门户给它配一套模型服务。
56
+ const project = await agenthub.projects.get("<已配好模型服务的 Project id>");
59
57
 
60
58
  // 2. Agent:Project 下一个可运行的 agent。
61
59
  await agenthub.agents.create({
@@ -64,7 +62,6 @@ await agenthub.agents.create({
64
62
  displayName: "Support Bot",
65
63
  kind: "managed_agent",
66
64
  defaults: {
67
- model: "claude-opus-4-7",
68
65
  systemPrompt: "You are the Acme support agent.",
69
66
  agentPackage: {
70
67
  format: "claude_code",
@@ -87,7 +84,10 @@ const version = await agenthub.agents.publishVersion({
87
84
  workerContract: { kind: "managed_agent" },
88
85
  setDefault: true,
89
86
  managedAgentProfileSnapshot: {
90
- model: "claude-opus-4-7",
87
+ // 模型服务必填:没声明模型服务的 Agent 建不出会话(SESSION_LLM_PROVIDER_REQUIRED)。
88
+ // 填这个 Project 那套模型服务的 publicId(llmp_ 开头,门户列表里复制)。
89
+ // model 省略 = 用该模型服务声明的默认档位。
90
+ llmProviderRef: "llmp_xxxxxxxxxxxxxxxx",
91
91
  systemPrompt: "You are the Acme support agent.",
92
92
  },
93
93
  });
@@ -108,6 +108,23 @@ const ready = await agenthub.sessions.wait(session.sessionId); // status === "re
108
108
  > 要额外给槽位绑一个 Environment,才有资源规格定制、canary 灰度、drift 检测、
109
109
  > 一键回滚这些能力:完整走一遍见下方「完整参考」里的发布闭环六幕示例。
110
110
 
111
+ ### 代表用户调用(仅第一方服务)
112
+
113
+ 服务到服务的场景(门户、后台任务等)可以用**第一方服务 token** 声明「代表某个用户」:
114
+ 给客户端传 `actAs`(用户 LDAP),此后该客户端发出的**每个**请求——JSON、multipart
115
+ 上传、SSE(首连与带 `Last-Event-ID` 的重连)——都带代表声明头。
116
+
117
+ ```ts
118
+ const agenthub = new PilotPlatformClient({
119
+ token: process.env.PILOT_SERVICE_TOKEN, // 第一方服务 token(actor:delegate)
120
+ actAs: "zhangsan", // 代表 zhangsan 行事
121
+ });
122
+ ```
123
+
124
+ 仅第一方服务 token 可用:其他 token 带它会得到 403 `ACT_AS_NOT_ALLOWED`(服务端开关
125
+ 未开:403 `ACT_AS_DISABLED`;值不是用户标识:400 `ACT_AS_INVALID`)。空串 / 纯空白在
126
+ 构造时即抛。`defaultHeaders` 或单次请求的 `headers` 里写同名头不能覆盖 `actAs`。
127
+
111
128
  ## 核心模型
112
129
 
113
130
  ```text
@@ -192,7 +209,7 @@ App 里点的"对";`purge(projectId, { subjectKind, subjectId })` 按主体清
192
209
  | --- | --- |
193
210
  | `usage` | 模型用量(`inputTokens` / `outputTokens` / `totalTokens` 等)。其中 `costUsd` 是 Claude Code CLI **自报的列表价估算**(`costSource === "claude_code_cli"`),不是账单实付;`failed` / `aborted` 轮次没有 `usage`(T-INV-13)。`completed` 轮次也可能缺省——用量数据没通过校验时字段不落,并在该轮 `anomalies` 里记 `usage_parse_failed`。 |
194
211
  | `traceId` | 这一轮的分布式 trace id(`string \| null`),可拼 Octopus trace-explorer 深链定位整条链路(agenthub → control-worker → agent-worker)。 |
195
- | `memoryRecall.state` | **只在会话首轮出现**——设计如此,不是版本或故障问题:读服务只给首轮投影这个字段(`session-turns-read-service.ts` 的 `core.turnId === enrichment.firstTurnId` 判据),第 2 轮起 `memoryRecall` 恒为 `undefined`,即便服务端是最新版。值是这一轮的**记忆召回状态**枚举,不是召回内容:`selected`(召回并注入了条目)/ `empty`(功能开着、也查了,本轮无可注入记忆)/ `recall_failed`(召回过程失败)/ `unavailable`(回读时没能解出召回快照)/ `legacy`(会话早于记忆机制,无快照)。目前只对外暴露状态,召回内容展示挂在另一条线(#1837)。 |
212
+ | `memoryRecall.state` | **只在会话首轮出现**——设计如此,不是版本或故障问题:读服务只给首轮投影这个字段(`session-turns-read-service.ts` 的 `core.turnId === enrichment.firstTurnId` 判据),第 2 轮起 `memoryRecall` 恒为 `undefined`,即便服务端是最新版。值是这一轮的**记忆召回状态**枚举,不是召回内容:`selected`(召回并注入了条目)/ `empty`(功能开着、也查了,本轮无可注入记忆)/ `recall_failed`(召回过程失败)/ `unavailable`(回读时没能解出召回快照)/ `legacy`(会话早于记忆机制,无快照)。目前只对外暴露状态,不含召回内容。 |
196
213
 
197
214
  三个字段都是可选/可空的:`usage` 与 `memoryRecall` 是可选字段,`traceId` 可空、没有
198
215
  链路时为 `null`。写消费代码时一律按「缺失」处理,不要假定它们一定存在。