@kanyun-ai-infra/agenthub 1.3.0 → 1.4.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/dist/index.cjs +131 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +87 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.js +131 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2227,6 +2227,24 @@ var AgentOptionsSchema = import_zod4.z.object({
|
|
|
2227
2227
|
/** Tool denylist — additive to the platform denylist; cannot remove guards. */
|
|
2228
2228
|
disallowedTools: import_zod4.z.array(AgentOptionsToolRuleSchema).max(AGENT_OPTIONS_TOOL_LIST_MAX_LENGTH).optional()
|
|
2229
2229
|
}).strict();
|
|
2230
|
+
var WorkloadManifestMemorySchema = import_zod4.z.object({
|
|
2231
|
+
/**
|
|
2232
|
+
* 是否为这个 agent 启用跨会话记忆。缺省 = 启用:manifest 无 `memory` 块时
|
|
2233
|
+
* `resolveAgentMemoryEnabled` 返回 true;只有显式 `enabled: false` 才关。
|
|
2234
|
+
*/
|
|
2235
|
+
enabled: import_zod4.z.boolean(),
|
|
2236
|
+
/**
|
|
2237
|
+
* 业务对象维度的记忆(`room` 作用域)从会话 metadata 的哪个键取。
|
|
2238
|
+
*
|
|
2239
|
+
* 目前只接受 `metadata.memoryRoomId` 这一个字面量 —— 把它写出来是为了让接入
|
|
2240
|
+
* 方在 profile 里**看得见**这个约定(此前它只是一个没有产品面的隐式 metadata
|
|
2241
|
+
* 键),而不是为了支持自定义键名:换键名会让写回侧与召回侧对不上。
|
|
2242
|
+
*
|
|
2243
|
+
* 省略 = 不启用 room 维度,只有 user(操作者偏好)与 agent(领域知识)两个
|
|
2244
|
+
* 作用域生效。
|
|
2245
|
+
*/
|
|
2246
|
+
roomIdFrom: import_zod4.z.literal("metadata.memoryRoomId").optional()
|
|
2247
|
+
}).strict();
|
|
2230
2248
|
var ManagedAgentProfileSnapshotSchema = import_zod4.z.object({
|
|
2231
2249
|
model: WorkloadManifestModelSchema.optional(),
|
|
2232
2250
|
systemPrompt: WorkloadManifestSystemPromptSchema.optional(),
|
|
@@ -2240,6 +2258,12 @@ var ManagedAgentProfileSnapshotSchema = import_zod4.z.object({
|
|
|
2240
2258
|
agentPackage: AgentPackageSchema.optional(),
|
|
2241
2259
|
/** Frozen custom LLM provider ref — see `WorkloadManifestDefaultsSchema`. */
|
|
2242
2260
|
llmProviderRef: LlmProviderConfigPublicIdSchema.optional(),
|
|
2261
|
+
/**
|
|
2262
|
+
* Per-agent managed-memory gate (#1662 E1 / #1827): frozen per revision.
|
|
2263
|
+
* Absent = enabled by default; `enabled: false` disables recall, injection,
|
|
2264
|
+
* and extraction for this agent. Shape: `WorkloadManifestMemorySchema`.
|
|
2265
|
+
*/
|
|
2266
|
+
memory: WorkloadManifestMemorySchema.optional(),
|
|
2243
2267
|
/**
|
|
2244
2268
|
* 冻结的托管 MCP 绑定清单(issue #1490 / #1493 层①)。
|
|
2245
2269
|
*
|
|
@@ -2413,7 +2437,16 @@ var WorkloadManifestDefaultsSchema = import_zod4.z.object({
|
|
|
2413
2437
|
* `sessions.metadata[SESSION_METADATA_LLM_PROVIDER_CONFIG_KEY]`.
|
|
2414
2438
|
* See `pilot-v2-llm-provider-config.ts`.
|
|
2415
2439
|
*/
|
|
2416
|
-
llmProviderRef: LlmProviderConfigPublicIdSchema.optional()
|
|
2440
|
+
llmProviderRef: LlmProviderConfigPublicIdSchema.optional(),
|
|
2441
|
+
/**
|
|
2442
|
+
* Workload-level per-agent memory gate (#1662 E1 / #1827).
|
|
2443
|
+
*
|
|
2444
|
+
* Absent = enabled by default; `enabled: false` disables recall, injection,
|
|
2445
|
+
* and extraction for this agent. Frozen into the revision snapshot
|
|
2446
|
+
* (`ManagedAgentProfileSnapshotSchema.memory`) so each published revision
|
|
2447
|
+
* carries its own immutable gate decision. Shape: `WorkloadManifestMemorySchema`.
|
|
2448
|
+
*/
|
|
2449
|
+
memory: WorkloadManifestMemorySchema.optional()
|
|
2417
2450
|
}).strict().superRefine(assertMcpBindingFieldsExclusive);
|
|
2418
2451
|
var WORKLOAD_MANIFEST_UI_DISPLAY_NAME_MAX_LENGTH = 255;
|
|
2419
2452
|
var WORKLOAD_MANIFEST_UI_PROMPT_PLACEHOLDER_MAX_LENGTH = 500;
|
|
@@ -3217,6 +3250,8 @@ var MEMORY_WRITE_OUTCOMES = [
|
|
|
3217
3250
|
"promoted",
|
|
3218
3251
|
/** 命中 `user_deleted` 墓碑:整条不写。删除是终态承诺,直写通道也撤不动。 */
|
|
3219
3252
|
"suppressed",
|
|
3253
|
+
/** agent 作用域被该 workload 的 manifest 声明为 `memory.enabled: false` 而拒绝。 */
|
|
3254
|
+
"agent_disabled",
|
|
3220
3255
|
/** 其它拒绝,见 `reason`。 */
|
|
3221
3256
|
"rejected"
|
|
3222
3257
|
];
|
|
@@ -3246,6 +3281,8 @@ var WriteMemoriesResultSchema = import_zod26.z.object({
|
|
|
3246
3281
|
strengthened: import_zod26.z.number().int().min(0),
|
|
3247
3282
|
promoted: import_zod26.z.number().int().min(0),
|
|
3248
3283
|
suppressed: import_zod26.z.number().int().min(0),
|
|
3284
|
+
/** agent 作用域条目被 per-agent 闸(#1827)挡下的条数。 */
|
|
3285
|
+
agent_disabled: import_zod26.z.number().int().min(0),
|
|
3249
3286
|
rejected: import_zod26.z.number().int().min(0)
|
|
3250
3287
|
}).strict()
|
|
3251
3288
|
}).strict();
|
|
@@ -5380,6 +5417,9 @@ var WorkspaceExportErrorCodeSchema = import_zod49.z.enum([
|
|
|
5380
5417
|
// 500 — fallthrough (e.g. the OSS client could not sign)
|
|
5381
5418
|
"INTERNAL_ERROR"
|
|
5382
5419
|
]);
|
|
5420
|
+
var SESSION_ARTIFACT_MAX_BUNDLE_COMPRESSED_BYTES = 8 * 1024 * 1024;
|
|
5421
|
+
var SESSION_ARTIFACT_MAX_ENTRY_BYTES = 8 * 1024 * 1024;
|
|
5422
|
+
var SESSION_ARTIFACT_MAX_TOTAL_UNCOMPRESSED_BYTES = 16 * 1024 * 1024;
|
|
5383
5423
|
var ScheduleTargetKindSchema = import_zod50.z.enum(["workload", "agent", "inline_v1", "inline_v2"]);
|
|
5384
5424
|
var ScheduleApiVersionPreferenceSchema = import_zod50.z.enum(["v1", "v2"]);
|
|
5385
5425
|
var ScheduleLifecycleStatusSchema = import_zod50.z.enum(["active", "disabled", "deleted"]);
|
|
@@ -6448,24 +6488,7 @@ function validateXExtensionValueShape(value) {
|
|
|
6448
6488
|
}
|
|
6449
6489
|
return "x-* value must be a scalar or a one-level object of scalars";
|
|
6450
6490
|
}
|
|
6451
|
-
var ManagedAgentProfileV1MemorySchema =
|
|
6452
|
-
/**
|
|
6453
|
-
* 是否为这个 agent 启用跨会话记忆。缺省 = 不启用:记忆会跨会话、在多人共用的
|
|
6454
|
-
* 作用域里流动,属于要显式选择的能力,不该因为升级平台版本而自动获得。
|
|
6455
|
-
*/
|
|
6456
|
-
enabled: import_zod52.z.boolean(),
|
|
6457
|
-
/**
|
|
6458
|
-
* 业务对象维度的记忆(`room` 作用域)从会话 metadata 的哪个键取。
|
|
6459
|
-
*
|
|
6460
|
-
* 目前只接受 `metadata.memoryRoomId` 这一个字面量 —— 把它写出来是为了让接入
|
|
6461
|
-
* 方在 profile 里**看得见**这个约定(此前它只是一个没有产品面的隐式 metadata
|
|
6462
|
-
* 键),而不是为了支持自定义键名:换键名会让写回侧与召回侧对不上。
|
|
6463
|
-
*
|
|
6464
|
-
* 省略 = 不启用 room 维度,只有 user(操作者偏好)与 agent(领域知识)两个
|
|
6465
|
-
* 作用域生效。
|
|
6466
|
-
*/
|
|
6467
|
-
roomIdFrom: import_zod52.z.literal("metadata.memoryRoomId").optional()
|
|
6468
|
-
}).strict();
|
|
6491
|
+
var ManagedAgentProfileV1MemorySchema = WorkloadManifestMemorySchema;
|
|
6469
6492
|
var ManagedAgentProfileV1SpecSchema = import_zod52.z.object({
|
|
6470
6493
|
runtime: ManagedAgentProfileV1RuntimeSchema,
|
|
6471
6494
|
model: ManagedAgentProfileV1ModelSchema.optional(),
|
|
@@ -8558,6 +8581,7 @@ var PilotPlatformApiError = class extends Error {
|
|
|
8558
8581
|
this.status = options.status;
|
|
8559
8582
|
this.code = options.code;
|
|
8560
8583
|
this.requestId = options.requestId;
|
|
8584
|
+
this.body = options.body;
|
|
8561
8585
|
}
|
|
8562
8586
|
};
|
|
8563
8587
|
var PilotPlatformUnauthenticatedError = class extends PilotPlatformApiError {
|
|
@@ -8588,7 +8612,7 @@ function pilotPlatformErrorFromResponse(params) {
|
|
|
8588
8612
|
const parsed = extractErrorBody(params.body);
|
|
8589
8613
|
const code = parsed.code ?? defaultCodeForStatus(params.status);
|
|
8590
8614
|
const message = parsed.message ?? parsed.error;
|
|
8591
|
-
const base = { code, message, requestId: params.requestId };
|
|
8615
|
+
const base = { code, message, requestId: params.requestId, body: parsed.raw };
|
|
8592
8616
|
if (params.status === 401) return new PilotPlatformUnauthenticatedError(base);
|
|
8593
8617
|
if (params.status === 403) return new PilotPlatformForbiddenError(base);
|
|
8594
8618
|
if (params.status === 404) return new PilotPlatformNotFoundError(base);
|
|
@@ -8598,12 +8622,13 @@ function pilotPlatformErrorFromResponse(params) {
|
|
|
8598
8622
|
return new PilotPlatformApiError({ ...base, status: params.status });
|
|
8599
8623
|
}
|
|
8600
8624
|
function extractErrorBody(body) {
|
|
8601
|
-
if (!body || typeof body !== "object") return {};
|
|
8625
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return {};
|
|
8602
8626
|
const record = body;
|
|
8603
8627
|
return {
|
|
8604
8628
|
error: typeof record.error === "string" ? record.error : void 0,
|
|
8605
8629
|
code: typeof record.code === "string" ? record.code : void 0,
|
|
8606
|
-
message: typeof record.message === "string" ? record.message : void 0
|
|
8630
|
+
message: typeof record.message === "string" ? record.message : void 0,
|
|
8631
|
+
raw: record
|
|
8607
8632
|
};
|
|
8608
8633
|
}
|
|
8609
8634
|
function defaultCodeForStatus(status) {
|
|
@@ -9325,6 +9350,24 @@ var ListSessionEventsEnvelopeSchema = import_zod72.z.object({
|
|
|
9325
9350
|
var DeliveryResultEnvelopeSchema = import_zod72.z.object({
|
|
9326
9351
|
data: import_zod72.z.object({ delivery: SessionDeliveryEnvelopeSchema.nullable() })
|
|
9327
9352
|
});
|
|
9353
|
+
var SessionArtifactsListEnvelopeSchema = import_zod72.z.object({
|
|
9354
|
+
data: import_zod72.z.object({
|
|
9355
|
+
items: import_zod72.z.array(
|
|
9356
|
+
import_zod72.z.object({
|
|
9357
|
+
id: import_zod72.z.string(),
|
|
9358
|
+
artifactId: import_zod72.z.string().optional(),
|
|
9359
|
+
filename: import_zod72.z.string(),
|
|
9360
|
+
path: import_zod72.z.string(),
|
|
9361
|
+
contentType: import_zod72.z.string(),
|
|
9362
|
+
size: import_zod72.z.number(),
|
|
9363
|
+
turnId: import_zod72.z.string().optional(),
|
|
9364
|
+
messageId: import_zod72.z.string().optional()
|
|
9365
|
+
})
|
|
9366
|
+
),
|
|
9367
|
+
partial: import_zod72.z.boolean().optional(),
|
|
9368
|
+
skippedBundles: import_zod72.z.array(import_zod72.z.object({ artifactId: import_zod72.z.string(), reason: import_zod72.z.string() })).optional()
|
|
9369
|
+
})
|
|
9370
|
+
});
|
|
9328
9371
|
var SessionsResource = class {
|
|
9329
9372
|
constructor(client) {
|
|
9330
9373
|
this.client = client;
|
|
@@ -9664,6 +9707,72 @@ var SessionsResource = class {
|
|
|
9664
9707
|
}
|
|
9665
9708
|
return parsed.data.data;
|
|
9666
9709
|
}
|
|
9710
|
+
/**
|
|
9711
|
+
* `GET /api/sessions/:id/artifacts` — the session's deliverable files as
|
|
9712
|
+
* packed by the worker (one zip bundle per turn; #1814 mounts this on the
|
|
9713
|
+
* control-plane too). Requires scope `runs:stream`.
|
|
9714
|
+
*
|
|
9715
|
+
* `mode: "incremental"` (default) returns the files of `turnId`'s bundle
|
|
9716
|
+
* (all bundles when `turnId` is omitted); `mode: "cumulative"` returns the
|
|
9717
|
+
* last-write-wins accumulation up to `turnId`. A bundle that violates the
|
|
9718
|
+
* read limits fails with 422 `ARTIFACT_BUNDLE_UNREADABLE` whose body carries
|
|
9719
|
+
* a structured `reason` (`entry_too_large` / `total_too_large` /
|
|
9720
|
+
* `compressed_too_large` / `entry_count`) plus the offending `path` and
|
|
9721
|
+
* `limit` — since #1814 the writer enforces the same caps at pack time, so
|
|
9722
|
+
* a 422 means a bundle from before that invariant, not fresh data.
|
|
9723
|
+
*
|
|
9724
|
+
* The response items deliberately do NOT carry `previewUrl` / `downloadUrl`
|
|
9725
|
+
* (relative BFF paths — useless off-origin and version-fragile): fetch
|
|
9726
|
+
* bytes with {@link getArtifact}.
|
|
9727
|
+
*/
|
|
9728
|
+
async listArtifacts(sessionId, options = {}) {
|
|
9729
|
+
const path = `/api/sessions/${encodeURIComponent(sessionId)}/artifacts`;
|
|
9730
|
+
const envelope = await this.client.request(path, {
|
|
9731
|
+
method: "GET",
|
|
9732
|
+
query: {
|
|
9733
|
+
turnId: options.turnId,
|
|
9734
|
+
mode: options.mode
|
|
9735
|
+
},
|
|
9736
|
+
signal: options.signal,
|
|
9737
|
+
cache: "no-store"
|
|
9738
|
+
});
|
|
9739
|
+
const parsed = SessionArtifactsListEnvelopeSchema.safeParse(envelope);
|
|
9740
|
+
if (!parsed.success) {
|
|
9741
|
+
throw new PilotPlatformApiError({
|
|
9742
|
+
status: 0,
|
|
9743
|
+
code: "MALFORMED_PLATFORM_RESPONSE",
|
|
9744
|
+
message: `GET ${path} did not return a {data: {items: [...]}} envelope.`,
|
|
9745
|
+
cause: parsed.error
|
|
9746
|
+
});
|
|
9747
|
+
}
|
|
9748
|
+
return parsed.data.data;
|
|
9749
|
+
}
|
|
9750
|
+
/**
|
|
9751
|
+
* `GET /api/sessions/:id/artifacts/content` — one artifact's bytes as a
|
|
9752
|
+
* `Uint8Array` (decoding is the caller's business; the SDK does not guess).
|
|
9753
|
+
* `path` comes from a {@link listArtifacts} item; pass that item's
|
|
9754
|
+
* `artifactId` when you have it (exact bundle, immune to later-turn
|
|
9755
|
+
* last-write-wins lookups). Requires scope `runs:stream`.
|
|
9756
|
+
*
|
|
9757
|
+
* Throws `PilotPlatformApiError` `NOT_FOUND` (404) for a path the bundle
|
|
9758
|
+
* does not carry, and 422 `ARTIFACT_BUNDLE_UNREADABLE` (with the structured
|
|
9759
|
+
* `reason` of {@link listArtifacts}) when the backing bundle violates the
|
|
9760
|
+
* read limits.
|
|
9761
|
+
*/
|
|
9762
|
+
async getArtifact(sessionId, path, options = {}) {
|
|
9763
|
+
const requestPath = `/api/sessions/${encodeURIComponent(sessionId)}/artifacts/content`;
|
|
9764
|
+
const res = await this.client.rawRequest(requestPath, {
|
|
9765
|
+
method: "GET",
|
|
9766
|
+
query: {
|
|
9767
|
+
artifactId: options.artifactId,
|
|
9768
|
+
path,
|
|
9769
|
+
...options.download ? { download: "1" } : {}
|
|
9770
|
+
},
|
|
9771
|
+
signal: options.signal,
|
|
9772
|
+
cache: "no-store"
|
|
9773
|
+
});
|
|
9774
|
+
return new Uint8Array(await res.arrayBuffer());
|
|
9775
|
+
}
|
|
9667
9776
|
/**
|
|
9668
9777
|
* `GET /api/sessions/:id/events/stream` — live SSE chunk stream, the same
|
|
9669
9778
|
* rendering feed the portal chat consumes (`pilot_coder.chunk` payloads,
|