@kanyun-ai-infra/agenthub 1.37.0 → 1.38.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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  本文件从 1.12.0 开始记录;更早的版本见 git 历史中的 `chore(agenthub-sdk): release X.Y.Z` 提交。
4
4
 
5
+ ## 1.38.0
6
+
7
+ - `sessions.create` 的 `repositories` 可带只拉条目(card-5163):`{ type: "git_repository", url, ref?, credentialRef, delivery: { mode: "pull_only" }, mountPath }`。仓库克隆到沙箱 `/workspace/repos/<mountPath>`,每轮开始重置到分支最新提交(只重置已跟踪文件),不推、不开 MR;`ref` 省略取远端默认分支,建会话时冻结。推回至多 1 项、只拉至多 1 项、顺序不限;同一仓库或同一 `mountPath` 不能出现两次,`mountPath` 为 1–32 位 `[a-z0-9-]`、字母或数字开头,只拉 `ref` 须是普通分支名,这些在发请求前抛错。凭据可以是 `access: "read"` 的只读凭据。新错误码:建会话 400 `PULL_REPOSITORIES_DISABLED`(开关关)、400 `PULL_REPOSITORIES_UNSUPPORTED_RUNTIME`(沙箱镜像不支持)、400 `PULL_REF_NOT_FOUND`(分支不存在);发回合 409 `PULL_REPOSITORY_REJECTED`(`details.reason` 为 `pull_repo:access_revoked` / `pull_repo:credential_invalid` / `pull_repo:disabled`,活会话不终止;休眠后复活的那一轮被拒时会话终止,终止理由记同一个 `pull_repo:*`,换凭据后再发一轮即重新复活)。每轮发会话事件 `agent.pull_repo_synced`(`{ turnId, mountPath, ref, head }`)。需要服务端已部署该能力并打开开关,旧服务端拒收只拉条目。
8
+
9
+ - 新导出会话仓库资源的类型与 schema(card-5163):`GitRepositoryResource`、`PullRepositoryResource`、`SessionRepositoryResource`、`VaultCredentialRef` 及对应 `*Schema`,`SessionRepositoriesSchema`,常量 `MAX_PUSH_BACK_REPOSITORIES`、`MAX_PULL_REPOSITORIES`、`PULL_REPO_MOUNT_PATH_PATTERN`、`PULL_REPOSITORY_REJECTED`,类型 `PullRepositoryRejectedReason`;以及 `GIT_TOKEN_ACCESS_VALUES` / `GitTokenAccess`。
10
+
11
+ - `vaults.credentials.create` 的 `git_token` 凭据新增可选 `access`(card-5163):`"write"` 或 `"read"`,不带即 `"write"`,与此前相同。`write` 探测仍要求仓库上 Developer;`read` 只要求 Reporter,只读令牌因此可以存进 vault。`read` 凭据只能给会话的只拉仓库用;推回条目引用它,建会话回 400 `REPO_CREDENTIAL_READ_ONLY`。轮换沿用同一阈值。记录在带了时回显 `access`。建好后不可改:`update` 带 `auth.access` 会在发请求前被拒,服务端回 400 `vault_credential_immutable_field_mutation`。同一 vault 同一仓库仍只能有一把活跃凭据,读或写二选一。取值不是 `read` / `write` 在发请求前抛错。需要服务端已部署该能力,旧服务端拒收这个字段。
12
+ - 项目推回策略的读回与并发安全写(card-5164),scope 都是 `project:settings`:
13
+ - 新增 `projects.repo.getPushBackPolicy(projectId)`:返回 `{ projectId, branchPatterns, etag }`。`etag` 由存储的列表算出,列表不变它就不变。
14
+ - 新增 `projects.repo.updatePushBackPolicy(projectId, { add?, remove? }, { ifMatch? })`:服务端在一次比较并交换里把 `add` 加到列表末尾、把 `remove` 删掉,不动其他模式;多个调用方共用一个项目时用它改各自的模式,不必先读。加已有的、删没有的都不改变列表。两边都为空或同一模式同时出现在两边,在发请求前抛错;只校验 `add` 里的模式(规则同 `setPushBackPolicy`),合并后超过 50 条回 400 `VALIDATION_ERROR`。删掉模式后,分支不再符合的 `push_back` 会话照旧被终止。
15
+ - `setPushBackPolicy` 新增可选 `{ ifMatch }`:带上读回的 `etag`,存储的列表变了就回 412 `PUSH_BACK_POLICY_PRECONDITION_FAILED`,`error.body` 带当前的 `branchPatterns` 与 `etag`,不写入、不终止会话。不带时与此前相同,后写者赢。返回值多一个可选 `etag`(旧服务端不返回)。
16
+ - 新导出 `PatchPushBackPolicyRequestSchema`、`PushBackPolicyStateSchema`、`PUSH_BACK_POLICY_PRECONDITION_FAILED` 及对应类型。
17
+ - 需要服务端已部署该能力;旧服务端对 `GET` 与 `PATCH` 回 405,对 `If-Match` 不做判断。
18
+
5
19
  ## 1.37.0
6
20
 
7
21
  - `vaults.credentials.create` 的 `git_token` 凭据新增可选 `username`(card-5049):沙箱克隆、拉取这个仓库时给 git 的 HTTP Basic 用户名。不带时为 `x-access-token`,与此前相同。GitLab OAuth 令牌只在用户名为 `oauth2` 时被接受,存这类令牌要带 `username: "oauth2"`。只许 1–64 位字母、数字、`.`、`_`、`-`,字母或数字开头,不合规在发请求前抛错。记录在带了时回显 `username`。建好后不可改:`update` 带 `auth.username` 会在发请求前被拒,服务端回 400 `vault_credential_immutable_field_mutation`。要换一种令牌就归档旧凭据再新建。需要服务端已部署该能力,旧服务端拒收这个字段。
package/dist/index.cjs CHANGED
@@ -69,6 +69,8 @@ __export(src_exports, {
69
69
  EvalRunDiffResponseReadSchema: () => EvalRunDiffResponseReadSchema,
70
70
  EvalsResource: () => EvalsResource,
71
71
  FilesResource: () => FilesResource,
72
+ GIT_TOKEN_ACCESS_VALUES: () => GIT_TOKEN_ACCESS_VALUES,
73
+ GitRepositoryResourceSchema: () => GitRepositoryResourceSchema,
72
74
  ListMemoriesQuerySchema: () => ListMemoriesQuerySchema,
73
75
  ListMemorySubjectPoliciesResultSchema: () => ListMemorySubjectPoliciesResultSchema,
74
76
  ListPipelineRunsResponseSchema: () => ListPipelineRunsResponseSchema,
@@ -82,6 +84,8 @@ __export(src_exports, {
82
84
  MAX_MEMORY_CONTENT_CHARS: () => MAX_MEMORY_CONTENT_CHARS,
83
85
  MAX_MEMORY_SUBJECT_POLICIES: () => MAX_MEMORY_SUBJECT_POLICIES,
84
86
  MAX_MEMORY_WRITE_BATCH: () => MAX_MEMORY_WRITE_BATCH,
87
+ MAX_PULL_REPOSITORIES: () => MAX_PULL_REPOSITORIES,
88
+ MAX_PUSH_BACK_REPOSITORIES: () => MAX_PUSH_BACK_REPOSITORIES,
85
89
  MAX_SESSION_MEMORY_SUBJECTS: () => MAX_SESSION_MEMORY_SUBJECTS,
86
90
  MAX_WEBHOOK_EVENT_ID_LENGTH: () => MAX_WEBHOOK_EVENT_ID_LENGTH,
87
91
  MAX_WEBHOOK_SUBSCRIPTIONS_PER_PROJECT: () => MAX_WEBHOOK_SUBSCRIPTIONS_PER_PROJECT,
@@ -98,6 +102,10 @@ __export(src_exports, {
98
102
  PILOT_WORKLOAD_MANIFEST_API_VERSION: () => PILOT_WORKLOAD_MANIFEST_API_VERSION,
99
103
  PILOT_WORKLOAD_MANIFEST_LEGACY_API_VERSION: () => PILOT_WORKLOAD_MANIFEST_LEGACY_API_VERSION,
100
104
  PIPELINE_API_ERROR_CODES: () => PIPELINE_API_ERROR_CODES,
105
+ PULL_REPOSITORY_REJECTED: () => PULL_REPOSITORY_REJECTED,
106
+ PULL_REPO_MOUNT_PATH_PATTERN: () => PULL_REPO_MOUNT_PATH_PATTERN,
107
+ PUSH_BACK_POLICY_PRECONDITION_FAILED: () => PUSH_BACK_POLICY_PRECONDITION_FAILED,
108
+ PatchPushBackPolicyRequestSchema: () => PatchPushBackPolicyRequestSchema,
101
109
  PilotPlatformApiError: () => PilotPlatformApiError,
102
110
  PilotPlatformClient: () => PilotPlatformClient,
103
111
  PilotPlatformForbiddenError: () => PilotPlatformForbiddenError,
@@ -120,9 +128,11 @@ __export(src_exports, {
120
128
  ProjectsResource: () => ProjectsResource,
121
129
  PromoteResponseSchema: () => PromoteResponseSchema,
122
130
  PublishPlatformRevisionRequestSchema: () => PublishPlatformRevisionRequestSchema,
131
+ PullRepositoryResourceSchema: () => PullRepositoryResourceSchema,
123
132
  PurgeSubjectMemoriesRequestSchema: () => PurgeSubjectMemoriesRequestSchema,
124
133
  PurgeSubjectMemoriesResultSchema: () => PurgeSubjectMemoriesResultSchema,
125
134
  PushBackPolicySchema: () => PushBackPolicySchema,
135
+ PushBackPolicyStateSchema: () => PushBackPolicyStateSchema,
126
136
  PutMemorySubjectPoliciesRequestSchema: () => PutMemorySubjectPoliciesRequestSchema,
127
137
  PutStageRequestSchema: () => PutStageRequestSchema,
128
138
  PutStageResponseSchema: () => PutStageResponseSchema,
@@ -143,6 +153,8 @@ __export(src_exports, {
143
153
  SessionDiagnosisDTOSchema: () => SessionDiagnosisDTOSchema,
144
154
  SessionFileResourceSchema: () => SessionFileResourceSchema,
145
155
  SessionMemorySubjectDeclarationSchema: () => SessionMemorySubjectDeclarationSchema,
156
+ SessionRepositoriesSchema: () => SessionRepositoriesSchema,
157
+ SessionRepositoryResourceSchema: () => SessionRepositoryResourceSchema,
146
158
  SessionResourcesSchema: () => SessionResourcesSchema,
147
159
  SessionTerminateRequestSchema: () => SessionTerminateRequestSchema,
148
160
  SessionTerminateResponseSchema: () => SessionTerminateResponseSchema,
@@ -184,6 +196,7 @@ __export(src_exports, {
184
196
  UPSTREAM_RATE_LIMITED_CODE: () => UPSTREAM_RATE_LIMITED_CODE,
185
197
  UpdateEnvironmentInputSchema: () => UpdateEnvironmentInputSchema,
186
198
  UpdateWebhookSubscriptionRequestSchema: () => UpdateWebhookSubscriptionRequestSchema,
199
+ VaultCredentialRefSchema: () => VaultCredentialRefSchema,
187
200
  VaultCredentialsResource: () => VaultCredentialsResource,
188
201
  VaultsResource: () => VaultsResource,
189
202
  WEBHOOK_EVENT_TYPES: () => WEBHOOK_EVENT_TYPES,
@@ -1159,6 +1172,7 @@ var StaticBearerCredentialSchema = import_zod11.z.object({
1159
1172
  }).strict();
1160
1173
  var GIT_REPO_PATH_PATTERN = /^(?!.*\.git$)[A-Za-z0-9_][A-Za-z0-9_.-]*(?:\/[A-Za-z0-9_][A-Za-z0-9_.-]*)+$/;
1161
1174
  var GIT_TOKEN_USERNAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
1175
+ var GIT_TOKEN_ACCESS_VALUES = ["read", "write"];
1162
1176
  var GitTokenCredentialSchema = import_zod11.z.object({
1163
1177
  type: import_zod11.z.literal("git_token"),
1164
1178
  gitOrigin: import_zod11.z.string().url().max(2048),
@@ -1166,7 +1180,14 @@ var GitTokenCredentialSchema = import_zod11.z.object({
1166
1180
  /** Write-only; never returned. */
1167
1181
  accessToken: import_zod11.z.string().min(1),
1168
1182
  expiresAt: import_zod11.z.string().datetime().optional(),
1169
- username: import_zod11.z.string().regex(GIT_TOKEN_USERNAME_PATTERN).optional()
1183
+ username: import_zod11.z.string().regex(GIT_TOKEN_USERNAME_PATTERN).optional(),
1184
+ /**
1185
+ * Omitted = `write`, exactly as before the field existed. The pre-write probe
1186
+ * (create and every rotation) requires Developer (30) for `write`, Reporter
1187
+ * (20) for `read`. Immutable after create: a read token and a write token for
1188
+ * the same repository are different credentials.
1189
+ */
1190
+ access: import_zod11.z.enum(GIT_TOKEN_ACCESS_VALUES).optional()
1170
1191
  }).strict();
1171
1192
  var CreateVaultRequestSchema = import_zod11.z.object({
1172
1193
  workspaceId: import_zod11.z.string().uuid(),
@@ -1255,6 +1276,8 @@ var GitTokenVaultCredentialRecordSchema = import_zod11.z.object({
1255
1276
  repoPath: import_zod11.z.string().min(1),
1256
1277
  /** Present only when the credential was created with one (not secret). */
1257
1278
  username: import_zod11.z.string().min(1).optional(),
1279
+ /** Present only when the credential was created with one; absent = `write`. */
1280
+ access: import_zod11.z.enum(GIT_TOKEN_ACCESS_VALUES).optional(),
1258
1281
  expiresAt: import_zod11.z.string().datetime().nullable(),
1259
1282
  secretRotatedAt: import_zod11.z.string().datetime().nullable(),
1260
1283
  rotationSeq: import_zod11.z.number().int().nonnegative(),
@@ -3161,10 +3184,34 @@ function isPushBackBranchName(branch) {
3161
3184
  var SetPushBackPolicyRequestSchema = import_zod34.z.object({
3162
3185
  branchPatterns: import_zod34.z.array(import_zod34.z.string().min(1).max(257)).max(PUSH_BACK_PATTERNS_MAX)
3163
3186
  }).strict();
3187
+ var PushBackPatternListSchema = import_zod34.z.array(import_zod34.z.string().min(1).max(257)).max(PUSH_BACK_PATTERNS_MAX);
3188
+ var PatchPushBackPolicyRequestSchema = import_zod34.z.object({
3189
+ add: PushBackPatternListSchema.optional(),
3190
+ remove: PushBackPatternListSchema.optional()
3191
+ }).strict().superRefine((body, ctx) => {
3192
+ var _a, _b;
3193
+ const add = (_a = body.add) != null ? _a : [];
3194
+ const remove = new Set((_b = body.remove) != null ? _b : []);
3195
+ if (add.length === 0 && remove.size === 0) {
3196
+ ctx.addIssue({ code: "custom", message: "add or remove must name a pattern" });
3197
+ return;
3198
+ }
3199
+ const both = add.find((pattern) => remove.has(pattern));
3200
+ if (both !== void 0) {
3201
+ ctx.addIssue({
3202
+ code: "custom",
3203
+ path: ["add"],
3204
+ message: `Pattern '${both}' is in both add and remove`
3205
+ });
3206
+ }
3207
+ });
3164
3208
  var PushBackPolicySchema = import_zod34.z.object({
3165
3209
  projectId: import_zod34.z.string(),
3166
- branchPatterns: import_zod34.z.array(import_zod34.z.string())
3210
+ branchPatterns: import_zod34.z.array(import_zod34.z.string()),
3211
+ etag: import_zod34.z.string().optional()
3167
3212
  });
3213
+ var PushBackPolicyStateSchema = PushBackPolicySchema.extend({ etag: import_zod34.z.string() });
3214
+ var PUSH_BACK_POLICY_PRECONDITION_FAILED = "PUSH_BACK_POLICY_PRECONDITION_FAILED";
3168
3215
  var PodAgentPushBackPolicySchema = import_zod34.z.object({
3169
3216
  mode: import_zod34.z.literal("push_back"),
3170
3217
  /** The repo's default branch; pushing to it is refused. */
@@ -3176,6 +3223,27 @@ var PodAgentPushBackPolicySchema = import_zod34.z.object({
3176
3223
  /** PB-11: the session's frozen commit author email. */
3177
3224
  authorEmail: import_zod34.z.string().min(1).optional()
3178
3225
  }).strict();
3226
+ var PULL_REPO_MOUNT_PATH_PATTERN = /^[a-z0-9][a-z0-9-]{0,31}$/;
3227
+ var POD_AGENT_PULL_REPOS_MAX = 16;
3228
+ var PodAgentPullRepoSchema = import_zod34.z.object({
3229
+ repoUrl: import_zod34.z.string().min(1),
3230
+ /** The frozen branch; every turn resets the clone to its remote head. */
3231
+ branch: import_zod34.z.string().min(1),
3232
+ mountPath: import_zod34.z.string().regex(PULL_REPO_MOUNT_PATH_PATTERN)
3233
+ }).strict();
3234
+ var PodAgentPullReposSchema = import_zod34.z.array(PodAgentPullRepoSchema).min(1).max(POD_AGENT_PULL_REPOS_MAX).superRefine((repos, ctx) => {
3235
+ const seen = /* @__PURE__ */ new Set();
3236
+ for (const [index, repo] of repos.entries()) {
3237
+ if (seen.has(repo.mountPath)) {
3238
+ ctx.addIssue({
3239
+ code: import_zod34.z.ZodIssueCode.custom,
3240
+ path: [index, "mountPath"],
3241
+ message: `duplicate mountPath '${repo.mountPath}'`
3242
+ });
3243
+ }
3244
+ seen.add(repo.mountPath);
3245
+ }
3246
+ });
3179
3247
  var PodAgentRondoPushPolicySchema = import_zod34.z.object({
3180
3248
  mode: import_zod34.z.literal("rondo"),
3181
3249
  /** The session's `repoUrl`; clone of any other repo is refused. */
@@ -3187,11 +3255,21 @@ var PodAgentRondoPushPolicySchema = import_zod34.z.object({
3187
3255
  /** The session's frozen `pushBackPaths` (RS-2 globs). */
3188
3256
  paths: import_zod34.z.array(import_zod34.z.string().min(1)).optional(),
3189
3257
  /** PB-11: the session's frozen commit author email. */
3190
- authorEmail: import_zod34.z.string().min(1).optional()
3258
+ authorEmail: import_zod34.z.string().min(1).optional(),
3259
+ /**
3260
+ * P1: pull-only repositories next to the pinned one; absent = none. Not
3261
+ * checked by {@link missingRondoPushPolicyField}: absence is a valid value.
3262
+ */
3263
+ pullRepos: PodAgentPullReposSchema.optional()
3264
+ }).strict();
3265
+ var PodAgentPullOnlyPolicySchema = import_zod34.z.object({
3266
+ mode: import_zod34.z.literal("pull_only"),
3267
+ pullRepos: PodAgentPullReposSchema
3191
3268
  }).strict();
3192
3269
  var PodAgentPushPolicySchema = import_zod34.z.discriminatedUnion("mode", [
3193
3270
  PodAgentPushBackPolicySchema,
3194
- PodAgentRondoPushPolicySchema
3271
+ PodAgentRondoPushPolicySchema,
3272
+ PodAgentPullOnlyPolicySchema
3195
3273
  ]);
3196
3274
  var PUSH_BACK_PATHS_MAX = 50;
3197
3275
  var PUSH_BACK_PATH_MAX_LENGTH = 255;
@@ -4333,7 +4411,9 @@ var SessionPreviewSchema = import_zod37.z.object({
4333
4411
  var SessionPreviewResponseSchema = import_zod37.z.object({
4334
4412
  preview: SessionPreviewSchema.nullable()
4335
4413
  });
4336
- var MAX_SESSION_REPOSITORIES = 1;
4414
+ var MAX_PUSH_BACK_REPOSITORIES = 1;
4415
+ var MAX_PULL_REPOSITORIES = 1;
4416
+ var MAX_SESSION_REPOSITORIES = MAX_PUSH_BACK_REPOSITORIES + MAX_PULL_REPOSITORIES;
4337
4417
  var VaultCredentialRefSchema = import_zod38.z.object({
4338
4418
  type: import_zod38.z.literal("vault_credential"),
4339
4419
  id: import_zod38.z.string().regex(/^vcrd_[a-zA-Z0-9]+$/)
@@ -4354,7 +4434,77 @@ var GitRepositoryResourceSchema = import_zod38.z.object({
4354
4434
  allowedPaths: import_zod38.z.array(import_zod38.z.string().max(PUSH_BACK_PATH_MAX_LENGTH * 4)).max(PUSH_BACK_PATHS_MAX * 10)
4355
4435
  }).strict()
4356
4436
  }).strict();
4357
- var SessionRepositoriesSchema = import_zod38.z.array(GitRepositoryResourceSchema).min(1).max(MAX_SESSION_REPOSITORIES);
4437
+ var PullRepositoryResourceSchema = import_zod38.z.object({
4438
+ type: import_zod38.z.literal("git_repository"),
4439
+ /** `https` clone URL on the credential's GitLab instance. */
4440
+ url: import_zod38.z.string().min(1).max(2048),
4441
+ /** The branch to follow; omitted = the remote default branch, resolved and frozen at creation. */
4442
+ ref: import_zod38.z.string().min(1).max(255).optional(),
4443
+ credentialRef: VaultCredentialRefSchema,
4444
+ delivery: import_zod38.z.object({ mode: import_zod38.z.literal("pull_only") }).strict(),
4445
+ /** `/workspace/repos/<mountPath>`: 1–32 of `[a-z0-9-]`, starting with a letter or digit. */
4446
+ mountPath: import_zod38.z.string().regex(PULL_REPO_MOUNT_PATH_PATTERN)
4447
+ }).strict();
4448
+ var SessionRepositoryResourceSchema = import_zod38.z.union([
4449
+ GitRepositoryResourceSchema,
4450
+ PullRepositoryResourceSchema
4451
+ ]);
4452
+ function isPullRepositoryResource(resource) {
4453
+ return resource.delivery.mode === "pull_only";
4454
+ }
4455
+ function sessionRepositoryKey(url) {
4456
+ let value = url.trim();
4457
+ while (value.endsWith("/")) value = value.slice(0, -1);
4458
+ if (value.endsWith(".git")) value = value.slice(0, -".git".length);
4459
+ while (value.endsWith("/")) value = value.slice(0, -1);
4460
+ return value;
4461
+ }
4462
+ var SessionRepositoriesSchema = import_zod38.z.array(SessionRepositoryResourceSchema).min(1).max(MAX_SESSION_REPOSITORIES).superRefine((repositories, ctx) => {
4463
+ const pushBack = repositories.filter((r) => !isPullRepositoryResource(r));
4464
+ const pull = repositories.filter(isPullRepositoryResource);
4465
+ if (pushBack.length > MAX_PUSH_BACK_REPOSITORIES) {
4466
+ ctx.addIssue({
4467
+ code: import_zod38.z.ZodIssueCode.custom,
4468
+ message: `repositories may hold at most ${MAX_PUSH_BACK_REPOSITORIES} push_back repository`
4469
+ });
4470
+ }
4471
+ if (pull.length > MAX_PULL_REPOSITORIES) {
4472
+ ctx.addIssue({
4473
+ code: import_zod38.z.ZodIssueCode.custom,
4474
+ message: `repositories may hold at most ${MAX_PULL_REPOSITORIES} pull_only repository`
4475
+ });
4476
+ }
4477
+ const mountPaths = /* @__PURE__ */ new Set();
4478
+ const repos = /* @__PURE__ */ new Set();
4479
+ for (const [index, repository] of repositories.entries()) {
4480
+ const key = sessionRepositoryKey(repository.url).toLowerCase();
4481
+ if (repos.has(key)) {
4482
+ ctx.addIssue({
4483
+ code: import_zod38.z.ZodIssueCode.custom,
4484
+ path: [index, "url"],
4485
+ message: "two repositories name the same repository"
4486
+ });
4487
+ }
4488
+ repos.add(key);
4489
+ if (!isPullRepositoryResource(repository)) continue;
4490
+ if (mountPaths.has(repository.mountPath)) {
4491
+ ctx.addIssue({
4492
+ code: import_zod38.z.ZodIssueCode.custom,
4493
+ path: [index, "mountPath"],
4494
+ message: `duplicate mountPath '${repository.mountPath}'`
4495
+ });
4496
+ }
4497
+ mountPaths.add(repository.mountPath);
4498
+ if (repository.ref !== void 0 && !isPushBackBranchName(repository.ref)) {
4499
+ ctx.addIssue({
4500
+ code: import_zod38.z.ZodIssueCode.custom,
4501
+ path: [index, "ref"],
4502
+ message: "a pull_only ref must be a plain branch name"
4503
+ });
4504
+ }
4505
+ }
4506
+ });
4507
+ var PULL_REPOSITORY_REJECTED = "PULL_REPOSITORY_REJECTED";
4358
4508
  var PLATFORM_DEFAULT_PROJECT_ID = "00000000-0000-0000-0000-000000000001";
4359
4509
  var PlatformProjectIdSchema = import_zod39.z.union([
4360
4510
  import_zod39.z.string().uuid(),
@@ -4638,6 +4788,12 @@ var FailureReasonCodeSchema = import_zod16.z.enum([
4638
4788
  * 那是 `push_back:repo_credential_invalid`。`source: control_plane`。
4639
4789
  */
4640
4790
  "REPO_CHECK_UNAVAILABLE",
4791
+ /**
4792
+ * P2(note 2026-12-05-session-multi-repo-pull-only-ref-guard):只拉仓库的凭据这一轮读不到它
4793
+ * (凭据 / vault 已归档、权限低于 Reporter、GitLab 拒 token、开关关),复活重放的那一轮不发;
4794
+ * 会话不终止,换凭据后下一轮照常。`source: control_plane`。
4795
+ */
4796
+ "PULL_REPOSITORY_REJECTED",
4641
4797
  /**
4642
4798
  * liveFirst upgrade handoff(MAP-VL9):移交扫描在整个复活预算耗尽、升级链仍未收场时
4643
4799
  * 记下的事实——扫描自己观察到的就是「链没在预算内完成」,所以恒落本值,不抄链内
@@ -5637,7 +5793,8 @@ var CreateSessionRequestSchema = import_zod16.z.object({
5637
5793
  pushBackPaths: import_zod16.z.array(import_zod16.z.string().max(PUSH_BACK_PATH_MAX_LENGTH * 4)).max(PUSH_BACK_PATHS_MAX * 10).optional(),
5638
5794
  /**
5639
5795
  * 会话仓库资源:把会话钉在一个仓库上(可以不是项目绑定的仓库),每轮改动用调用方自己存在
5640
- * vault 里的 `git_token` 凭据推回 `ref` 分支。目前最多 1 项;与 `repoUrl` / `repoRef` /
5796
+ * vault 里的 `git_token` 凭据推回 `ref` 分支。另可带只拉条目(`delivery.mode: "pull_only"`,
5797
+ * 落在 `/workspace/repos/<mountPath>`,每轮重置、不推)。推回至多 1 项、只拉至多 1 项;与 `repoUrl` / `repoRef` /
5641
5798
  * `deliveryMode` / `pushBackPaths` 互斥。调用方的 token 须带 `vaults:read`(或 `vaults:admin`),
5642
5799
  * 凭据须属于本项目、归调用方所有且未归档,否则 403 `REPO_RESOURCE_NOT_ALLOWED`;`url` 须是
5643
5800
  * 凭据登记的那个仓库,`ref` 须已存在且该凭据可推。带此字段的请求不走预热池。
@@ -5691,7 +5848,10 @@ var CreateSessionRequestSchema = import_zod16.z.object({
5691
5848
  path: ["repositories"]
5692
5849
  }
5693
5850
  ).refine(
5694
- (data) => data.commitAuthor === void 0 || data.deliveryMode === "push_back" || data.repositories !== void 0,
5851
+ (data) => {
5852
+ var _a, _b;
5853
+ return data.commitAuthor === void 0 || data.deliveryMode === "push_back" || ((_b = (_a = data.repositories) == null ? void 0 : _a.some((r) => r.delivery.mode === "push_back")) != null ? _b : false);
5854
+ },
5695
5855
  {
5696
5856
  message: "COMMIT_AUTHOR_REQUIRES_PUSH_BACK: commitAuthor only applies to deliveryMode 'push_back'",
5697
5857
  path: ["commitAuthor"]
@@ -8098,6 +8258,13 @@ var DeclaredMcpToolsSchema = import_zod51.z.record(
8098
8258
  import_zod51.z.string().min(1).max(200),
8099
8259
  import_zod51.z.array(ManagedMcpToolNameSchema).max(MANAGED_MCP_TOOL_LIST_MAX_LENGTH)
8100
8260
  );
8261
+ var PullRepositoryRunConfigSchema = import_zod51.z.object({
8262
+ /** `<workspace>/repos/<mountPath>`; the pod-agent lease lists the same value. */
8263
+ mountPath: import_zod51.z.string().regex(PULL_REPO_MOUNT_PATH_PATTERN),
8264
+ url: import_zod51.z.string().min(1),
8265
+ /** The frozen branch; each turn resets the clone to its remote head. */
8266
+ ref: import_zod51.z.string().min(1)
8267
+ }).strict();
8101
8268
  var PilotCoderRunConfigV1Schema = import_zod51.z.object({
8102
8269
  runId: import_zod51.z.string().min(1),
8103
8270
  agentId: import_zod51.z.string().min(1),
@@ -8349,7 +8516,19 @@ var PilotCoderRunConfigV1Schema = import_zod51.z.object({
8349
8516
  * not receive it: a trimmed `llmUpstream` would silently run the turn on
8350
8517
  * the session's model service.
8351
8518
  */
8352
- llmUpstream: LlmUpstreamRunConfigSchema.optional()
8519
+ llmUpstream: LlmUpstreamRunConfigSchema.optional(),
8520
+ /**
8521
+ * Pull-only repositories (note 2026-12-05-session-multi-repo-pull-only-ref-guard,
8522
+ * P1 / P2): each is cloned into `<workspace>/repos/<mountPath>` through
8523
+ * pod-agent, reset to the remote head of `ref` at the start of every turn
8524
+ * (tracked files only; untracked and ignored files stay), and never pushed.
8525
+ * The agent's working directory stays the push_back clone, or the workspace
8526
+ * root without one. Any clone or reset failure fails the turn.
8527
+ *
8528
+ * WC-1 v8, required (WC-3): a trimmed list would run the turn without code
8529
+ * the caller was told is mounted, so an older Pod is refused instead.
8530
+ */
8531
+ pullRepositories: import_zod51.z.array(PullRepositoryRunConfigSchema).min(1).optional()
8353
8532
  }).strict();
8354
8533
  function runConfigFieldContractVersions(contract) {
8355
8534
  if (contract === null) return [];
@@ -8404,7 +8583,9 @@ var RUN_CONFIG_FIELD_MIN_CONTRACT_VERSION = {
8404
8583
  turnBudget: 5,
8405
8584
  turnPricebook: 6,
8406
8585
  // Per-turn model upstream (card-4551): the claude_code executor binds the turn at the pod-agent.
8407
- llmUpstream: 7
8586
+ llmUpstream: 7,
8587
+ // Pull-only repositories (note 2026-12-05 P1 / P2): required, see the field.
8588
+ pullRepositories: 8
8408
8589
  };
8409
8590
  var RUN_CONFIG_CONTRACT_VERSION = Math.max(
8410
8591
  0,
@@ -8613,6 +8794,35 @@ var PodAgentGitSyncResponseSchema = import_zod54.z.discriminatedUnion("kind", [
8613
8794
  ]).optional()
8614
8795
  })
8615
8796
  ]);
8797
+ var PodAgentGitPullSyncRequestSchema = import_zod54.z.object({
8798
+ leaseToken: import_zod54.z.string().min(1),
8799
+ workspaceDir: import_zod54.z.string().refine((s) => s.startsWith("/"), {
8800
+ message: "workspaceDir must be an absolute path"
8801
+ })
8802
+ }).strict();
8803
+ var PodAgentGitPullSyncResponseSchema = import_zod54.z.discriminatedUnion("kind", [
8804
+ import_zod54.z.object({
8805
+ kind: import_zod54.z.literal("ok"),
8806
+ /** Bare repository holding `refs/heads/<branch>`; replaced by the next pull-sync of the same mountPath. */
8807
+ gitDir: import_zod54.z.string().min(1),
8808
+ branch: import_zod54.z.string().min(1),
8809
+ branchSha: GitShaSchema
8810
+ }),
8811
+ import_zod54.z.object({
8812
+ kind: import_zod54.z.literal("failed"),
8813
+ reason: import_zod54.z.string().min(1),
8814
+ code: import_zod54.z.enum([
8815
+ "AUTH_FETCH_FAILED",
8816
+ "INVALID_WORKSPACE",
8817
+ "INTERNAL",
8818
+ "TRANSPORT_FAILED",
8819
+ // The lease does not list this workspace as a pull-only repository.
8820
+ "PUSH_POLICY_VIOLATION",
8821
+ // The branch does not exist on the remote.
8822
+ "REMOTE_MISSING"
8823
+ ]).optional()
8824
+ })
8825
+ ]);
8616
8826
  var TurnIdSchema = import_zod55.z.string().min(1).max(MODEL_CALL_ID_MAX_LENGTH).regex(/^[^\s\u0000-\u001f\u007f]+$/, "turnId must not contain whitespace or control characters");
8617
8827
  var PodAgentLlmTurnBindRequestSchema = import_zod55.z.object({ turnId: TurnIdSchema }).strict();
8618
8828
  var PodAgentLlmTurnUnbindRequestSchema = import_zod55.z.object({ turnId: TurnIdSchema.optional() }).strict();
@@ -9234,9 +9444,7 @@ var SESSION_ADMISSION_REJECTIONS = {
9234
9444
  },
9235
9445
  [GLOBAL_SESSION_LIMIT_EXCEEDED_CODE]: { status: 503, retryAfterSeconds: 30 },
9236
9446
  [STARTUP_QUEUE_SATURATED_CODE]: { status: 503, retryAfterSeconds: 30 },
9237
- // 冷却是窗口滑过去,所以 `Retry-After` **只能**是窗口长度,不能沿用邻居的 30s:
9238
- // 熔断态派生自最近 N 次启动结论,早于窗口滑完重试必然再被拒。这一项的值随 env 变
9239
- // (见下面的覆盖),表里放的是默认窗口。
9447
+ // 无冷却截止时刻的保守默认值。实际建会话的熔断拒绝提供截止时刻。
9240
9448
  [PROJECT_CIRCUIT_OPEN_CODE]: {
9241
9449
  status: 503,
9242
9450
  retryAfterSeconds: PROJECT_STARTUP_BREAKER_WINDOW_MINUTES * 60
@@ -10313,6 +10521,7 @@ var PatchPlatformTokenRequestSchema = import_zod70.z.object({
10313
10521
  var X_PILOT_API_VERSION_HEADER = "x-pilot-api-version";
10314
10522
  var LIVE_TOOL_RESULT_MAX_BYTES = 16 * 1024;
10315
10523
  var CredentialsBrokerRequestSchema = import_zod71.z.object({}).strict();
10524
+ var GitProviderCredentialRequestSchema = import_zod71.z.object({ repoUrl: import_zod71.z.string().min(1).max(2048).optional() }).strict();
10316
10525
  var GitProviderCredentialSchema = import_zod71.z.object({
10317
10526
  /**
10318
10527
  * Git hosting provider name.
@@ -18861,10 +19070,8 @@ var PipelineRunWorkloadSchema = import_zod110.z.object({
18861
19070
  /**
18862
19071
  * #3781 deep-link companions to `evalVerdict`: the conclusion id the verdict
18863
19072
  * was folded from (`eval_conclusions.id`, max-attempt row) and the eval run
18864
- * ids attached to it via `eval_runs.conclusion_id`. The legacy
18865
- * `evalRunId`/`evalVerdict` columns on `pipeline_run_workloads` have no
18866
- * writer (#2892, always null) and stay unwritten — these fields are the
18867
- * read-side derivation, NOT a backfill of those columns.
19073
+ * ids attached to it via `eval_runs.conclusion_id`. Both fields derive from
19074
+ * the conclusion and are independent of the legacy `evalRunId` field.
18868
19075
  *
18869
19076
  * `.optional()` per eval spec §7 (read-side tolerance): the CLI/SDK ships
18870
19077
  * independently of the server, so a client parsing a response from a
@@ -21438,6 +21645,18 @@ var ProjectRepoResource = class {
21438
21645
  );
21439
21646
  return RepoMergeRequestSchema.parse(response);
21440
21647
  }
21648
+ /**
21649
+ * Read the branches `push_back` sessions of this project may push back to,
21650
+ * with the `etag` of the stored list. Needs scope `project:settings`; 404
21651
+ * `PROJECT_NOT_FOUND` for a project outside the token's scope.
21652
+ */
21653
+ async getPushBackPolicy(projectId, options = {}) {
21654
+ const response = await this.client.request(
21655
+ `/api/projects/${encodeURIComponent(projectId)}/push-back-policy`,
21656
+ { method: "GET", signal: options.signal }
21657
+ );
21658
+ return PushBackPolicyStateSchema.parse(response);
21659
+ }
21441
21660
  /**
21442
21661
  * Replace the branches `push_back` sessions of this project may push back
21443
21662
  * to (and that {@link createBranch} may create). Each pattern is a branch
@@ -21445,18 +21664,55 @@ var ProjectRepoResource = class {
21445
21664
  * the project. Needs scope `project:settings`. 400
21446
21665
  * `PUSH_BACK_PATTERN_RESERVED` for a pattern under `pilot/` or
21447
21666
  * `agenthub-release/`, `PUSH_BACK_PATTERN_COVERS_DEFAULT_BRANCH` for one
21448
- * that matches the default branch. Narrowing applies to the next turn of
21449
- * running sessions.
21667
+ * that matches the default branch. Narrowing ends the running `push_back`
21668
+ * sessions whose branch no longer passes. Without `ifMatch` the last writer
21669
+ * wins; with it (an `etag` from an earlier read or write) the write happens
21670
+ * only if the stored list is unchanged, else 412
21671
+ * `PUSH_BACK_POLICY_PRECONDITION_FAILED` with the current `branchPatterns`
21672
+ * and `etag` in `error.body`. Several writers sharing a project should use
21673
+ * {@link updatePushBackPolicy} instead.
21450
21674
  */
21451
21675
  async setPushBackPolicy(projectId, request, options = {}) {
21452
21676
  const body = SetPushBackPolicyRequestSchema.parse(request);
21453
21677
  const response = await this.client.request(
21454
21678
  `/api/projects/${encodeURIComponent(projectId)}/push-back-policy`,
21455
- { method: "PUT", body, signal: options.signal }
21679
+ {
21680
+ method: "PUT",
21681
+ body,
21682
+ signal: options.signal,
21683
+ ...ifMatchHeader(options.ifMatch)
21684
+ }
21456
21685
  );
21457
21686
  return PushBackPolicySchema.parse(response);
21458
21687
  }
21688
+ /**
21689
+ * Add and remove push-back branch patterns without touching the others: the
21690
+ * server merges into the stored list in one compare-and-swap, so concurrent
21691
+ * callers each editing their own patterns do not overwrite one another.
21692
+ * Adding a stored pattern or removing an absent one changes nothing. At
21693
+ * least one pattern overall, none on both sides; only added patterns are
21694
+ * validated (rules as {@link setPushBackPolicy}) and the merged list holds
21695
+ * at most 50. Needs scope `project:settings`. `ifMatch` as in
21696
+ * {@link setPushBackPolicy}. Removing patterns ends the running `push_back`
21697
+ * sessions whose branch no longer passes.
21698
+ */
21699
+ async updatePushBackPolicy(projectId, request, options = {}) {
21700
+ const body = PatchPushBackPolicyRequestSchema.parse(request);
21701
+ const response = await this.client.request(
21702
+ `/api/projects/${encodeURIComponent(projectId)}/push-back-policy`,
21703
+ {
21704
+ method: "PATCH",
21705
+ body,
21706
+ signal: options.signal,
21707
+ ...ifMatchHeader(options.ifMatch)
21708
+ }
21709
+ );
21710
+ return PushBackPolicyStateSchema.parse(response);
21711
+ }
21459
21712
  };
21713
+ function ifMatchHeader(etag) {
21714
+ return etag === void 0 ? {} : { headers: { "If-Match": `"${etag}"` } };
21715
+ }
21460
21716
 
21461
21717
  // src/resources/projects.ts
21462
21718
  var RestorePlatformProjectResponseSchema = import_zod131.z.object({
@@ -24159,7 +24415,7 @@ function unwrapEnvelope(envelope, routeLabel, requiredKeys) {
24159
24415
  }
24160
24416
 
24161
24417
  // src/client.ts
24162
- var AGENTHUB_SDK_USER_AGENT = `@kanyun-ai-infra/agenthub/${true ? "1.37.0" : "0.0.0-dev"}`;
24418
+ var AGENTHUB_SDK_USER_AGENT = `@kanyun-ai-infra/agenthub/${true ? "1.38.0" : "0.0.0-dev"}`;
24163
24419
  var DEFAULT_CONTROL_PLANE_URL = "https://agenthub-plane.zhenguanyu.com";
24164
24420
  var NON_JSON_ERROR_BODY_MAX_CHARS = 200;
24165
24421
  var clientDefaultSignals = /* @__PURE__ */ new WeakMap();
@@ -24681,6 +24937,8 @@ async function verifySessionIdentity(request, options) {
24681
24937
  EvalRunDiffResponseReadSchema,
24682
24938
  EvalsResource,
24683
24939
  FilesResource,
24940
+ GIT_TOKEN_ACCESS_VALUES,
24941
+ GitRepositoryResourceSchema,
24684
24942
  ListMemoriesQuerySchema,
24685
24943
  ListMemorySubjectPoliciesResultSchema,
24686
24944
  ListPipelineRunsResponseSchema,
@@ -24694,6 +24952,8 @@ async function verifySessionIdentity(request, options) {
24694
24952
  MAX_MEMORY_CONTENT_CHARS,
24695
24953
  MAX_MEMORY_SUBJECT_POLICIES,
24696
24954
  MAX_MEMORY_WRITE_BATCH,
24955
+ MAX_PULL_REPOSITORIES,
24956
+ MAX_PUSH_BACK_REPOSITORIES,
24697
24957
  MAX_SESSION_MEMORY_SUBJECTS,
24698
24958
  MAX_WEBHOOK_EVENT_ID_LENGTH,
24699
24959
  MAX_WEBHOOK_SUBSCRIPTIONS_PER_PROJECT,
@@ -24710,6 +24970,10 @@ async function verifySessionIdentity(request, options) {
24710
24970
  PILOT_WORKLOAD_MANIFEST_API_VERSION,
24711
24971
  PILOT_WORKLOAD_MANIFEST_LEGACY_API_VERSION,
24712
24972
  PIPELINE_API_ERROR_CODES,
24973
+ PULL_REPOSITORY_REJECTED,
24974
+ PULL_REPO_MOUNT_PATH_PATTERN,
24975
+ PUSH_BACK_POLICY_PRECONDITION_FAILED,
24976
+ PatchPushBackPolicyRequestSchema,
24713
24977
  PilotPlatformApiError,
24714
24978
  PilotPlatformClient,
24715
24979
  PilotPlatformForbiddenError,
@@ -24732,9 +24996,11 @@ async function verifySessionIdentity(request, options) {
24732
24996
  ProjectsResource,
24733
24997
  PromoteResponseSchema,
24734
24998
  PublishPlatformRevisionRequestSchema,
24999
+ PullRepositoryResourceSchema,
24735
25000
  PurgeSubjectMemoriesRequestSchema,
24736
25001
  PurgeSubjectMemoriesResultSchema,
24737
25002
  PushBackPolicySchema,
25003
+ PushBackPolicyStateSchema,
24738
25004
  PutMemorySubjectPoliciesRequestSchema,
24739
25005
  PutStageRequestSchema,
24740
25006
  PutStageResponseSchema,
@@ -24755,6 +25021,8 @@ async function verifySessionIdentity(request, options) {
24755
25021
  SessionDiagnosisDTOSchema,
24756
25022
  SessionFileResourceSchema,
24757
25023
  SessionMemorySubjectDeclarationSchema,
25024
+ SessionRepositoriesSchema,
25025
+ SessionRepositoryResourceSchema,
24758
25026
  SessionResourcesSchema,
24759
25027
  SessionTerminateRequestSchema,
24760
25028
  SessionTerminateResponseSchema,
@@ -24796,6 +25064,7 @@ async function verifySessionIdentity(request, options) {
24796
25064
  UPSTREAM_RATE_LIMITED_CODE,
24797
25065
  UpdateEnvironmentInputSchema,
24798
25066
  UpdateWebhookSubscriptionRequestSchema,
25067
+ VaultCredentialRefSchema,
24799
25068
  VaultCredentialsResource,
24800
25069
  VaultsResource,
24801
25070
  WEBHOOK_EVENT_TYPES,