@nekro-nxt/contracts 0.2.0 → 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/dist/index.mjs +689 -126
- package/dist/index.mjs.map +1 -1
- package/lib/types/community-personas.d.ts +139 -0
- package/lib/types/community-personas.d.ts.map +1 -0
- package/lib/types/community.d.ts +269 -148
- package/lib/types/community.d.ts.map +1 -1
- package/lib/types/extension-capabilities.d.ts +36 -7
- package/lib/types/extension-capabilities.d.ts.map +1 -1
- package/lib/types/extension-ui.d.ts +194 -3
- package/lib/types/extension-ui.d.ts.map +1 -1
- package/lib/types/host-api.d.ts +1674 -272
- package/lib/types/host-api.d.ts.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/community-personas.ts +81 -0
- package/src/community.ts +233 -169
- package/src/extension-capabilities.ts +54 -8
- package/src/extension-ui.ts +107 -20
- package/src/host-api.ts +382 -34
- package/src/index.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -523,10 +523,10 @@ const configSchema = {
|
|
|
523
523
|
//#region src/extension-capabilities.ts
|
|
524
524
|
/**
|
|
525
525
|
* Host capability level this build implements. A Revision that declares `requires.sdk` above it is rejected at
|
|
526
|
-
* import with an "upgrade NekroNXT" message instead of an opaque schema error. Bump
|
|
527
|
-
*
|
|
526
|
+
* import with an "upgrade NekroNXT" message instead of an opaque schema error. Bump when a Manifest capability
|
|
527
|
+
* ships; never reuse a level for a different meaning. Level 7 is Manifest V7 (host instance + agent attachments).
|
|
528
528
|
*/
|
|
529
|
-
const EXTENSION_SDK_LEVEL =
|
|
529
|
+
const EXTENSION_SDK_LEVEL = 7;
|
|
530
530
|
const ExtensionRequiresSchema = z.object({ sdk: z.number().int().min(1).max(1e3) }).strict();
|
|
531
531
|
/** `api.example.com` or `*.example.com` (subdomains only); lower-case DNS labels, no scheme, port or path. */
|
|
532
532
|
const ExtensionNetworkDomainSchema = z.string().trim().toLowerCase().max(253).regex(/^(\*\.)?(?=.{1,253}$)([a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$/u, { message: "网络域名必须是 api.example.com 或 *.example.com 形式,不含协议、端口和路径。" });
|
|
@@ -657,8 +657,8 @@ const mcpTarget = (server) => server.transport === "stdio" ? JSON.stringify([
|
|
|
657
657
|
server.url
|
|
658
658
|
]);
|
|
659
659
|
/**
|
|
660
|
-
*
|
|
661
|
-
* means the
|
|
660
|
+
* Agent-layer capabilities (`permissions.agent`): what the extension may do inside the agents it is enabled for. An
|
|
661
|
+
* absent field means the extension cannot use that capability.
|
|
662
662
|
*/
|
|
663
663
|
const ExtensionCapabilitiesSchema = z.object({
|
|
664
664
|
network: ExtensionNetworkCapabilitySchema.optional(),
|
|
@@ -672,6 +672,22 @@ const ExtensionCapabilitiesSchema = z.object({
|
|
|
672
672
|
mcp: ExtensionMcpCapabilitySchema.optional(),
|
|
673
673
|
context: z.array(ExtensionContextContributionSchema).max(8).refine((value) => new Set(value.map(({ name }) => name)).size === value.length, "上下文名称不能重复。").optional()
|
|
674
674
|
}).strict();
|
|
675
|
+
/**
|
|
676
|
+
* Host-layer capabilities (`permissions.host`): what the extension's single host instance may do through the `nxt`
|
|
677
|
+
* service its factory receives. Host storage is the extension's `shared` partition.
|
|
678
|
+
*/
|
|
679
|
+
const HostLayerCapabilitiesSchema = z.object({
|
|
680
|
+
network: ExtensionNetworkCapabilitySchema.optional(),
|
|
681
|
+
storage: z.object({ quotaBytes: z.number().int().min(1024).max(EXTENSION_STORAGE_MAX_QUOTA_BYTES).optional() }).strict().optional()
|
|
682
|
+
}).strict();
|
|
683
|
+
/** Host-layer capabilities in the agent-capability shape, so digests, expansion and summaries share one implementation. */
|
|
684
|
+
const hostLayerAsCapabilities = (host) => host === void 0 || Object.keys(host).length === 0 ? void 0 : {
|
|
685
|
+
...host.network === void 0 ? {} : { network: host.network },
|
|
686
|
+
...host.storage === void 0 ? {} : { storage: {
|
|
687
|
+
scopes: ["shared"],
|
|
688
|
+
...host.storage.quotaBytes === void 0 ? {} : { quotaBytes: host.storage.quotaBytes }
|
|
689
|
+
} }
|
|
690
|
+
};
|
|
675
691
|
const NETWORK_MODE_RANK = {
|
|
676
692
|
domains: 0,
|
|
677
693
|
config: 1,
|
|
@@ -709,8 +725,11 @@ const extensionCapabilitiesExpand = (previous, next) => {
|
|
|
709
725
|
if (next.llm !== void 0 && (previous?.llm === void 0 || next.llm.maxCallsPerTurn > previous.llm.maxCallsPerTurn || next.llm.maxOutputTokens > previous.llm.maxOutputTokens)) return true;
|
|
710
726
|
return false;
|
|
711
727
|
};
|
|
712
|
-
/**
|
|
713
|
-
|
|
728
|
+
/**
|
|
729
|
+
* User-facing summary of declared capabilities, in a stable order, for approval and inspection pages. `layer: 'host'`
|
|
730
|
+
* phrases host-layer capabilities (passed through {@link hostLayerAsCapabilities}) for the host instance.
|
|
731
|
+
*/
|
|
732
|
+
const summarizeExtensionCapabilities = (capabilities, options = {}) => {
|
|
714
733
|
if (capabilities === void 0) return [];
|
|
715
734
|
const items = [];
|
|
716
735
|
const network = capabilities.network;
|
|
@@ -724,7 +743,7 @@ const summarizeExtensionCapabilities = (capabilities) => {
|
|
|
724
743
|
key: "network",
|
|
725
744
|
risk: "normal",
|
|
726
745
|
label: "访问你在配置中填写的地址",
|
|
727
|
-
detail: network.fields.join("、")
|
|
746
|
+
detail: network.fields.map((field) => options.fieldTitle?.(field) ?? field).join("、")
|
|
728
747
|
});
|
|
729
748
|
else if (network?.mode === "unrestricted") items.push({
|
|
730
749
|
key: "network",
|
|
@@ -732,7 +751,12 @@ const summarizeExtensionCapabilities = (capabilities) => {
|
|
|
732
751
|
label: "访问任意公网地址",
|
|
733
752
|
detail: network.purpose
|
|
734
753
|
});
|
|
735
|
-
if (capabilities.storage !== void 0) {
|
|
754
|
+
if (capabilities.storage !== void 0 && options.layer === "host") items.push({
|
|
755
|
+
key: "storage",
|
|
756
|
+
risk: "normal",
|
|
757
|
+
label: "在本机保存扩展数据,页面与启用它的智能体共用"
|
|
758
|
+
});
|
|
759
|
+
else if (capabilities.storage !== void 0) {
|
|
736
760
|
const shared = capabilities.storage.scopes.includes("shared");
|
|
737
761
|
items.push({
|
|
738
762
|
key: "storage",
|
|
@@ -904,8 +928,14 @@ const HostPageContributionSchema = z.object({
|
|
|
904
928
|
description: z.string().trim().max(120).optional(),
|
|
905
929
|
icon: HostPageIconSchema,
|
|
906
930
|
objectPane: z.enum(["navigation", "hidden"]),
|
|
907
|
-
startPath: z.string().trim().regex(/^(?:[a-z0-9][a-z0-9/_-]*)?$/u)
|
|
931
|
+
startPath: z.string().trim().regex(/^(?:[a-z0-9][a-z0-9/_-]*)?$/u),
|
|
932
|
+
/** Registers a navigation rail entry for this page; at most one page of an extension may declare it. */
|
|
933
|
+
rail: z.object({ order: z.number().int().min(0).max(999).optional() }).strict().optional()
|
|
908
934
|
}).strict();
|
|
935
|
+
/** Rail position of a page that registers a rail entry without an explicit order. */
|
|
936
|
+
const HOST_PAGE_DEFAULT_RAIL_ORDER = 100;
|
|
937
|
+
/** The stored rail position of a page; `null` when the page has no rail entry. */
|
|
938
|
+
const hostPageRailOrder = (page) => page.rail === void 0 ? null : page.rail.order ?? 100;
|
|
909
939
|
const HostUiNavigationItemSchema = z.object({
|
|
910
940
|
id: z.string().trim().min(1).max(80),
|
|
911
941
|
label: z.string().trim().min(1).max(80),
|
|
@@ -949,12 +979,7 @@ const HostUiNetworkOriginSchema = z.string().url().transform((value, context) =>
|
|
|
949
979
|
}
|
|
950
980
|
return url.origin;
|
|
951
981
|
});
|
|
952
|
-
const
|
|
953
|
-
permissions: z.array(HostUiPermissionSchema).max(HostUiPermissionSchema.options.length),
|
|
954
|
-
networkOrigins: z.array(HostUiNetworkOriginSchema).max(32).default([]),
|
|
955
|
-
/** Host capabilities of an agent-scope Revision; absent keeps the pre-capability digest unchanged. */
|
|
956
|
-
capabilities: ExtensionCapabilitiesSchema.optional()
|
|
957
|
-
}).strict().superRefine((value, context) => {
|
|
982
|
+
const checkBrowserPermissions = (value, context) => {
|
|
958
983
|
if (new Set(value.permissions).size !== value.permissions.length) context.addIssue({
|
|
959
984
|
code: "custom",
|
|
960
985
|
path: ["permissions"],
|
|
@@ -970,6 +995,44 @@ const HostUiPermissionDeclarationSchema = z.object({
|
|
|
970
995
|
path: ["networkOrigins"],
|
|
971
996
|
message: "Host UI network origins require network.request."
|
|
972
997
|
});
|
|
998
|
+
};
|
|
999
|
+
/**
|
|
1000
|
+
* One approval: browser-side permissions plus the capabilities of one layer. Grants, digests and the approval page
|
|
1001
|
+
* use this shape for both the host approval and each agent approval.
|
|
1002
|
+
*/
|
|
1003
|
+
const HostUiPermissionDeclarationSchema = z.object({
|
|
1004
|
+
permissions: z.array(HostUiPermissionSchema).max(HostUiPermissionSchema.options.length),
|
|
1005
|
+
networkOrigins: z.array(HostUiNetworkOriginSchema).max(32).default([]),
|
|
1006
|
+
capabilities: ExtensionCapabilitiesSchema.optional()
|
|
1007
|
+
}).strict().superRefine(checkBrowserPermissions);
|
|
1008
|
+
/**
|
|
1009
|
+
* Manifest V7 `permissions`: browser-side permissions of pages and panels (`host.call`), host-layer capabilities used
|
|
1010
|
+
* by the single host instance, and agent-layer capabilities used inside each enabled agent.
|
|
1011
|
+
*/
|
|
1012
|
+
const ExtensionPermissionsSchema = z.object({
|
|
1013
|
+
permissions: z.array(HostUiPermissionSchema).max(HostUiPermissionSchema.options.length).default([]),
|
|
1014
|
+
networkOrigins: z.array(HostUiNetworkOriginSchema).max(32).default([]),
|
|
1015
|
+
host: HostLayerCapabilitiesSchema.optional(),
|
|
1016
|
+
agent: ExtensionCapabilitiesSchema.optional()
|
|
1017
|
+
}).strict().superRefine(checkBrowserPermissions);
|
|
1018
|
+
const EMPTY_EXTENSION_PERMISSIONS = {
|
|
1019
|
+
permissions: [],
|
|
1020
|
+
networkOrigins: []
|
|
1021
|
+
};
|
|
1022
|
+
/** What installing the extension on this machine asks the user to approve. */
|
|
1023
|
+
const hostPermissionDeclaration = (permissions) => {
|
|
1024
|
+
const capabilities = hostLayerAsCapabilities(permissions.host);
|
|
1025
|
+
return {
|
|
1026
|
+
permissions: [...permissions.permissions],
|
|
1027
|
+
networkOrigins: [...permissions.networkOrigins],
|
|
1028
|
+
...capabilities === void 0 ? {} : { capabilities }
|
|
1029
|
+
};
|
|
1030
|
+
};
|
|
1031
|
+
/** What enabling the extension for one agent asks the user to approve. */
|
|
1032
|
+
const agentPermissionDeclaration = (permissions) => ({
|
|
1033
|
+
permissions: [],
|
|
1034
|
+
networkOrigins: [],
|
|
1035
|
+
...permissions.agent === void 0 || Object.keys(permissions.agent).length === 0 ? {} : { capabilities: permissions.agent }
|
|
973
1036
|
});
|
|
974
1037
|
const HostUiOwnerSchema = z.discriminatedUnion("kind", [z.object({
|
|
975
1038
|
kind: z.literal("extension"),
|
|
@@ -991,6 +1054,8 @@ const HostUiPageEntrySchema = z.object({
|
|
|
991
1054
|
startPath: z.string(),
|
|
992
1055
|
visible: z.boolean(),
|
|
993
1056
|
sortOrder: z.number().int().nonnegative(),
|
|
1057
|
+
/** Present when the page registered a navigation rail entry; lower orders come first. */
|
|
1058
|
+
rail: z.object({ order: z.number().int().min(0).max(999) }).strict().optional(),
|
|
994
1059
|
routeBase: z.string().regex(/^\/apps\/hup_[0-9A-Za-z]+$/u),
|
|
995
1060
|
client: z.object({
|
|
996
1061
|
moduleUrl: z.string().startsWith("/"),
|
|
@@ -1035,12 +1100,17 @@ const ExtensionPanelAnchorSchema = z.enum([
|
|
|
1035
1100
|
"extension",
|
|
1036
1101
|
"connection"
|
|
1037
1102
|
]);
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
const
|
|
1103
|
+
/**
|
|
1104
|
+
* Which layer a panel belongs to. Agent and channel panels follow the agents the extension is enabled for (a channel
|
|
1105
|
+
* panel also shows on channels of the extension's own adapter); extension and connection panels belong to the host
|
|
1106
|
+
* instance.
|
|
1107
|
+
*/
|
|
1108
|
+
const PANEL_ANCHOR_LAYER = {
|
|
1109
|
+
agent: "agent",
|
|
1110
|
+
channel: "agent",
|
|
1111
|
+
extension: "host",
|
|
1112
|
+
connection: "host"
|
|
1113
|
+
};
|
|
1044
1114
|
const PanelDensitySchema = z.enum(["compact", "full"]);
|
|
1045
1115
|
const ConnectionPanelRoleSchema = z.enum([
|
|
1046
1116
|
"setup",
|
|
@@ -1103,8 +1173,21 @@ const MessageRendererContributionSchema = z.object({
|
|
|
1103
1173
|
kind: z.literal("message-renderer"),
|
|
1104
1174
|
richKind: RichKindSchema
|
|
1105
1175
|
}).strict();
|
|
1106
|
-
/**
|
|
1176
|
+
/** What an extension provides, derived from its Manifest; for listing and filtering, never a lifecycle switch. */
|
|
1177
|
+
const EXTENSION_PROVIDES = [
|
|
1178
|
+
"agent",
|
|
1179
|
+
"page",
|
|
1180
|
+
"adapter",
|
|
1181
|
+
"mcp"
|
|
1182
|
+
];
|
|
1183
|
+
const ExtensionProvideSchema = z.enum(EXTENSION_PROVIDES);
|
|
1184
|
+
/** One configuration form: a serialized Schemastery document. */
|
|
1107
1185
|
const ExtensionConfigDeclarationSchema = z.object({ schema: ConfigSchemaDocumentSchema }).strict();
|
|
1186
|
+
/** Manifest V7 `config`: the host instance's configuration and each enabled agent's configuration. */
|
|
1187
|
+
const ExtensionLayeredConfigSchema = z.object({
|
|
1188
|
+
host: ExtensionConfigDeclarationSchema.optional(),
|
|
1189
|
+
agent: ExtensionConfigDeclarationSchema.optional()
|
|
1190
|
+
}).strict();
|
|
1108
1191
|
/** Product projection of what one Revision contributes to the shell. */
|
|
1109
1192
|
const ExtensionUiContributionsSchema = z.object({
|
|
1110
1193
|
panels: z.array(PanelContributionSchema).max(16),
|
|
@@ -1285,18 +1368,112 @@ const COMMUNITY_REVIEW_STATUSES = [
|
|
|
1285
1368
|
"incomplete"
|
|
1286
1369
|
];
|
|
1287
1370
|
const CommunityReviewStatusSchema = z.enum(COMMUNITY_REVIEW_STATUSES);
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
"
|
|
1291
|
-
"
|
|
1292
|
-
"
|
|
1371
|
+
/** 社区评级的六个维度(审查标准 v1),从正上方顺时针排列成六边形。 */
|
|
1372
|
+
const COMMUNITY_RATING_DIMENSIONS = [
|
|
1373
|
+
"security",
|
|
1374
|
+
"openness",
|
|
1375
|
+
"reliability",
|
|
1376
|
+
"lightweight",
|
|
1377
|
+
"usability",
|
|
1378
|
+
"craft"
|
|
1379
|
+
];
|
|
1380
|
+
const COMMUNITY_RATING_DIMENSION_LABELS = {
|
|
1381
|
+
security: "安全",
|
|
1382
|
+
openness: "开放",
|
|
1383
|
+
reliability: "稳定",
|
|
1384
|
+
lightweight: "轻量",
|
|
1385
|
+
usability: "易用",
|
|
1386
|
+
craft: "工艺"
|
|
1387
|
+
};
|
|
1388
|
+
/** 社区的审查员,评级与审查记录以她署名。 */
|
|
1389
|
+
const COMMUNITY_REVIEWER_NAME = "小澄";
|
|
1390
|
+
/** 社区判定的达成标签;不认识的标签不显示。扩展页面最多显示 {@link COMMUNITY_RATING_BADGE_LIMIT} 个。 */
|
|
1391
|
+
const COMMUNITY_RATING_BADGES = {
|
|
1392
|
+
"zero-permission": {
|
|
1393
|
+
label: "零权限",
|
|
1394
|
+
description: "没有申请任何权限。"
|
|
1395
|
+
},
|
|
1396
|
+
"least-privilege": {
|
|
1397
|
+
label: "最小权限",
|
|
1398
|
+
description: "声明的每项能力都用得上,安全满星。"
|
|
1399
|
+
},
|
|
1400
|
+
"no-network": {
|
|
1401
|
+
label: "不联网",
|
|
1402
|
+
description: "不访问任何网络。"
|
|
1403
|
+
},
|
|
1404
|
+
"scoped-network": {
|
|
1405
|
+
label: "限定地址联网",
|
|
1406
|
+
description: "只访问指定域名或用户在配置中填写的地址。"
|
|
1407
|
+
},
|
|
1408
|
+
"managed-secrets": {
|
|
1409
|
+
label: "凭据托管",
|
|
1410
|
+
description: "凭据都是配置中的凭据字段,经宿主读取,没有写进源码。"
|
|
1411
|
+
},
|
|
1412
|
+
"readable-source": {
|
|
1413
|
+
label: "源码可读",
|
|
1414
|
+
description: "没有混淆、压缩或内嵌大段编码内容。"
|
|
1415
|
+
},
|
|
1416
|
+
"open-source": {
|
|
1417
|
+
label: "开源",
|
|
1418
|
+
description: "填写了公开的源码仓库。"
|
|
1419
|
+
},
|
|
1420
|
+
"readable-errors": {
|
|
1421
|
+
label: "错误可读",
|
|
1422
|
+
description: "失败时都返回给用户看的说明,稳定满星。"
|
|
1423
|
+
},
|
|
1424
|
+
"stable-context": {
|
|
1425
|
+
label: "上下文稳定",
|
|
1426
|
+
description: "不占上下文,或注入的上下文稳定、不破坏提示缓存。"
|
|
1427
|
+
},
|
|
1428
|
+
"complete-docs": {
|
|
1429
|
+
label: "说明完整",
|
|
1430
|
+
description: "有图标和介绍,易用至少四星。"
|
|
1431
|
+
}
|
|
1432
|
+
};
|
|
1433
|
+
const COMMUNITY_RATING_BADGE_LIMIT = 4;
|
|
1434
|
+
/** 一次发布的评级:六维星级、综合评分(各维度平均,保留一位小数)与达成标签。 */
|
|
1435
|
+
const CommunityRatingSchema = z.object({
|
|
1436
|
+
standard: z.string().max(20),
|
|
1437
|
+
score: z.number().min(1).max(5),
|
|
1438
|
+
dimensions: z.array(z.object({
|
|
1439
|
+
key: z.string().max(40),
|
|
1440
|
+
stars: z.number().int().min(1).max(5),
|
|
1441
|
+
headline: z.string().max(200),
|
|
1442
|
+
cap: z.string().max(200).optional()
|
|
1443
|
+
})).max(16),
|
|
1444
|
+
badges: z.array(z.string().max(40)).max(32)
|
|
1445
|
+
});
|
|
1446
|
+
/** 市场的排序方式。 */
|
|
1447
|
+
const COMMUNITY_EXTENSION_SORTS = [
|
|
1448
|
+
{
|
|
1449
|
+
key: "updated",
|
|
1450
|
+
label: "最近更新"
|
|
1451
|
+
},
|
|
1452
|
+
{
|
|
1453
|
+
key: "score",
|
|
1454
|
+
label: "综合评分"
|
|
1455
|
+
},
|
|
1456
|
+
{
|
|
1457
|
+
key: "downloads",
|
|
1458
|
+
label: "下载最多"
|
|
1459
|
+
},
|
|
1460
|
+
{
|
|
1461
|
+
key: "newest",
|
|
1462
|
+
label: "最新上架"
|
|
1463
|
+
}
|
|
1464
|
+
];
|
|
1465
|
+
const CommunityExtensionSortSchema = z.enum([
|
|
1466
|
+
"updated",
|
|
1467
|
+
"score",
|
|
1468
|
+
"downloads",
|
|
1469
|
+
"newest"
|
|
1293
1470
|
]);
|
|
1294
1471
|
const CommunityReleaseIdSchema = z.string().regex(/^rel_[0-9A-Za-z]+$/u);
|
|
1295
1472
|
const CommunityAccountSchema = z.object({
|
|
1296
1473
|
handle: z.string().min(1).max(80),
|
|
1297
1474
|
displayName: z.string().max(200),
|
|
1298
1475
|
avatarUrl: z.string().url().nullable()
|
|
1299
|
-
})
|
|
1476
|
+
});
|
|
1300
1477
|
const CommunityEnvironmentSchema = z.enum([
|
|
1301
1478
|
"production",
|
|
1302
1479
|
"staging",
|
|
@@ -1310,7 +1487,7 @@ const CommunityStatusSchema = z.object({
|
|
|
1310
1487
|
signedInAt: z.number().int().nullable(),
|
|
1311
1488
|
/** 最近一次更新检查发现的可更新扩展数量(只读缓存,不发起网络请求)。 */
|
|
1312
1489
|
updatesAvailable: z.number().int().nonnegative()
|
|
1313
|
-
})
|
|
1490
|
+
});
|
|
1314
1491
|
const CommunityPermissionItemSchema = z.object({
|
|
1315
1492
|
key: z.string().max(120),
|
|
1316
1493
|
level: z.enum([
|
|
@@ -1319,32 +1496,34 @@ const CommunityPermissionItemSchema = z.object({
|
|
|
1319
1496
|
"high"
|
|
1320
1497
|
]),
|
|
1321
1498
|
label: z.string().max(200),
|
|
1322
|
-
detail: z.string().max(2e3).optional()
|
|
1323
|
-
|
|
1499
|
+
detail: z.string().max(2e3).optional(),
|
|
1500
|
+
/** `host`: approved when installed on this machine; `agent`: approved when enabled for an agent. */
|
|
1501
|
+
layer: z.enum(["host", "agent"]).optional()
|
|
1502
|
+
});
|
|
1324
1503
|
const CommunityReleaseSchema = z.object({
|
|
1325
1504
|
id: CommunityReleaseIdSchema,
|
|
1326
1505
|
reviewStatus: CommunityReviewStatusSchema,
|
|
1327
|
-
|
|
1506
|
+
/** 审查完成后的评级;尚未审查、审查未完成或旧版社区时为 null。 */
|
|
1507
|
+
rating: CommunityRatingSchema.nullable(),
|
|
1328
1508
|
permissions: z.array(CommunityPermissionItemSchema).max(64),
|
|
1329
1509
|
packageSize: z.number().int().nonnegative(),
|
|
1330
1510
|
requiresSdk: z.number().int().positive().nullable(),
|
|
1331
1511
|
notes: z.string().max(2e3),
|
|
1332
1512
|
createdAt: z.number().int()
|
|
1333
|
-
})
|
|
1513
|
+
});
|
|
1334
1514
|
/** 社区为官方扩展保留的发布者标识:官方扩展由多位官方成员维护,对外不显示个人账号。 */
|
|
1335
1515
|
const COMMUNITY_OFFICIAL_HANDLE = "nekro-nxt";
|
|
1336
1516
|
/** 发布者的展示文字:官方扩展显示「NekroNXT 官方」,其余显示 @账号。 */
|
|
1337
1517
|
const communityPublisherLabel = (handle) => handle === "nekro-nxt" ? "NekroNXT 官方" : `@${handle}`;
|
|
1338
1518
|
const CommunityExtensionSummarySchema = z.object({
|
|
1339
1519
|
id: ExtensionIdSchema,
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
"host-adapter",
|
|
1343
|
-
"host-ui"
|
|
1344
|
-
]),
|
|
1520
|
+
/** What the extension provides, derived from its Manifest; unknown future labels are dropped. */
|
|
1521
|
+
provides: z.array(z.string().max(32)).max(8),
|
|
1345
1522
|
displayName: z.string().max(200),
|
|
1346
1523
|
summary: z.string().max(1e3),
|
|
1347
1524
|
tags: z.array(z.string().max(40)).max(16),
|
|
1525
|
+
/** 最新公开发布包内的扩展图标(社区的绝对地址);没有图标或旧版社区时为 null。 */
|
|
1526
|
+
iconUrl: z.string().url().nullable(),
|
|
1348
1527
|
/** 由社区后台认定的官方扩展;此时发布者是社区保留的官方主页(`COMMUNITY_OFFICIAL_HANDLE`)。 */
|
|
1349
1528
|
official: z.boolean(),
|
|
1350
1529
|
publisher: CommunityAccountSchema,
|
|
@@ -1352,20 +1531,46 @@ const CommunityExtensionSummarySchema = z.object({
|
|
|
1352
1531
|
downloads: z.number().int().nonnegative(),
|
|
1353
1532
|
updatedAt: z.number().int(),
|
|
1354
1533
|
pageUrl: z.string().url()
|
|
1355
|
-
})
|
|
1534
|
+
});
|
|
1356
1535
|
const CommunityExtensionDetailSchema = CommunityExtensionSummarySchema.extend({
|
|
1357
1536
|
description: z.string().max(2e4),
|
|
1358
1537
|
sourceUrl: z.string().url().nullable(),
|
|
1538
|
+
/** 公开的审查记录:评级、总评、各维度说明,以及发现与自动检查的标题。 */
|
|
1359
1539
|
review: z.object({
|
|
1360
1540
|
status: CommunityReviewStatusSchema,
|
|
1361
|
-
|
|
1541
|
+
rating: CommunityRatingSchema.nullable(),
|
|
1362
1542
|
summary: z.string().max(2e3).nullable(),
|
|
1363
|
-
|
|
1543
|
+
dimensions: z.array(z.object({
|
|
1544
|
+
key: z.string().max(40),
|
|
1545
|
+
notes: z.string().max(2e3)
|
|
1546
|
+
})).max(16),
|
|
1547
|
+
findings: z.array(z.object({
|
|
1548
|
+
dimension: z.string().max(40),
|
|
1364
1549
|
severity: z.string().max(20),
|
|
1365
1550
|
title: z.string().max(200)
|
|
1366
|
-
})
|
|
1367
|
-
|
|
1368
|
-
|
|
1551
|
+
})).max(64),
|
|
1552
|
+
checks: z.array(z.object({
|
|
1553
|
+
severity: z.string().max(20),
|
|
1554
|
+
title: z.string().max(200)
|
|
1555
|
+
})).max(64),
|
|
1556
|
+
reviewedAt: z.number().int().nullable()
|
|
1557
|
+
}).nullable()
|
|
1558
|
+
});
|
|
1559
|
+
/**
|
|
1560
|
+
* 发布时随包提交的条目信息(作者自己写的介绍)。首次发布用于建条目;之后提供了哪项就覆盖哪项,未提供的保持不变。
|
|
1561
|
+
*/
|
|
1562
|
+
const COMMUNITY_LISTING_LIMITS = {
|
|
1563
|
+
summary: 160,
|
|
1564
|
+
description: 2e4,
|
|
1565
|
+
tags: 8,
|
|
1566
|
+
tag: 40
|
|
1567
|
+
};
|
|
1568
|
+
const CommunityListingInputSchema = z.object({
|
|
1569
|
+
summary: z.string().trim().max(COMMUNITY_LISTING_LIMITS.summary).optional(),
|
|
1570
|
+
description: z.string().max(COMMUNITY_LISTING_LIMITS.description).optional(),
|
|
1571
|
+
tags: z.array(z.string().trim().min(1).max(COMMUNITY_LISTING_LIMITS.tag)).max(COMMUNITY_LISTING_LIMITS.tags).optional(),
|
|
1572
|
+
sourceUrl: z.string().trim().url().refine((value) => /^https?:\/\//iu.test(value), "源码地址必须是 http(s) 链接。").optional()
|
|
1573
|
+
});
|
|
1369
1574
|
const CommunityEndpointSchema = z.object({
|
|
1370
1575
|
url: z.string().url(),
|
|
1371
1576
|
source: z.enum([
|
|
@@ -1377,14 +1582,14 @@ const CommunityEndpointSchema = z.object({
|
|
|
1377
1582
|
environmentUrl: z.string().url().nullable(),
|
|
1378
1583
|
/** 当前地址是未加密的非本机地址。 */
|
|
1379
1584
|
insecure: z.boolean()
|
|
1380
|
-
})
|
|
1585
|
+
});
|
|
1381
1586
|
const CommunitySourceSchema = z.object({
|
|
1382
1587
|
kind: z.literal("community"),
|
|
1383
1588
|
communityUrl: z.string().url(),
|
|
1384
1589
|
releaseId: CommunityReleaseIdSchema,
|
|
1385
1590
|
publisherHandle: z.string().min(1).max(80),
|
|
1386
1591
|
installedAt: z.number().int().nonnegative()
|
|
1387
|
-
})
|
|
1592
|
+
});
|
|
1388
1593
|
const CommunityInstalledItemSchema = z.object({
|
|
1389
1594
|
extensionId: ExtensionIdSchema,
|
|
1390
1595
|
displayName: z.string(),
|
|
@@ -1400,39 +1605,26 @@ const CommunityInstalledItemSchema = z.object({
|
|
|
1400
1605
|
latest: CommunityReleaseSchema.nullable(),
|
|
1401
1606
|
updateAvailable: z.boolean(),
|
|
1402
1607
|
addedPermissions: z.array(CommunityPermissionItemSchema)
|
|
1403
|
-
})
|
|
1608
|
+
});
|
|
1404
1609
|
const CommunityInstalledSchema = z.object({
|
|
1405
1610
|
checkedAt: z.number().int().nullable(),
|
|
1406
1611
|
items: z.array(CommunityInstalledItemSchema)
|
|
1407
|
-
})
|
|
1612
|
+
});
|
|
1408
1613
|
const CommunityMyExtensionSchema = CommunityExtensionSummarySchema.extend({
|
|
1409
|
-
releases: z.array(CommunityReleaseSchema.extend({ withdrawn: z.boolean() })
|
|
1614
|
+
releases: z.array(CommunityReleaseSchema.extend({ withdrawn: z.boolean() })),
|
|
1410
1615
|
delisted: z.boolean(),
|
|
1411
1616
|
delistedReason: z.string().nullable()
|
|
1412
|
-
})
|
|
1413
|
-
|
|
1414
|
-
"security",
|
|
1415
|
-
"transparency",
|
|
1416
|
-
"reliability",
|
|
1417
|
-
"context_cost",
|
|
1418
|
-
"usability",
|
|
1419
|
-
"maintainability",
|
|
1420
|
-
"compliance"
|
|
1421
|
-
];
|
|
1617
|
+
});
|
|
1618
|
+
/** 审查发现可归属的维度:六个评级维度加合规。 */
|
|
1422
1619
|
const COMMUNITY_REVIEW_DIMENSION_LABELS = {
|
|
1423
|
-
|
|
1424
|
-
transparency: "源码透明",
|
|
1425
|
-
reliability: "可靠性",
|
|
1426
|
-
context_cost: "上下文与成本",
|
|
1427
|
-
usability: "可用性",
|
|
1428
|
-
maintainability: "可维护性",
|
|
1620
|
+
...COMMUNITY_RATING_DIMENSION_LABELS,
|
|
1429
1621
|
compliance: "合规"
|
|
1430
1622
|
};
|
|
1431
1623
|
/** 作者看到的完整审查报告。 */
|
|
1432
1624
|
const CommunityReviewReportSchema = z.object({
|
|
1433
1625
|
releaseId: CommunityReleaseIdSchema,
|
|
1434
1626
|
status: CommunityReviewStatusSchema,
|
|
1435
|
-
|
|
1627
|
+
rating: CommunityRatingSchema.nullable(),
|
|
1436
1628
|
deterministic: z.array(z.object({
|
|
1437
1629
|
severity: z.enum([
|
|
1438
1630
|
"info",
|
|
@@ -1444,18 +1636,24 @@ const CommunityReviewReportSchema = z.object({
|
|
|
1444
1636
|
detail: z.string(),
|
|
1445
1637
|
file: z.string().optional(),
|
|
1446
1638
|
line: z.number().int().optional()
|
|
1447
|
-
})
|
|
1639
|
+
})),
|
|
1448
1640
|
ai: z.object({
|
|
1449
1641
|
summary: z.string(),
|
|
1450
1642
|
verdict: z.string(),
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
key: z.enum(COMMUNITY_REVIEW_DIMENSIONS),
|
|
1454
|
-
grade: CommunityGradeSchema,
|
|
1643
|
+
compliance: z.object({
|
|
1644
|
+
ok: z.boolean(),
|
|
1455
1645
|
notes: z.string()
|
|
1456
|
-
}).
|
|
1646
|
+
}).nullable(),
|
|
1647
|
+
dimensions: z.array(z.object({
|
|
1648
|
+
key: z.string(),
|
|
1649
|
+
stars: z.number().int().min(1).max(5),
|
|
1650
|
+
headline: z.string(),
|
|
1651
|
+
notes: z.string(),
|
|
1652
|
+
/** 不满五星时拿下一颗星的修改建议。 */
|
|
1653
|
+
nextStar: z.string().optional()
|
|
1654
|
+
})),
|
|
1457
1655
|
findings: z.array(z.object({
|
|
1458
|
-
dimension: z.
|
|
1656
|
+
dimension: z.string(),
|
|
1459
1657
|
severity: z.enum([
|
|
1460
1658
|
"info",
|
|
1461
1659
|
"suggestion",
|
|
@@ -1468,9 +1666,9 @@ const CommunityReviewReportSchema = z.object({
|
|
|
1468
1666
|
file: z.string().optional(),
|
|
1469
1667
|
line: z.number().int().optional(),
|
|
1470
1668
|
suggestion: z.string().optional()
|
|
1471
|
-
})
|
|
1669
|
+
})),
|
|
1472
1670
|
exploitability: z.string().optional()
|
|
1473
|
-
}).
|
|
1671
|
+
}).nullable(),
|
|
1474
1672
|
model: z.string().nullable(),
|
|
1475
1673
|
error: z.string().nullable(),
|
|
1476
1674
|
decisions: z.array(z.object({
|
|
@@ -1478,10 +1676,10 @@ const CommunityReviewReportSchema = z.object({
|
|
|
1478
1676
|
note: z.string(),
|
|
1479
1677
|
by: z.string(),
|
|
1480
1678
|
createdAt: z.number().int()
|
|
1481
|
-
})
|
|
1679
|
+
})),
|
|
1482
1680
|
finishedAt: z.number().int().nullable(),
|
|
1483
1681
|
reportUrl: z.string().url()
|
|
1484
|
-
})
|
|
1682
|
+
});
|
|
1485
1683
|
/** 安装者看到的审查标签:只描述审查发现,不做「安全」担保。 */
|
|
1486
1684
|
const communityReviewLabel = (status) => {
|
|
1487
1685
|
switch (status) {
|
|
@@ -1518,6 +1716,91 @@ const communityReviewLabel = (status) => {
|
|
|
1518
1716
|
}
|
|
1519
1717
|
};
|
|
1520
1718
|
//#endregion
|
|
1719
|
+
//#region src/community-personas.ts
|
|
1720
|
+
/**
|
|
1721
|
+
* 社区人设在本机的投影:名称、头像、简介、作者介绍、标签与人设正文(对应智能体的 `persona`)。不含模型与扩展。
|
|
1722
|
+
* Host 宽松读取社区响应并归一到这些结构;头像改写为本机代理地址,页面不直接跨域读取社区图片。
|
|
1723
|
+
*/
|
|
1724
|
+
const CommunityPersonaIdSchema = z.string().regex(/^psn_[0-9A-Za-z]+$/u);
|
|
1725
|
+
const CommunityPersonaRevisionIdSchema = z.string().regex(/^prv_[0-9A-Za-z]+$/u);
|
|
1726
|
+
/** 人设正文上限,与智能体设定一致。 */
|
|
1727
|
+
const COMMUNITY_PERSONA_MAX_LENGTH = 64 * 1024;
|
|
1728
|
+
/** 发布头像上限(社区约定 ≤512 KiB 的 PNG、JPEG 或 WebP)。 */
|
|
1729
|
+
const COMMUNITY_PERSONA_AVATAR_MAX_BYTES = 512 * 1024;
|
|
1730
|
+
const COMMUNITY_PERSONA_AVATAR_TYPES = [
|
|
1731
|
+
"image/png",
|
|
1732
|
+
"image/jpeg",
|
|
1733
|
+
"image/webp"
|
|
1734
|
+
];
|
|
1735
|
+
const TagsSchema = z.array(z.string().min(1).max(40)).max(16);
|
|
1736
|
+
const CommunityPersonaSummarySchema = z.object({
|
|
1737
|
+
id: CommunityPersonaIdSchema,
|
|
1738
|
+
name: z.string().min(1).max(200),
|
|
1739
|
+
summary: z.string().max(1e3),
|
|
1740
|
+
tags: TagsSchema,
|
|
1741
|
+
/** 本机代理地址 `/api/community/personas/<id>/avatar?v=…`;没有头像时为 null。 */
|
|
1742
|
+
avatarUrl: z.string().startsWith("/api/community/personas/").nullable(),
|
|
1743
|
+
official: z.boolean(),
|
|
1744
|
+
publisher: CommunityAccountSchema,
|
|
1745
|
+
installs: z.number().int().nonnegative(),
|
|
1746
|
+
updatedAt: z.number().int(),
|
|
1747
|
+
pageUrl: z.string().url()
|
|
1748
|
+
});
|
|
1749
|
+
const CommunityPersonaDetailSchema = CommunityPersonaSummarySchema.extend({
|
|
1750
|
+
description: z.string().max(2e4),
|
|
1751
|
+
persona: z.string().max(COMMUNITY_PERSONA_MAX_LENGTH),
|
|
1752
|
+
revision: z.object({
|
|
1753
|
+
id: CommunityPersonaRevisionIdSchema,
|
|
1754
|
+
notes: z.string().max(2e3),
|
|
1755
|
+
createdAt: z.number().int()
|
|
1756
|
+
}),
|
|
1757
|
+
review: z.object({
|
|
1758
|
+
status: z.enum(["approved", "flagged"]),
|
|
1759
|
+
summary: z.string().max(2e3).nullable()
|
|
1760
|
+
}).nullable()
|
|
1761
|
+
});
|
|
1762
|
+
const CommunityPersonaReviewStatusSchema = z.enum([
|
|
1763
|
+
"pending",
|
|
1764
|
+
"approved",
|
|
1765
|
+
"flagged",
|
|
1766
|
+
"rejected"
|
|
1767
|
+
]);
|
|
1768
|
+
const CommunityMyPersonaSchema = CommunityPersonaSummarySchema.extend({
|
|
1769
|
+
status: z.enum(["listed", "delisted"]),
|
|
1770
|
+
latestRevision: z.object({
|
|
1771
|
+
id: CommunityPersonaRevisionIdSchema,
|
|
1772
|
+
createdAt: z.number().int(),
|
|
1773
|
+
reviewStatus: CommunityPersonaReviewStatusSchema,
|
|
1774
|
+
reviewSummary: z.string().max(2e3).nullable()
|
|
1775
|
+
})
|
|
1776
|
+
});
|
|
1777
|
+
const CommunityMyPersonasSchema = z.object({
|
|
1778
|
+
items: z.array(CommunityMyPersonaSchema),
|
|
1779
|
+
/** 本机智能体最近一次发布到当前社区的人设,用于「更新已发布的人设」。 */
|
|
1780
|
+
agentLinks: z.record(AgentIdSchema, CommunityPersonaIdSchema)
|
|
1781
|
+
});
|
|
1782
|
+
/** 作者看到的审查状态文字。 */
|
|
1783
|
+
const communityPersonaReviewLabel = (status) => {
|
|
1784
|
+
switch (status) {
|
|
1785
|
+
case "approved": return {
|
|
1786
|
+
tone: "ok",
|
|
1787
|
+
label: "已公开"
|
|
1788
|
+
};
|
|
1789
|
+
case "pending": return {
|
|
1790
|
+
tone: "neutral",
|
|
1791
|
+
label: "审查中"
|
|
1792
|
+
};
|
|
1793
|
+
case "flagged": return {
|
|
1794
|
+
tone: "warn",
|
|
1795
|
+
label: "待人工复核"
|
|
1796
|
+
};
|
|
1797
|
+
case "rejected": return {
|
|
1798
|
+
tone: "bad",
|
|
1799
|
+
label: "未通过"
|
|
1800
|
+
};
|
|
1801
|
+
}
|
|
1802
|
+
};
|
|
1803
|
+
//#endregion
|
|
1521
1804
|
//#region src/host-api.ts
|
|
1522
1805
|
const EmptyParamsSchema = z.object({}).strict();
|
|
1523
1806
|
const NoRequestBodySchema = z.undefined();
|
|
@@ -1652,6 +1935,24 @@ const AgentModelSchema = z.object({
|
|
|
1652
1935
|
model: NonEmptyStringSchema,
|
|
1653
1936
|
reasoningEffort: NonEmptyStringSchema.optional()
|
|
1654
1937
|
}).strict();
|
|
1938
|
+
/**
|
|
1939
|
+
* An enable or disable request of one agent extension that has not settled: `waiting` until the agent reaches a safe
|
|
1940
|
+
* gap (its current reply ends), or `failed` with the reason until the next request replaces it.
|
|
1941
|
+
*/
|
|
1942
|
+
/** What one approval asks the user to grant and whether the current grant already covers it. */
|
|
1943
|
+
const ExtensionPermissionRequirementSchema = z.object({
|
|
1944
|
+
declaration: HostUiPermissionDeclarationSchema,
|
|
1945
|
+
permissionDigest: z.string().regex(/^[a-f0-9]{64}$/u),
|
|
1946
|
+
approvalRequired: z.boolean()
|
|
1947
|
+
}).strict();
|
|
1948
|
+
const ExtensionActivationTransitionSchema = z.object({
|
|
1949
|
+
agentId: AgentIdSchema,
|
|
1950
|
+
target: z.enum(["enabled", "disabled"]),
|
|
1951
|
+
extensionRevisionId: ExtensionRevisionIdSchema.optional(),
|
|
1952
|
+
state: z.enum(["waiting", "failed"]),
|
|
1953
|
+
message: z.string().optional(),
|
|
1954
|
+
since: z.number().int().safe().nonnegative()
|
|
1955
|
+
}).strict();
|
|
1655
1956
|
const ImageUnderstandingPolicyApiSchema = z.object({
|
|
1656
1957
|
history: z.object({
|
|
1657
1958
|
mode: z.literal("persistent-distinct"),
|
|
@@ -1800,7 +2101,9 @@ const HostSnapshotMessageSchema = z.object({
|
|
|
1800
2101
|
parts: z.array(SnapshotMessagePartSchema),
|
|
1801
2102
|
sender: z.object({
|
|
1802
2103
|
memberId: ChannelMemberIdSchema,
|
|
1803
|
-
displayName: z.string().optional()
|
|
2104
|
+
displayName: z.string().optional(),
|
|
2105
|
+
/** The sender is the account of this agent on this host, answering the channel through another connection. */
|
|
2106
|
+
localAgentId: AgentIdSchema.optional()
|
|
1804
2107
|
}).strict().optional(),
|
|
1805
2108
|
mentionedConnectionAccount: z.boolean().optional(),
|
|
1806
2109
|
activityKey: AdapterActivityKeySchema.optional(),
|
|
@@ -1954,6 +2257,16 @@ const ChannelRuntimeStepSchema = z.object({
|
|
|
1954
2257
|
firstTokenMs: z.number().int().nonnegative().optional(),
|
|
1955
2258
|
usage: ChannelRuntimeUsageSchema.optional()
|
|
1956
2259
|
}).strict();
|
|
2260
|
+
/** One message that entered the model's input during a turn: channel admissions and host or DSH injections. */
|
|
2261
|
+
const ChannelRuntimeInputSchema = z.object({
|
|
2262
|
+
messageId: z.string().min(1),
|
|
2263
|
+
/** DSH `user/message` source kind, e.g. `nekro-nxt-channel` or `nekro-nxt-handoff`. */
|
|
2264
|
+
source: z.string().min(1),
|
|
2265
|
+
/** Channel Events carried by a channel admission. */
|
|
2266
|
+
eventCount: z.number().int().positive().optional(),
|
|
2267
|
+
preview: z.string().optional(),
|
|
2268
|
+
at: z.number().int().safe().nonnegative().optional()
|
|
2269
|
+
}).strict();
|
|
1957
2270
|
const ChannelRuntimeTurnSchema = z.object({
|
|
1958
2271
|
turn: z.number().int().nonnegative(),
|
|
1959
2272
|
state: z.enum([
|
|
@@ -1985,7 +2298,9 @@ const ChannelRuntimeTurnSchema = z.object({
|
|
|
1985
2298
|
/** Session log time the turn closed; absent while it is still running. */
|
|
1986
2299
|
endedAt: z.number().int().safe().nonnegative().optional(),
|
|
1987
2300
|
/** Newest Channel Event of the admission that opened this turn; absent for non-channel turns. */
|
|
1988
|
-
triggerEventId: ChannelEventIdSchema.optional()
|
|
2301
|
+
triggerEventId: ChannelEventIdSchema.optional(),
|
|
2302
|
+
/** Messages that entered the model's input during the turn, in log order; absent when there were none. */
|
|
2303
|
+
inputs: z.array(ChannelRuntimeInputSchema).optional()
|
|
1989
2304
|
}).strict();
|
|
1990
2305
|
const ChannelRuntimeOccupancySchema = z.object({
|
|
1991
2306
|
projectedTokens: z.number().int().nonnegative(),
|
|
@@ -2064,6 +2379,54 @@ const ChannelRuntimeSseDataSchema = ChannelRuntimeProjectionSchema.extend({
|
|
|
2064
2379
|
revision: z.number().int().positive(),
|
|
2065
2380
|
truncated: z.boolean().optional()
|
|
2066
2381
|
}).strict();
|
|
2382
|
+
const ChannelRuntimeContextSchema = z.object({
|
|
2383
|
+
available: z.boolean(),
|
|
2384
|
+
route: z.object({
|
|
2385
|
+
provider: z.string(),
|
|
2386
|
+
model: z.string(),
|
|
2387
|
+
contextWindow: z.number().int().positive().optional(),
|
|
2388
|
+
reasoningEffort: z.string().optional(),
|
|
2389
|
+
temperature: z.number().optional(),
|
|
2390
|
+
maxTokens: z.number().int().positive().optional()
|
|
2391
|
+
}).strict().optional(),
|
|
2392
|
+
instructions: z.array(z.object({
|
|
2393
|
+
role: z.enum(["system", "developer"]),
|
|
2394
|
+
text: z.string(),
|
|
2395
|
+
truncated: z.boolean()
|
|
2396
|
+
}).strict()),
|
|
2397
|
+
tools: z.array(z.object({
|
|
2398
|
+
name: z.string(),
|
|
2399
|
+
description: z.string().optional(),
|
|
2400
|
+
parameters: z.string().optional()
|
|
2401
|
+
}).strict()),
|
|
2402
|
+
changes: z.array(z.object({
|
|
2403
|
+
at: z.number().nonnegative().optional(),
|
|
2404
|
+
reason: z.enum([
|
|
2405
|
+
"initial",
|
|
2406
|
+
"resume",
|
|
2407
|
+
"change",
|
|
2408
|
+
"series"
|
|
2409
|
+
]),
|
|
2410
|
+
toolCount: z.number().int().nonnegative()
|
|
2411
|
+
}).strict())
|
|
2412
|
+
}).strict();
|
|
2413
|
+
/** A channel's own instructions for whoever answers it, with recent earlier versions to restore. */
|
|
2414
|
+
const ChannelPromptViewSchema = z.object({
|
|
2415
|
+
document: PromptDocumentV1Schema,
|
|
2416
|
+
/** The agent may not rewrite a locked prompt. */
|
|
2417
|
+
locked: z.boolean(),
|
|
2418
|
+
/** 0 before the first save; send it back as `expectedRevision`. */
|
|
2419
|
+
revision: z.number().int().nonnegative(),
|
|
2420
|
+
maxChars: z.number().int().positive(),
|
|
2421
|
+
updatedBy: z.enum(["admin", "agent"]).optional(),
|
|
2422
|
+
updatedAt: z.number().int().nonnegative().optional(),
|
|
2423
|
+
revisions: z.array(z.object({
|
|
2424
|
+
revision: z.number().int().positive(),
|
|
2425
|
+
document: PromptDocumentV1Schema,
|
|
2426
|
+
updatedBy: z.enum(["admin", "agent"]),
|
|
2427
|
+
updatedAt: z.number().int().nonnegative()
|
|
2428
|
+
}).strict())
|
|
2429
|
+
}).strict();
|
|
2067
2430
|
const AdapterConnectionCreationSchema = z.object({
|
|
2068
2431
|
mode: z.enum(["schema-form", "qr-login"]),
|
|
2069
2432
|
actionLabel: z.string().trim().min(1).optional(),
|
|
@@ -2400,11 +2763,15 @@ const HostSnapshotSchema = z.object({
|
|
|
2400
2763
|
unreadCount: 0,
|
|
2401
2764
|
unreadCapped: false
|
|
2402
2765
|
}),
|
|
2766
|
+
/** Other agents on this host that answer the same platform channel through another connection; absent when none. */
|
|
2767
|
+
localAgentIds: z.array(AgentIdSchema).min(1).optional(),
|
|
2403
2768
|
bindings: z.array(z.object({
|
|
2404
2769
|
channelId: ChannelIdSchema,
|
|
2405
2770
|
agentId: AgentIdSchema,
|
|
2406
2771
|
triggerPolicy: TriggerPolicySchema,
|
|
2407
2772
|
processingFeedback: z.enum(["auto", "off"]).default("auto"),
|
|
2773
|
+
/** Absent means `observe`. */
|
|
2774
|
+
localAgentMessages: z.enum(["observe", "trigger"]).optional(),
|
|
2408
2775
|
activityTriggerOverrides: ActivityTriggerOverridesSchema.default({}),
|
|
2409
2776
|
boundAt: z.number().int().safe().nonnegative()
|
|
2410
2777
|
}).strict())
|
|
@@ -2483,11 +2850,8 @@ const HostSnapshotSchema = z.object({
|
|
|
2483
2850
|
}).strict()).default([]),
|
|
2484
2851
|
extensions: z.array(z.object({
|
|
2485
2852
|
id: ExtensionIdSchema,
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
"host-adapter",
|
|
2489
|
-
"host-ui"
|
|
2490
|
-
]),
|
|
2853
|
+
/** What the latest Revision provides; listing and filtering only. */
|
|
2854
|
+
provides: z.array(ExtensionProvideSchema),
|
|
2491
2855
|
slug: NonEmptyStringSchema,
|
|
2492
2856
|
displayName: z.string(),
|
|
2493
2857
|
description: z.string(),
|
|
@@ -2497,15 +2861,18 @@ const HostSnapshotSchema = z.object({
|
|
|
2497
2861
|
revisionNumber: z.number().int().positive(),
|
|
2498
2862
|
format: z.enum(["current", "unavailable"]).optional(),
|
|
2499
2863
|
ui: ExtensionUiContributionsSchema.default(EMPTY_EXTENSION_UI_CONTRIBUTIONS),
|
|
2500
|
-
|
|
2864
|
+
/** The host instance's configuration form (`config.host`). */
|
|
2865
|
+
hostConfigSchema: ConfigSchemaDocumentSchema.optional(),
|
|
2866
|
+
/** Each enabled agent's configuration form (`config.agent`). */
|
|
2867
|
+
agentConfigSchema: ConfigSchemaDocumentSchema.optional(),
|
|
2868
|
+
/** 扩展包自带图标的读取路径(同源、按摘要寻址、可长期缓存);没有图标时缺省。 */
|
|
2869
|
+
iconUrl: z.string().regex(/^\/api\/extensions\/[^/]+\/revisions\/[^/]+\/icon\/[a-f0-9]{64}\.(?:svg|png|webp)$/u).optional(),
|
|
2501
2870
|
createdAt: z.number().int().safe().nonnegative(),
|
|
2502
2871
|
/** 从社区安装的保存记录的来源;本机保存与文件导入没有来源。 */
|
|
2503
2872
|
source: CommunitySourceSchema.optional(),
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
"host-ui"
|
|
2508
|
-
]),
|
|
2873
|
+
provides: z.array(ExtensionProvideSchema),
|
|
2874
|
+
/** Whether this Revision can be enabled for agents (agent-layer contributions or capabilities). */
|
|
2875
|
+
agentLayer: z.boolean(),
|
|
2509
2876
|
contributions: z.array(z.string()),
|
|
2510
2877
|
verification: z.object({
|
|
2511
2878
|
verifiedAt: z.number().int().nonnegative(),
|
|
@@ -2522,9 +2889,11 @@ const HostSnapshotSchema = z.object({
|
|
|
2522
2889
|
renderedPages: z.array(HostPageContributionSchema).max(8).optional(),
|
|
2523
2890
|
usedUiComponents: z.array(HostUiKitComponentNameSchema).optional(),
|
|
2524
2891
|
pageGeometry: z.array(HostUiPageGeometryEvidenceSchema).max(8).optional(),
|
|
2525
|
-
permissions:
|
|
2526
|
-
|
|
2527
|
-
|
|
2892
|
+
permissions: ExtensionPermissionsSchema.optional(),
|
|
2893
|
+
/** Installing this Revision on the machine, against the current host grant. */
|
|
2894
|
+
hostPermission: ExtensionPermissionRequirementSchema.optional(),
|
|
2895
|
+
/** Enabling this Revision for an agent that has no grant yet. */
|
|
2896
|
+
agentPermission: ExtensionPermissionRequirementSchema.optional(),
|
|
2528
2897
|
adapter: z.object({
|
|
2529
2898
|
apiVersion: z.literal(2),
|
|
2530
2899
|
key: NonEmptyStringSchema,
|
|
@@ -2572,10 +2941,14 @@ const HostSnapshotSchema = z.object({
|
|
|
2572
2941
|
observedAt: z.number().int().safe().nonnegative()
|
|
2573
2942
|
}).strict()).optional()
|
|
2574
2943
|
}).strict()),
|
|
2944
|
+
/** Present only while some agent's enable or disable request is waiting or has failed. */
|
|
2945
|
+
activationTransitions: z.array(ExtensionActivationTransitionSchema).optional(),
|
|
2575
2946
|
installation: z.object({
|
|
2576
2947
|
extensionRevisionId: ExtensionRevisionIdSchema,
|
|
2577
2948
|
installedAt: z.number().int().safe().nonnegative(),
|
|
2949
|
+
/** Secret fields are removed; `configuredSecrets` lists those the Host stores. */
|
|
2578
2950
|
config: JsonValueSchema.default({}),
|
|
2951
|
+
configuredSecrets: z.array(z.string()).optional(),
|
|
2579
2952
|
runtime: z.object({
|
|
2580
2953
|
status: z.enum([
|
|
2581
2954
|
"active",
|
|
@@ -2586,11 +2959,8 @@ const HostSnapshotSchema = z.object({
|
|
|
2586
2959
|
observedAt: z.number().int().safe().nonnegative()
|
|
2587
2960
|
}).optional()
|
|
2588
2961
|
}).strict().optional(),
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
permissionDigest: z.string().regex(/^[a-f0-9]{64}$/u),
|
|
2592
|
-
approvalRequired: z.boolean()
|
|
2593
|
-
}).strict().optional(),
|
|
2962
|
+
/** Installing the latest Revision on this machine, against the current host grant. */
|
|
2963
|
+
hostPermission: ExtensionPermissionRequirementSchema.optional(),
|
|
2594
2964
|
hostClientDiagnostic: z.object({
|
|
2595
2965
|
revisionId: ExtensionRevisionIdSchema,
|
|
2596
2966
|
status: z.enum(["loaded", "failed"]),
|
|
@@ -2948,6 +3318,19 @@ const LlmProviderCredentialSchema = z.object({
|
|
|
2948
3318
|
source: z.string().optional(),
|
|
2949
3319
|
writable: z.boolean()
|
|
2950
3320
|
}).strict();
|
|
3321
|
+
/**
|
|
3322
|
+
* The latest connection test that still describes the provider's saved address, protocol and API key. Tests made
|
|
3323
|
+
* before one of those changed are dropped. Never carries a key, request or response body.
|
|
3324
|
+
*/
|
|
3325
|
+
const LlmProviderTestResultSchema = z.object({
|
|
3326
|
+
/** Epoch milliseconds when the test finished. */
|
|
3327
|
+
at: z.number().int().nonnegative(),
|
|
3328
|
+
ok: z.boolean(),
|
|
3329
|
+
/** Short failure reason shown to the user; absent when the test passed. */
|
|
3330
|
+
message: z.string().max(240).optional(),
|
|
3331
|
+
/** The model the test asked. */
|
|
3332
|
+
model: NonEmptyStringSchema.optional()
|
|
3333
|
+
}).strict();
|
|
2951
3334
|
const LlmProviderViewSchema = z.object({
|
|
2952
3335
|
provider: NonEmptyStringSchema,
|
|
2953
3336
|
displayName: z.string(),
|
|
@@ -2964,7 +3347,9 @@ const LlmProviderViewSchema = z.object({
|
|
|
2964
3347
|
/** The model list was edited on this host; built-in providers can restore their own catalog. */
|
|
2965
3348
|
modelsCustomized: z.boolean(),
|
|
2966
3349
|
/** The provider's adapter can list the models its endpoint offers. */
|
|
2967
|
-
discoverable: z.boolean()
|
|
3350
|
+
discoverable: z.boolean(),
|
|
3351
|
+
/** `null` when the current configuration was never tested; absent from hosts that do not record tests. */
|
|
3352
|
+
lastTest: LlmProviderTestResultSchema.nullable().optional()
|
|
2968
3353
|
}).strict();
|
|
2969
3354
|
const LlmProviderSettingsSchema = z.object({
|
|
2970
3355
|
writable: z.boolean(),
|
|
@@ -3005,11 +3390,7 @@ const ExtensionImportInspectionSchema = z.object({
|
|
|
3005
3390
|
revisionId: ExtensionRevisionIdSchema,
|
|
3006
3391
|
slug: NonEmptyStringSchema,
|
|
3007
3392
|
displayName: NonEmptyStringSchema,
|
|
3008
|
-
|
|
3009
|
-
"agent",
|
|
3010
|
-
"host-adapter",
|
|
3011
|
-
"host-ui"
|
|
3012
|
-
]),
|
|
3393
|
+
provides: z.array(ExtensionProvideSchema),
|
|
3013
3394
|
idempotent: z.boolean(),
|
|
3014
3395
|
slugConflict: z.boolean()
|
|
3015
3396
|
}).strict();
|
|
@@ -3056,6 +3437,7 @@ const agentExtensionParam = z.object({
|
|
|
3056
3437
|
agentId: AgentIdSchema,
|
|
3057
3438
|
extensionId: ExtensionIdSchema
|
|
3058
3439
|
}).strict();
|
|
3440
|
+
const PermissionApprovalSchema = z.object({ permissionDigest: z.string().regex(/^[a-f0-9]{64}$/u) }).strict();
|
|
3059
3441
|
const extensionParam = z.object({ extensionId: ExtensionIdSchema }).strict();
|
|
3060
3442
|
const dshPluginPackageParam = z.object({ packageId: DshPluginPackageIdSchema }).strict();
|
|
3061
3443
|
const dshPluginEntryParam = z.object({ entryId: DshPluginEntryIdSchema }).strict();
|
|
@@ -3391,6 +3773,8 @@ const HostApiContracts = {
|
|
|
3391
3773
|
channelId: ChannelIdSchema,
|
|
3392
3774
|
triggerPolicy: TriggerPolicySchema,
|
|
3393
3775
|
processingFeedback: z.enum(["auto", "off"]).optional(),
|
|
3776
|
+
/** Messages from another local agent's account: `observe` keeps them as context unless they @ this agent. */
|
|
3777
|
+
localAgentMessages: z.enum(["observe", "trigger"]).optional(),
|
|
3394
3778
|
activityTriggerOverrides: ActivityTriggerOverridesSchema.optional()
|
|
3395
3779
|
}).strict(),
|
|
3396
3780
|
response: z.object({
|
|
@@ -3398,6 +3782,7 @@ const HostApiContracts = {
|
|
|
3398
3782
|
agentId: AgentIdSchema,
|
|
3399
3783
|
triggerPolicy: TriggerPolicySchema,
|
|
3400
3784
|
processingFeedback: z.enum(["auto", "off"]).default("auto"),
|
|
3785
|
+
localAgentMessages: z.enum(["observe", "trigger"]).optional(),
|
|
3401
3786
|
activityTriggerOverrides: ActivityTriggerOverridesSchema.default({}),
|
|
3402
3787
|
boundAt: z.number().int().safe().nonnegative()
|
|
3403
3788
|
}).strict(),
|
|
@@ -3492,6 +3877,52 @@ const HostApiContracts = {
|
|
|
3492
3877
|
}).strict(),
|
|
3493
3878
|
error: HostApiErrorSchema
|
|
3494
3879
|
}),
|
|
3880
|
+
getChannelRuntimeContext: defineContract({
|
|
3881
|
+
method: "GET",
|
|
3882
|
+
path: "/api/channels/:channelId/runtime/context",
|
|
3883
|
+
params: channelParam,
|
|
3884
|
+
request: NoRequestBodySchema,
|
|
3885
|
+
response: ChannelRuntimeContextSchema,
|
|
3886
|
+
error: HostApiErrorSchema
|
|
3887
|
+
}),
|
|
3888
|
+
getChannelRuntimeInput: defineContract({
|
|
3889
|
+
method: "GET",
|
|
3890
|
+
path: "/api/channels/:channelId/runtime/inputs/:messageId",
|
|
3891
|
+
params: z.object({
|
|
3892
|
+
channelId: ChannelIdSchema,
|
|
3893
|
+
messageId: z.string().trim().min(1).max(200)
|
|
3894
|
+
}).strict(),
|
|
3895
|
+
request: NoRequestBodySchema,
|
|
3896
|
+
response: z.object({
|
|
3897
|
+
messageId: z.string(),
|
|
3898
|
+
available: z.boolean(),
|
|
3899
|
+
source: z.string().optional(),
|
|
3900
|
+
text: z.string().optional(),
|
|
3901
|
+
truncated: z.boolean()
|
|
3902
|
+
}).strict(),
|
|
3903
|
+
error: HostApiErrorSchema
|
|
3904
|
+
}),
|
|
3905
|
+
getChannelPrompt: defineContract({
|
|
3906
|
+
method: "GET",
|
|
3907
|
+
path: "/api/channels/:channelId/prompt",
|
|
3908
|
+
params: channelParam,
|
|
3909
|
+
request: NoRequestBodySchema,
|
|
3910
|
+
response: ChannelPromptViewSchema,
|
|
3911
|
+
error: HostApiErrorSchema
|
|
3912
|
+
}),
|
|
3913
|
+
updateChannelPrompt: defineContract({
|
|
3914
|
+
method: "PUT",
|
|
3915
|
+
path: "/api/channels/:channelId/prompt",
|
|
3916
|
+
params: channelParam,
|
|
3917
|
+
request: z.object({
|
|
3918
|
+
document: PromptDocumentV1Schema,
|
|
3919
|
+
locked: z.boolean(),
|
|
3920
|
+
/** The revision the edit started from; a newer stored revision rejects the save. */
|
|
3921
|
+
expectedRevision: z.number().int().nonnegative()
|
|
3922
|
+
}).strict(),
|
|
3923
|
+
response: ChannelPromptViewSchema,
|
|
3924
|
+
error: HostApiErrorSchema
|
|
3925
|
+
}),
|
|
3495
3926
|
resetChannelContext: defineContract({
|
|
3496
3927
|
invalidatesSnapshot: true,
|
|
3497
3928
|
method: "POST",
|
|
@@ -3825,11 +4256,11 @@ const HostApiContracts = {
|
|
|
3825
4256
|
path: "/api/community/extensions",
|
|
3826
4257
|
params: z.object({
|
|
3827
4258
|
query: z.string().trim().max(80).optional(),
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
4259
|
+
provides: ExtensionProvideSchema.optional(),
|
|
4260
|
+
/** 只列社区后台认定的官方扩展。 */
|
|
4261
|
+
official: z.enum(["1"]).optional(),
|
|
4262
|
+
/** 排序方式,默认最近更新;游标只在同一种排序下有效。 */
|
|
4263
|
+
sort: CommunityExtensionSortSchema.optional(),
|
|
3833
4264
|
cursor: z.string().max(200).optional()
|
|
3834
4265
|
}).strict(),
|
|
3835
4266
|
request: NoRequestBodySchema,
|
|
@@ -3952,7 +4383,9 @@ const HostApiContracts = {
|
|
|
3952
4383
|
request: z.object({
|
|
3953
4384
|
extensionId: ExtensionIdSchema,
|
|
3954
4385
|
revisionId: ExtensionRevisionIdSchema,
|
|
3955
|
-
notes: z.string().max(2e3)
|
|
4386
|
+
notes: z.string().max(2e3),
|
|
4387
|
+
/** 作者填写的条目信息;省略的字段不改动社区上已有的内容。 */
|
|
4388
|
+
listing: CommunityListingInputSchema.optional()
|
|
3956
4389
|
}).strict(),
|
|
3957
4390
|
response: z.object({
|
|
3958
4391
|
releaseId: CommunityReleaseIdSchema,
|
|
@@ -3966,6 +4399,102 @@ const HostApiContracts = {
|
|
|
3966
4399
|
}).strict(),
|
|
3967
4400
|
error: HostApiErrorSchema
|
|
3968
4401
|
}),
|
|
4402
|
+
listCommunityPersonas: defineContract({
|
|
4403
|
+
timeoutMs: 3e4,
|
|
4404
|
+
method: "GET",
|
|
4405
|
+
path: "/api/community/personas",
|
|
4406
|
+
params: z.object({
|
|
4407
|
+
query: z.string().trim().min(1).max(200).optional(),
|
|
4408
|
+
tag: z.string().trim().min(1).max(40).optional(),
|
|
4409
|
+
official: z.literal("1").optional(),
|
|
4410
|
+
cursor: z.string().min(1).max(500).optional()
|
|
4411
|
+
}).strict(),
|
|
4412
|
+
request: NoRequestBodySchema,
|
|
4413
|
+
response: z.object({
|
|
4414
|
+
items: z.array(CommunityPersonaSummarySchema),
|
|
4415
|
+
nextCursor: z.string().nullable()
|
|
4416
|
+
}).strict(),
|
|
4417
|
+
error: HostApiErrorSchema
|
|
4418
|
+
}),
|
|
4419
|
+
getCommunityPersona: defineContract({
|
|
4420
|
+
timeoutMs: 3e4,
|
|
4421
|
+
method: "GET",
|
|
4422
|
+
path: "/api/community/personas/:personaId",
|
|
4423
|
+
params: z.object({ personaId: CommunityPersonaIdSchema }).strict(),
|
|
4424
|
+
request: NoRequestBodySchema,
|
|
4425
|
+
response: CommunityPersonaDetailSchema,
|
|
4426
|
+
error: HostApiErrorSchema
|
|
4427
|
+
}),
|
|
4428
|
+
/**
|
|
4429
|
+
* 把社区人设装进本机:新建一个智能体,或为现有智能体保存一次只换设定(及可选名称)的新配置。头像下载后作为
|
|
4430
|
+
* 智能体头像;下载失败不影响安装。`expectedRevisionId` 是用户看过的修订,社区已更新时拒绝,避免装入未看过的内容。
|
|
4431
|
+
*/
|
|
4432
|
+
installCommunityPersona: defineContract({
|
|
4433
|
+
invalidatesSnapshot: true,
|
|
4434
|
+
timeoutMs: 6e4,
|
|
4435
|
+
method: "POST",
|
|
4436
|
+
path: "/api/community/personas/:personaId/install",
|
|
4437
|
+
params: z.object({ personaId: CommunityPersonaIdSchema }).strict(),
|
|
4438
|
+
request: z.discriminatedUnion("target", [z.object({
|
|
4439
|
+
target: z.literal("new"),
|
|
4440
|
+
expectedRevisionId: CommunityPersonaRevisionIdSchema,
|
|
4441
|
+
displayName: z.string().trim().min(1).max(80),
|
|
4442
|
+
model: AgentModelSchema,
|
|
4443
|
+
useAvatar: z.boolean()
|
|
4444
|
+
}).strict(), z.object({
|
|
4445
|
+
target: z.literal("replace"),
|
|
4446
|
+
expectedRevisionId: CommunityPersonaRevisionIdSchema,
|
|
4447
|
+
agentId: AgentIdSchema,
|
|
4448
|
+
expectedCurrentRevisionId: AgentRevisionIdSchema,
|
|
4449
|
+
/** 同时改名;省略时保留原名称。 */
|
|
4450
|
+
displayName: z.string().trim().min(1).max(80).optional(),
|
|
4451
|
+
useAvatar: z.boolean()
|
|
4452
|
+
}).strict()]),
|
|
4453
|
+
response: z.object({
|
|
4454
|
+
agentId: AgentIdSchema,
|
|
4455
|
+
channelId: ChannelIdSchema.nullable(),
|
|
4456
|
+
currentRevisionId: AgentRevisionIdSchema,
|
|
4457
|
+
avatar: z.enum([
|
|
4458
|
+
"applied",
|
|
4459
|
+
"none",
|
|
4460
|
+
"failed"
|
|
4461
|
+
])
|
|
4462
|
+
}).strict(),
|
|
4463
|
+
error: HostApiErrorSchema
|
|
4464
|
+
}),
|
|
4465
|
+
listCommunityMyPersonas: defineContract({
|
|
4466
|
+
timeoutMs: 3e4,
|
|
4467
|
+
method: "GET",
|
|
4468
|
+
path: "/api/community/mine/personas",
|
|
4469
|
+
params: EmptyParamsSchema,
|
|
4470
|
+
request: NoRequestBodySchema,
|
|
4471
|
+
response: CommunityMyPersonasSchema,
|
|
4472
|
+
error: HostApiErrorSchema
|
|
4473
|
+
}),
|
|
4474
|
+
/** 把智能体的设定分享到社区;带 `personaId` 时更新自己已发布的人设(生成新修订并重新审查)。 */
|
|
4475
|
+
publishCommunityPersona: defineContract({
|
|
4476
|
+
timeoutMs: 6e4,
|
|
4477
|
+
method: "POST",
|
|
4478
|
+
path: "/api/community/personas/publish",
|
|
4479
|
+
params: EmptyParamsSchema,
|
|
4480
|
+
request: z.object({
|
|
4481
|
+
agentId: AgentIdSchema,
|
|
4482
|
+
personaId: CommunityPersonaIdSchema.optional(),
|
|
4483
|
+
name: z.string().trim().min(1).max(80),
|
|
4484
|
+
summary: z.string().trim().min(1).max(200),
|
|
4485
|
+
description: z.string().max(2e4),
|
|
4486
|
+
tags: z.array(z.string().trim().min(1).max(40)).max(16),
|
|
4487
|
+
persona: z.string().trim().min(1).max(COMMUNITY_PERSONA_MAX_LENGTH),
|
|
4488
|
+
notes: z.string().max(2e3).optional(),
|
|
4489
|
+
/** 页面缩放后的头像(Base64);省略时不上传头像,更新时保留社区上的原头像。 */
|
|
4490
|
+
avatar: z.object({
|
|
4491
|
+
mediaType: z.enum(COMMUNITY_PERSONA_AVATAR_TYPES),
|
|
4492
|
+
base64: z.string().min(1).max(Math.ceil(512 * 1024 * 4 / 3) + 4)
|
|
4493
|
+
}).strict().optional()
|
|
4494
|
+
}).strict(),
|
|
4495
|
+
response: CommunityMyPersonaSchema,
|
|
4496
|
+
error: HostApiErrorSchema
|
|
4497
|
+
}),
|
|
3969
4498
|
testMcpServer: defineContract({
|
|
3970
4499
|
timeoutMs: 3e4,
|
|
3971
4500
|
method: "POST",
|
|
@@ -4367,8 +4896,18 @@ const HostApiContracts = {
|
|
|
4367
4896
|
method: "POST",
|
|
4368
4897
|
path: "/api/extensions/:extensionId/revisions/:revisionId/call",
|
|
4369
4898
|
params: extensionRevisionParam,
|
|
4899
|
+
/**
|
|
4900
|
+
* A panel's call to its extension's host instance. The Host checks the anchor (the agent has the extension
|
|
4901
|
+
* enabled; the channel or connection exists) and hands the extension the resolved caller.
|
|
4902
|
+
*/
|
|
4370
4903
|
request: z.object({
|
|
4371
|
-
|
|
4904
|
+
/** Absent: the call comes from the extension itself, like a page call. */
|
|
4905
|
+
anchor: z.object({
|
|
4906
|
+
kind: ExtensionPanelAnchorSchema,
|
|
4907
|
+
id: NonEmptyStringSchema
|
|
4908
|
+
}).strict().optional(),
|
|
4909
|
+
/** The agent the panel is shown for; must be the responding agent of an anchored channel. */
|
|
4910
|
+
agentId: AgentIdSchema.optional(),
|
|
4372
4911
|
method: NonEmptyStringSchema,
|
|
4373
4912
|
input: JsonValueSchema.optional()
|
|
4374
4913
|
}).strict(),
|
|
@@ -4405,16 +4944,26 @@ const HostApiContracts = {
|
|
|
4405
4944
|
params: agentExtensionParam,
|
|
4406
4945
|
request: z.object({
|
|
4407
4946
|
revisionId: ExtensionRevisionIdSchema,
|
|
4408
|
-
|
|
4947
|
+
/** Approval of the agent-layer capabilities. */
|
|
4948
|
+
permissionApproval: PermissionApprovalSchema.optional(),
|
|
4949
|
+
/** Approval of the host layer when enabling also installs or switches the extension on this machine. */
|
|
4950
|
+
hostPermissionApproval: PermissionApprovalSchema.optional()
|
|
4409
4951
|
}).strict(),
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4952
|
+
/**
|
|
4953
|
+
* The committed Activation, or — while the agent is still replying — `pending` with the accepted request; it then
|
|
4954
|
+
* takes effect at the agent's next safe gap and its progress appears in the snapshot's `activationTransitions`.
|
|
4955
|
+
*/
|
|
4956
|
+
response: z.object({
|
|
4957
|
+
activation: z.object({
|
|
4958
|
+
agentId: AgentIdSchema,
|
|
4959
|
+
extensionId: ExtensionIdSchema,
|
|
4960
|
+
extensionRevisionId: ExtensionRevisionIdSchema,
|
|
4961
|
+
config: JsonValueSchema,
|
|
4962
|
+
configuredSecrets: z.array(z.string()).optional(),
|
|
4963
|
+
activatedAt: z.number().int().safe().nonnegative()
|
|
4964
|
+
}).strict().optional(),
|
|
4965
|
+
pending: ExtensionActivationTransitionSchema.optional()
|
|
4966
|
+
}).strict().refine((value) => value.activation === void 0 !== (value.pending === void 0), "启用结果必须二选一。"),
|
|
4418
4967
|
error: HostApiErrorSchema
|
|
4419
4968
|
}),
|
|
4420
4969
|
deactivateExtension: defineContract({
|
|
@@ -4423,7 +4972,11 @@ const HostApiContracts = {
|
|
|
4423
4972
|
path: "/api/agents/:agentId/extensions/:extensionId/activation",
|
|
4424
4973
|
params: agentExtensionParam,
|
|
4425
4974
|
request: NoRequestBodySchema,
|
|
4426
|
-
|
|
4975
|
+
/** `pending` is present when the agent is still replying; the Activation is removed at its next safe gap. */
|
|
4976
|
+
response: z.object({
|
|
4977
|
+
disabled: z.literal(true),
|
|
4978
|
+
pending: ExtensionActivationTransitionSchema.optional()
|
|
4979
|
+
}).strict(),
|
|
4427
4980
|
error: HostApiErrorSchema
|
|
4428
4981
|
}),
|
|
4429
4982
|
updateExtensionActivationConfig: defineContract({
|
|
@@ -4448,8 +5001,15 @@ const HostApiContracts = {
|
|
|
4448
5001
|
method: "PUT",
|
|
4449
5002
|
path: "/api/extensions/:extensionId/installation/config",
|
|
4450
5003
|
params: extensionParam,
|
|
4451
|
-
request: z.object({
|
|
4452
|
-
|
|
5004
|
+
request: z.object({
|
|
5005
|
+
config: JsonValueSchema,
|
|
5006
|
+
/** Write-only credential drafts keyed by secret field; an absent or empty draft keeps the stored one. */
|
|
5007
|
+
secrets: z.record(z.string(), z.string().max(8192)).optional()
|
|
5008
|
+
}).strict(),
|
|
5009
|
+
response: z.object({
|
|
5010
|
+
config: JsonValueSchema,
|
|
5011
|
+
configuredSecrets: z.array(z.string()).optional()
|
|
5012
|
+
}).strict(),
|
|
4453
5013
|
error: HostApiErrorSchema
|
|
4454
5014
|
}),
|
|
4455
5015
|
installHostExtension: defineContract({
|
|
@@ -4460,7 +5020,10 @@ const HostApiContracts = {
|
|
|
4460
5020
|
params: extensionParam,
|
|
4461
5021
|
request: z.object({
|
|
4462
5022
|
revisionId: ExtensionRevisionIdSchema,
|
|
4463
|
-
|
|
5023
|
+
/** Approval of the host layer (browser permissions and `permissions.host`). */
|
|
5024
|
+
permissionApproval: PermissionApprovalSchema.optional(),
|
|
5025
|
+
/** Approval of expanded agent-layer capabilities for the agents that move to this Revision. */
|
|
5026
|
+
agentPermissionApproval: PermissionApprovalSchema.optional()
|
|
4464
5027
|
}).strict(),
|
|
4465
5028
|
response: z.object({ installation: z.object({
|
|
4466
5029
|
extensionId: ExtensionIdSchema,
|
|
@@ -4689,6 +5252,6 @@ function buildHostApiPath(name, input) {
|
|
|
4689
5252
|
return buildValidatedHostApiPath(HostApiContracts[name], input);
|
|
4690
5253
|
}
|
|
4691
5254
|
//#endregion
|
|
4692
|
-
export { ACTIVITY_MAX_BUCKETS, ACTIVITY_MAX_WINDOW_MS, ACTIVITY_MIN_BUCKET_MS,
|
|
5255
|
+
export { ACTIVITY_MAX_BUCKETS, ACTIVITY_MAX_WINDOW_MS, ACTIVITY_MIN_BUCKET_MS, ActivityQuerySchema, AdapterActivityKeySchema, AdmissionIdSchema, AgentAppearanceSchema, AgentIdSchema, AgentRevisionChangedFieldSchema, AgentRevisionHistorySchema, AgentRevisionIdSchema, AssetIdSchema, AttentionItemSchema, AttentionListSchema, AuthoringAttemptIdSchema, AuthoringTaskIdSchema, CHANNEL_UNREAD_COUNT_CAP, COMMUNITY_EXTENSION_SORTS, COMMUNITY_LISTING_LIMITS, COMMUNITY_OFFICIAL_HANDLE, COMMUNITY_PERSONA_AVATAR_MAX_BYTES, COMMUNITY_PERSONA_AVATAR_TYPES, COMMUNITY_PERSONA_MAX_LENGTH, COMMUNITY_RATING_BADGES, COMMUNITY_RATING_BADGE_LIMIT, COMMUNITY_RATING_DIMENSIONS, COMMUNITY_RATING_DIMENSION_LABELS, COMMUNITY_REVIEWER_NAME, COMMUNITY_REVIEW_DIMENSION_LABELS, COMMUNITY_REVIEW_STATUSES, CONFIG_SCHEMA_MAX_BYTES, ChannelActivitySeriesSchema, ChannelActivitySummarySchema, ChannelEventIdSchema, ChannelFactSseDataSchema, ChannelFactSseItemSchema, ChannelIdSchema, ChannelMemberIdSchema, ChannelPendingContextSchema, ChannelPromptViewSchema, ChannelRuntimeCacheSampleSchema, ChannelRuntimeCacheSchema, ChannelRuntimeContextSchema, ChannelRuntimeInputSchema, ChannelRuntimeOccupancySchema, ChannelRuntimePerformanceSampleSchema, ChannelRuntimePerformanceSchema, ChannelRuntimePhaseSchema, ChannelRuntimeProjectionSchema, ChannelRuntimeSseDataSchema, ChannelRuntimeStepSchema, ChannelRuntimeToolSchema, ChannelRuntimeTurnSchema, ChannelRuntimeUsageSchema, ClientNotificationFeedResponseSchema, ClientNotificationSchema, CommunityAccountSchema, CommunityEndpointSchema, CommunityEnvironmentSchema, CommunityExtensionDetailSchema, CommunityExtensionSortSchema, CommunityExtensionSummarySchema, CommunityInstalledItemSchema, CommunityInstalledSchema, CommunityListingInputSchema, CommunityMyExtensionSchema, CommunityMyPersonaSchema, CommunityMyPersonasSchema, CommunityPermissionItemSchema, CommunityPersonaDetailSchema, CommunityPersonaIdSchema, CommunityPersonaReviewStatusSchema, CommunityPersonaRevisionIdSchema, CommunityPersonaSummarySchema, CommunityRatingSchema, CommunityReleaseIdSchema, CommunityReleaseSchema, CommunityReviewReportSchema, CommunityReviewStatusSchema, CommunitySourceSchema, CommunityStatusSchema, ConfigSchemaDocumentSchema, ConfigSchemaMetaSchema, ConfigSchemaNodeSchema, ConnectionEventIdSchema, ConnectionIdSchema, ConnectionPanelRoleSchema, ConnectionTestResultSchema, DshCredentialRefSchema, DshCredentialViewSchema, DshCredentialsChangedSseDataSchema, DshNxtHostUiSchema, DshPluginCatalogEntrySchema, DshPluginEntryIdSchema, DshPluginOperationSseDataSchema, DshPluginPackageIdSchema, DshSettingsChangedSseDataSchema, DshSettingsMutationRequestSchema, DshSettingsNamespaceSchema, DshSettingsPathOperationSchema, DshSettingsPathSchema, DynamicChangedSseDataSchema, DynamicClientApprovalPolicySchema, EMPTY_CONFIG_SCHEMA, EMPTY_EXTENSION_PERMISSIONS, EMPTY_EXTENSION_UI_CONTRIBUTIONS, EXTENSION_CONTEXT_DYNAMIC_MAX_CHARS, EXTENSION_CONTEXT_STATIC_MAX_CHARS, EXTENSION_DATA_HOOK_PERMISSIONS, EXTENSION_INBOUND_HOOK_MAX_TIMEOUT_MS, EXTENSION_JOB_MAX_RUNTIME, EXTENSION_LLM_MAX_CALLS_PER_TURN, EXTENSION_LLM_MAX_OUTPUT_TOKENS, EXTENSION_PROVIDES, EXTENSION_SDK_LEVEL, EXTENSION_STORAGE_DEFAULT_QUOTA_BYTES, EXTENSION_STORAGE_MAX_QUOTA_BYTES, EXTENSION_STORAGE_SCOPES, EpisodeHandoffIdSchema, EpisodeIdSchema, ExtensionActivationTransitionSchema, ExtensionCapabilitiesSchema, ExtensionConfigDeclarationSchema, ExtensionContextContributionSchema, ExtensionDeclaredJobSchema, ExtensionIdSchema, ExtensionImportInspectionSchema, ExtensionInboundHookCapabilitySchema, ExtensionJobsCapabilitySchema, ExtensionLayeredConfigSchema, ExtensionLlmCapabilitySchema, ExtensionMcpCapabilitySchema, ExtensionMcpServerNameSchema, ExtensionMcpServerSchema, ExtensionMcpValueSchema, ExtensionNetworkCapabilitySchema, ExtensionNetworkDomainSchema, ExtensionPanelAnchorSchema, ExtensionPanelDeclarationSchema, ExtensionPermissionRequirementSchema, ExtensionPermissionsSchema, ExtensionPlatformCapabilitySchema, ExtensionProvideSchema, ExtensionRequiresSchema, ExtensionRevisionIdSchema, ExtensionStorageCapabilitySchema, ExtensionStorageScopeSchema, ExtensionUiContributionsSchema, HOST_PAGE_DEFAULT_RAIL_ORDER, HOST_UI_KIT_COMPONENT_NAMES, HostApiContracts, HostApiErrorSchema, HostConnectionEventSchema, HostIconNameSchema, HostLayerCapabilitiesSchema, HostPageContributionSchema, HostPageIconSchema, HostSnapshotMessageSchema, HostSnapshotSchema, HostSseEventSchema, HostSseStatusDataSchema, HostSyncCursorSchema, HostUiKitComponentNameSchema, HostUiNavigationGroupSchema, HostUiNavigationItemSchema, HostUiNavigationModelSchema, HostUiNetworkOriginSchema, HostUiOwnerSchema, HostUiPageEntrySchema, HostUiPageGeometryEvidenceSchema, HostUiPageInstanceIdSchema, HostUiPagePreferencesSchema, HostUiPermissionDeclarationSchema, HostUiPermissionSchema, HostUpgradeSummarySchema, INSECURE_HTTP_MANAGEMENT_PAIR_PROOF_PREFIX, ImageUnderstandingPolicyApiSchema, InsecureHttpManagementChallengeResponseSchema, InstanceDescriptorSchema, InstanceDescriptorWireSchema, JsonValueSchema, LlmDiscoveredModelSchema, LlmModelInputModalitiesSchema, LlmProviderCredentialSchema, LlmProviderModelSchema, LlmProviderSettingsSchema, LlmProviderTestResultSchema, LlmProviderViewSchema, LogicalMessageIdSchema, MANAGEMENT_PAIR_PROOF_PREFIX, ManagementChallengeResponseSchema, ManagementDeviceEnrollmentRequestSchema, ManagementDeviceEnrollmentResponseSchema, ManagementDeviceIdSchema, ManagementDeviceViewSchema, ManagementSessionRequestSchema, ManagementSessionResponseSchema, McpServerFormSchema, MessagePartSchema, MessagePartsSchema, MessageRendererContributionSchema, NonEmptyMessagePartsSchema, NotificationEventKeySchema, NotificationSettingsViewSchema, OutboundIntentIdSchema, PANEL_ANCHOR_LAYER, PROMPT_DOCUMENT_MAX_PLAIN_TEXT_LENGTH, PROMPT_DOCUMENT_MAX_REFERENCES, PanelContributionSchema, PanelDensitySchema, PhysicalDeliveryIdSchema, PlatformIdentityIdSchema, PlatformUserListResponseSchema, PromptDocumentV1Schema, PromptSegmentSchema, RICH_EXTENSION_MAX_BYTES, RichExtensionSchema, RichKindSchema, RichTargetUrlSchema, RuntimeCompatibilityDiagnosticSchema, ScheduledTaskIdSchema, ScheduledTaskSchema, ServerInstanceIdSchema, TestBarkNotificationRequestSchema, ToolViewContributionSchema, ToolViewDensitySchema, UpdateNotificationSettingsRequestSchema, WorkTreeOrderSchema, activityDurationMs, agentPermissionDeclaration, buildHostApiContractPath, buildHostApiPath, communityPersonaReviewLabel, communityPublisherLabel, communityReviewLabel, configDescription, configFieldKind, configFields, configSchema, configSecretKeys, extensionCapabilitiesExpand, hostLayerAsCapabilities, hostPageRailOrder, hostPermissionDeclaration, insecureHttpManagementPairProofMessage, managementPairProofMessage, mcpSecretFields, messagePartAssetId, messagePartAssetIds, messagePartsSearchText, normalizePromptDocument, parseConfigValue, parseJsonValue, parseMessageParts, promptDocumentFromText, promptDocumentPlainText, richPartContextText, summarizeExtensionCapabilities, validateConfigValue };
|
|
4693
5256
|
|
|
4694
5257
|
//# sourceMappingURL=index.mjs.map
|