@nekro-nxt/contracts 0.2.0 → 0.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.mjs CHANGED
@@ -523,10 +523,33 @@ 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 only when a new optional
527
- * Manifest capability ships; never reuse a level for a different meaning.
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); level 8 adds the asset library, image info, tool result
528
+ * images, the search index and host-layer model calls.
528
529
  */
529
- const EXTENSION_SDK_LEVEL = 6;
530
+ const EXTENSION_SDK_LEVEL = 8;
531
+ /**
532
+ * The first NekroNXT version of each capability level, so users read "needs NekroNXT 0.5.0" rather than a level
533
+ * number. Add the row for a new level in the change that raises EXTENSION_SDK_LEVEL; a test keeps the two in step.
534
+ */
535
+ const EXTENSION_SDK_RELEASES = [
536
+ {
537
+ level: 6,
538
+ version: "0.3.0"
539
+ },
540
+ {
541
+ level: 7,
542
+ version: "0.4.0"
543
+ },
544
+ {
545
+ level: 8,
546
+ version: "0.5.0"
547
+ }
548
+ ];
549
+ /** The oldest NekroNXT version that supports `level`; undefined for a level no release supports yet. */
550
+ const extensionSdkVersion = (level) => EXTENSION_SDK_RELEASES.find((release) => release.level >= level)?.version;
551
+ /** Manifest V7 itself; extensions that use nothing newer need this level. */
552
+ const EXTENSION_SDK_BASE_LEVEL = 7;
530
553
  const ExtensionRequiresSchema = z.object({ sdk: z.number().int().min(1).max(1e3) }).strict();
531
554
  /** `api.example.com` or `*.example.com` (subdomains only); lower-case DNS labels, no scheme, port or path. */
532
555
  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 形式,不含协议、端口和路径。" });
@@ -603,6 +626,45 @@ const ExtensionPlatformCapabilitySchema = z.object({
603
626
  /** Adapters whose raw API passthrough the extension may call. */
604
627
  raw: z.array(AdapterKeySchema).max(8).default([])
605
628
  }).strict();
629
+ const EXTENSION_ASSET_LIBRARY_DEFAULT_QUOTA_BYTES = 2 * 1024 * 1024 * 1024;
630
+ const EXTENSION_ASSET_LIBRARY_MAX_QUOTA_BYTES = 32 * 1024 * 1024 * 1024;
631
+ const ExtensionAssetLibraryCapabilitySchema = z.object({ quotaBytes: z.number().int().min(1024 * 1024).max(EXTENSION_ASSET_LIBRARY_MAX_QUOTA_BYTES).optional() }).strict();
632
+ /**
633
+ * `write` creates Assets in the current channel; `library` keeps Assets in the extension's own library so they can be
634
+ * used in any channel later.
635
+ */
636
+ const ExtensionAssetsCapabilitySchema = z.object({
637
+ write: z.literal(true).optional(),
638
+ library: ExtensionAssetLibraryCapabilitySchema.optional()
639
+ }).strict().refine((value) => value.write !== void 0 || value.library !== void 0, "assets 至少声明 write 或 library。");
640
+ const IndexNameSchema = z.string().trim().regex(/^[a-z][a-z0-9_]{0,31}$/u, "索引、字段和过滤项名称只能使用小写字母、数字和下划线,以字母开头。");
641
+ const EXTENSION_INDEX_MAX_TEXT_FIELDS = 4;
642
+ const EXTENSION_INDEX_MAX_FILTERS = 4;
643
+ /**
644
+ * One searchable collection. Text fields are matched by keywords (and vectors when the Host has them enabled); weights
645
+ * rank keyword matches. Filter fields hold short keyword values, possibly several per document.
646
+ */
647
+ const ExtensionIndexCollectionSchema = z.object({
648
+ name: IndexNameSchema,
649
+ fields: z.array(z.object({
650
+ name: IndexNameSchema,
651
+ weight: z.number().min(.1).max(10).default(1)
652
+ }).strict()).min(1).max(4),
653
+ filters: z.array(IndexNameSchema).max(4).default([])
654
+ }).strict().superRefine((value, context) => {
655
+ const names = [...value.fields.map(({ name }) => name), ...value.filters];
656
+ if (new Set(names).size !== names.length) context.addIssue({
657
+ code: "custom",
658
+ message: "同一索引里的字段与过滤项不能重名。"
659
+ });
660
+ });
661
+ const ExtensionIndexCapabilitySchema = z.object({ collections: z.array(ExtensionIndexCollectionSchema).min(1).max(4).refine((value) => new Set(value.map(({ name }) => name)).size === value.length, "索引名称不能重复。") }).strict();
662
+ const EXTENSION_MODEL_MAX_CALLS_PER_MINUTE = 120;
663
+ /** Calls to a model the user picks from the Host's configured models, with images allowed; host layer only. */
664
+ const ExtensionModelsCapabilitySchema = z.object({
665
+ maxCallsPerMinute: z.number().int().min(1).max(120),
666
+ maxOutputTokens: z.number().int().min(64).max(EXTENSION_LLM_MAX_OUTPUT_TOKENS)
667
+ }).strict();
606
668
  /** A header or environment value: literal text, or the current value of a `meta.role: 'secret'` config field. */
607
669
  const ExtensionMcpValueSchema = z.union([z.string().max(4096), z.object({ secret: z.string().trim().min(1).max(64) }).strict()]);
608
670
  /** Becomes the model-facing tool prefix `mcp__<name>__`. */
@@ -657,13 +719,16 @@ const mcpTarget = (server) => server.transport === "stdio" ? JSON.stringify([
657
719
  server.url
658
720
  ]);
659
721
  /**
660
- * Optional Host capabilities of an agent-scope Revision. Every field is additive to Manifest V6: an absent field
661
- * means the Revision cannot use that capability, exactly as before the field existed.
722
+ * Agent-layer capabilities (`permissions.agent`): what the extension may do inside the agents it is enabled for. An
723
+ * absent field means the extension cannot use that capability.
662
724
  */
663
725
  const ExtensionCapabilitiesSchema = z.object({
664
726
  network: ExtensionNetworkCapabilitySchema.optional(),
665
727
  storage: ExtensionStorageCapabilitySchema.optional(),
666
- assets: z.object({ write: z.literal(true) }).strict().optional(),
728
+ assets: ExtensionAssetsCapabilitySchema.optional(),
729
+ index: ExtensionIndexCapabilitySchema.optional(),
730
+ /** Host layer only; the agent layer uses `llm`, which runs on the agent's own model. */
731
+ models: ExtensionModelsCapabilitySchema.optional(),
667
732
  history: z.object({ read: z.literal(true) }).strict().optional(),
668
733
  inboundHook: ExtensionInboundHookCapabilitySchema.optional(),
669
734
  jobs: ExtensionJobsCapabilitySchema.optional(),
@@ -672,6 +737,30 @@ const ExtensionCapabilitiesSchema = z.object({
672
737
  mcp: ExtensionMcpCapabilitySchema.optional(),
673
738
  context: z.array(ExtensionContextContributionSchema).max(8).refine((value) => new Set(value.map(({ name }) => name)).size === value.length, "上下文名称不能重复。").optional()
674
739
  }).strict();
740
+ /**
741
+ * Host-layer capabilities (`permissions.host`): what the extension's single host instance may do through the `nxt`
742
+ * service its factory receives. Host storage is the extension's `shared` partition.
743
+ */
744
+ const HostLayerCapabilitiesSchema = z.object({
745
+ network: ExtensionNetworkCapabilitySchema.optional(),
746
+ storage: z.object({ quotaBytes: z.number().int().min(1024).max(EXTENSION_STORAGE_MAX_QUOTA_BYTES).optional() }).strict().optional(),
747
+ /** The same library agent attachments use; the host instance lists and imports into it. */
748
+ assets: z.object({ library: ExtensionAssetLibraryCapabilitySchema }).strict().optional(),
749
+ /** The same collections agent attachments declare; pages search and maintain them. */
750
+ index: ExtensionIndexCapabilitySchema.optional(),
751
+ models: ExtensionModelsCapabilitySchema.optional()
752
+ }).strict();
753
+ /** Host-layer capabilities in the agent-capability shape, so digests, expansion and summaries share one implementation. */
754
+ const hostLayerAsCapabilities = (host) => host === void 0 || Object.keys(host).length === 0 ? void 0 : {
755
+ ...host.network === void 0 ? {} : { network: host.network },
756
+ ...host.storage === void 0 ? {} : { storage: {
757
+ scopes: ["shared"],
758
+ ...host.storage.quotaBytes === void 0 ? {} : { quotaBytes: host.storage.quotaBytes }
759
+ } },
760
+ ...host.assets === void 0 ? {} : { assets: { library: host.assets.library } },
761
+ ...host.index === void 0 ? {} : { index: host.index },
762
+ ...host.models === void 0 ? {} : { models: host.models }
763
+ };
675
764
  const NETWORK_MODE_RANK = {
676
765
  domains: 0,
677
766
  config: 1,
@@ -694,7 +783,9 @@ const extensionCapabilitiesExpand = (previous, next) => {
694
783
  if (next === void 0) return false;
695
784
  if (networkExpands(previous?.network, next.network)) return true;
696
785
  if (next.storage?.scopes.some((scope) => !(previous?.storage?.scopes ?? []).includes(scope))) return true;
697
- if (next.assets !== void 0 && previous?.assets === void 0) return true;
786
+ if (next.assets?.write !== void 0 && previous?.assets?.write === void 0) return true;
787
+ if (next.assets?.library !== void 0 && previous?.assets?.library === void 0) return true;
788
+ if (next.models !== void 0 && (previous?.models === void 0 || next.models.maxCallsPerMinute > previous.models.maxCallsPerMinute || next.models.maxOutputTokens > previous.models.maxOutputTokens)) return true;
698
789
  if (next.history !== void 0 && previous?.history === void 0) return true;
699
790
  const platformKey = ({ adapter, action }) => `${adapter}:${action}`;
700
791
  const previousActions = new Set((previous?.platform?.actions ?? []).map(platformKey));
@@ -709,8 +800,12 @@ const extensionCapabilitiesExpand = (previous, next) => {
709
800
  if (next.llm !== void 0 && (previous?.llm === void 0 || next.llm.maxCallsPerTurn > previous.llm.maxCallsPerTurn || next.llm.maxOutputTokens > previous.llm.maxOutputTokens)) return true;
710
801
  return false;
711
802
  };
712
- /** User-facing summary of declared capabilities, in a stable order, for approval and inspection pages. */
713
- const summarizeExtensionCapabilities = (capabilities) => {
803
+ const formatLibraryQuota = (bytes) => bytes >= 1024 * 1024 * 1024 ? `${+(bytes / 1024 / 1024 / 1024).toFixed(1)} GB` : `${Math.round(bytes / 1024 / 1024)} MB`;
804
+ /**
805
+ * User-facing summary of declared capabilities, in a stable order, for approval and inspection pages. `layer: 'host'`
806
+ * phrases host-layer capabilities (passed through {@link hostLayerAsCapabilities}) for the host instance.
807
+ */
808
+ const summarizeExtensionCapabilities = (capabilities, options = {}) => {
714
809
  if (capabilities === void 0) return [];
715
810
  const items = [];
716
811
  const network = capabilities.network;
@@ -724,7 +819,7 @@ const summarizeExtensionCapabilities = (capabilities) => {
724
819
  key: "network",
725
820
  risk: "normal",
726
821
  label: "访问你在配置中填写的地址",
727
- detail: network.fields.join("、")
822
+ detail: network.fields.map((field) => options.fieldTitle?.(field) ?? field).join("、")
728
823
  });
729
824
  else if (network?.mode === "unrestricted") items.push({
730
825
  key: "network",
@@ -732,7 +827,12 @@ const summarizeExtensionCapabilities = (capabilities) => {
732
827
  label: "访问任意公网地址",
733
828
  detail: network.purpose
734
829
  });
735
- if (capabilities.storage !== void 0) {
830
+ if (capabilities.storage !== void 0 && options.layer === "host") items.push({
831
+ key: "storage",
832
+ risk: "normal",
833
+ label: "在本机保存扩展数据,页面与启用它的智能体共用"
834
+ });
835
+ else if (capabilities.storage !== void 0) {
736
836
  const shared = capabilities.storage.scopes.includes("shared");
737
837
  items.push({
738
838
  key: "storage",
@@ -740,11 +840,29 @@ const summarizeExtensionCapabilities = (capabilities) => {
740
840
  label: shared ? "保存数据,并在启用它的智能体之间共享" : "为这个智能体保存数据"
741
841
  });
742
842
  }
743
- if (capabilities.assets !== void 0) items.push({
843
+ if (capabilities.assets?.write !== void 0) items.push({
744
844
  key: "assets",
745
845
  risk: "normal",
746
846
  label: "在当前频道生成图片或文件"
747
847
  });
848
+ if (capabilities.assets?.library !== void 0) items.push({
849
+ key: "assets.library",
850
+ risk: "sensitive",
851
+ label: "把频道里的图片收进扩展资源库,之后可以在其他频道使用",
852
+ detail: `最多 ${formatLibraryQuota(capabilities.assets.library.quotaBytes ?? 2147483648)}`
853
+ });
854
+ if (capabilities.index !== void 0) items.push({
855
+ key: "index",
856
+ risk: "normal",
857
+ label: "建立可搜索的索引",
858
+ detail: capabilities.index.collections.map(({ name }) => name).join("、")
859
+ });
860
+ if (capabilities.models !== void 0) items.push({
861
+ key: "models",
862
+ risk: "sensitive",
863
+ label: "使用本机已配置的模型,可以发送图片",
864
+ detail: `每分钟最多 ${capabilities.models.maxCallsPerMinute} 次,计入所选模型的用量`
865
+ });
748
866
  if (capabilities.history !== void 0) items.push({
749
867
  key: "history",
750
868
  risk: "normal",
@@ -904,8 +1022,14 @@ const HostPageContributionSchema = z.object({
904
1022
  description: z.string().trim().max(120).optional(),
905
1023
  icon: HostPageIconSchema,
906
1024
  objectPane: z.enum(["navigation", "hidden"]),
907
- startPath: z.string().trim().regex(/^(?:[a-z0-9][a-z0-9/_-]*)?$/u)
1025
+ startPath: z.string().trim().regex(/^(?:[a-z0-9][a-z0-9/_-]*)?$/u),
1026
+ /** Registers a navigation rail entry for this page; at most one page of an extension may declare it. */
1027
+ rail: z.object({ order: z.number().int().min(0).max(999).optional() }).strict().optional()
908
1028
  }).strict();
1029
+ /** Rail position of a page that registers a rail entry without an explicit order. */
1030
+ const HOST_PAGE_DEFAULT_RAIL_ORDER = 100;
1031
+ /** The stored rail position of a page; `null` when the page has no rail entry. */
1032
+ const hostPageRailOrder = (page) => page.rail === void 0 ? null : page.rail.order ?? 100;
909
1033
  const HostUiNavigationItemSchema = z.object({
910
1034
  id: z.string().trim().min(1).max(80),
911
1035
  label: z.string().trim().min(1).max(80),
@@ -949,12 +1073,7 @@ const HostUiNetworkOriginSchema = z.string().url().transform((value, context) =>
949
1073
  }
950
1074
  return url.origin;
951
1075
  });
952
- const HostUiPermissionDeclarationSchema = z.object({
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) => {
1076
+ const checkBrowserPermissions = (value, context) => {
958
1077
  if (new Set(value.permissions).size !== value.permissions.length) context.addIssue({
959
1078
  code: "custom",
960
1079
  path: ["permissions"],
@@ -970,6 +1089,58 @@ const HostUiPermissionDeclarationSchema = z.object({
970
1089
  path: ["networkOrigins"],
971
1090
  message: "Host UI network origins require network.request."
972
1091
  });
1092
+ };
1093
+ /**
1094
+ * One approval: browser-side permissions plus the capabilities of one layer. Grants, digests and the approval page
1095
+ * use this shape for both the host approval and each agent approval.
1096
+ */
1097
+ const HostUiPermissionDeclarationSchema = z.object({
1098
+ permissions: z.array(HostUiPermissionSchema).max(HostUiPermissionSchema.options.length),
1099
+ networkOrigins: z.array(HostUiNetworkOriginSchema).max(32).default([]),
1100
+ capabilities: ExtensionCapabilitiesSchema.optional()
1101
+ }).strict().superRefine(checkBrowserPermissions);
1102
+ /**
1103
+ * Manifest V7 `permissions`: browser-side permissions of pages and panels (`host.call`), host-layer capabilities used
1104
+ * by the single host instance, and agent-layer capabilities used inside each enabled agent.
1105
+ */
1106
+ const ExtensionPermissionsSchema = z.object({
1107
+ permissions: z.array(HostUiPermissionSchema).max(HostUiPermissionSchema.options.length).default([]),
1108
+ networkOrigins: z.array(HostUiNetworkOriginSchema).max(32).default([]),
1109
+ host: HostLayerCapabilitiesSchema.optional(),
1110
+ agent: ExtensionCapabilitiesSchema.optional()
1111
+ }).strict().superRefine(checkBrowserPermissions).superRefine((value, context) => {
1112
+ if (value.agent?.models !== void 0) context.addIssue({
1113
+ code: "custom",
1114
+ path: ["agent", "models"],
1115
+ message: "models 只能在 permissions.host 中声明;智能体层使用 llm 调用智能体自己的模型。"
1116
+ });
1117
+ for (const collection of value.agent?.index?.collections ?? []) {
1118
+ const host = value.host?.index?.collections.find(({ name }) => name === collection.name);
1119
+ if (host !== void 0 && JSON.stringify(host) !== JSON.stringify(collection)) context.addIssue({
1120
+ code: "custom",
1121
+ path: ["agent", "index"],
1122
+ message: `索引 ${collection.name} 在 permissions.host 与 permissions.agent 中的定义不一致。`
1123
+ });
1124
+ }
1125
+ });
1126
+ const EMPTY_EXTENSION_PERMISSIONS = {
1127
+ permissions: [],
1128
+ networkOrigins: []
1129
+ };
1130
+ /** What installing the extension on this machine asks the user to approve. */
1131
+ const hostPermissionDeclaration = (permissions) => {
1132
+ const capabilities = hostLayerAsCapabilities(permissions.host);
1133
+ return {
1134
+ permissions: [...permissions.permissions],
1135
+ networkOrigins: [...permissions.networkOrigins],
1136
+ ...capabilities === void 0 ? {} : { capabilities }
1137
+ };
1138
+ };
1139
+ /** What enabling the extension for one agent asks the user to approve. */
1140
+ const agentPermissionDeclaration = (permissions) => ({
1141
+ permissions: [],
1142
+ networkOrigins: [],
1143
+ ...permissions.agent === void 0 || Object.keys(permissions.agent).length === 0 ? {} : { capabilities: permissions.agent }
973
1144
  });
974
1145
  const HostUiOwnerSchema = z.discriminatedUnion("kind", [z.object({
975
1146
  kind: z.literal("extension"),
@@ -991,6 +1162,8 @@ const HostUiPageEntrySchema = z.object({
991
1162
  startPath: z.string(),
992
1163
  visible: z.boolean(),
993
1164
  sortOrder: z.number().int().nonnegative(),
1165
+ /** Present when the page registered a navigation rail entry; lower orders come first. */
1166
+ rail: z.object({ order: z.number().int().min(0).max(999) }).strict().optional(),
994
1167
  routeBase: z.string().regex(/^\/apps\/hup_[0-9A-Za-z]+$/u),
995
1168
  client: z.object({
996
1169
  moduleUrl: z.string().startsWith("/"),
@@ -1035,12 +1208,17 @@ const ExtensionPanelAnchorSchema = z.enum([
1035
1208
  "extension",
1036
1209
  "connection"
1037
1210
  ]);
1038
- const AGENT_PANEL_ANCHORS = [
1039
- "agent",
1040
- "channel",
1041
- "extension"
1042
- ];
1043
- const ADAPTER_PANEL_ANCHORS = ["connection", "channel"];
1211
+ /**
1212
+ * Which layer a panel belongs to. Agent and channel panels follow the agents the extension is enabled for (a channel
1213
+ * panel also shows on channels of the extension's own adapter); extension and connection panels belong to the host
1214
+ * instance.
1215
+ */
1216
+ const PANEL_ANCHOR_LAYER = {
1217
+ agent: "agent",
1218
+ channel: "agent",
1219
+ extension: "host",
1220
+ connection: "host"
1221
+ };
1044
1222
  const PanelDensitySchema = z.enum(["compact", "full"]);
1045
1223
  const ConnectionPanelRoleSchema = z.enum([
1046
1224
  "setup",
@@ -1103,8 +1281,21 @@ const MessageRendererContributionSchema = z.object({
1103
1281
  kind: z.literal("message-renderer"),
1104
1282
  richKind: RichKindSchema
1105
1283
  }).strict();
1106
- /** Optional configuration surface shared by every extension scope. */
1284
+ /** What an extension provides, derived from its Manifest; for listing and filtering, never a lifecycle switch. */
1285
+ const EXTENSION_PROVIDES = [
1286
+ "agent",
1287
+ "page",
1288
+ "adapter",
1289
+ "mcp"
1290
+ ];
1291
+ const ExtensionProvideSchema = z.enum(EXTENSION_PROVIDES);
1292
+ /** One configuration form: a serialized Schemastery document. */
1107
1293
  const ExtensionConfigDeclarationSchema = z.object({ schema: ConfigSchemaDocumentSchema }).strict();
1294
+ /** Manifest V7 `config`: the host instance's configuration and each enabled agent's configuration. */
1295
+ const ExtensionLayeredConfigSchema = z.object({
1296
+ host: ExtensionConfigDeclarationSchema.optional(),
1297
+ agent: ExtensionConfigDeclarationSchema.optional()
1298
+ }).strict();
1108
1299
  /** Product projection of what one Revision contributes to the shell. */
1109
1300
  const ExtensionUiContributionsSchema = z.object({
1110
1301
  panels: z.array(PanelContributionSchema).max(16),
@@ -1123,6 +1314,26 @@ const EXTENSION_DATA_HOOK_PERMISSIONS = {
1123
1314
  useConnection: "connections.read",
1124
1315
  useChannelRuntime: "runtime.read"
1125
1316
  };
1317
+ /**
1318
+ * The capability level a set of permissions needs: Manifest V7 itself, or the level that introduced the newest
1319
+ * capability it declares. Packaging and import compare it with `requires.sdk`, so an extension cannot claim a level
1320
+ * too old for what it uses.
1321
+ */
1322
+ const requiredExtensionSdkLevel = (permissions) => {
1323
+ const level8 = [
1324
+ permissions?.host?.assets === void 0 ? void 0 : "扩展资源库",
1325
+ permissions?.agent?.assets?.library === void 0 ? void 0 : "扩展资源库",
1326
+ permissions?.host?.index === void 0 && permissions?.agent?.index === void 0 ? void 0 : "检索索引",
1327
+ permissions?.host?.models === void 0 ? void 0 : "本机层模型调用"
1328
+ ].filter((name) => name !== void 0);
1329
+ return level8.length > 0 ? {
1330
+ level: 8,
1331
+ capabilities: [...new Set(level8)]
1332
+ } : {
1333
+ level: 7,
1334
+ capabilities: []
1335
+ };
1336
+ };
1126
1337
  //#endregion
1127
1338
  //#region src/runtime-compatibility.ts
1128
1339
  const RuntimeCompatibilityDiagnosticSchema = z.object({
@@ -1285,18 +1496,112 @@ const COMMUNITY_REVIEW_STATUSES = [
1285
1496
  "incomplete"
1286
1497
  ];
1287
1498
  const CommunityReviewStatusSchema = z.enum(COMMUNITY_REVIEW_STATUSES);
1288
- const CommunityGradeSchema = z.enum([
1289
- "A",
1290
- "B",
1291
- "C",
1292
- "D"
1499
+ /** 社区评级的六个维度(审查标准 v1),从正上方顺时针排列成六边形。 */
1500
+ const COMMUNITY_RATING_DIMENSIONS = [
1501
+ "security",
1502
+ "openness",
1503
+ "reliability",
1504
+ "lightweight",
1505
+ "usability",
1506
+ "craft"
1507
+ ];
1508
+ const COMMUNITY_RATING_DIMENSION_LABELS = {
1509
+ security: "安全",
1510
+ openness: "开放",
1511
+ reliability: "稳定",
1512
+ lightweight: "轻量",
1513
+ usability: "易用",
1514
+ craft: "工艺"
1515
+ };
1516
+ /** 社区的审查员,评级与审查记录以她署名。 */
1517
+ const COMMUNITY_REVIEWER_NAME = "小澄";
1518
+ /** 社区判定的达成标签;不认识的标签不显示。扩展页面最多显示 {@link COMMUNITY_RATING_BADGE_LIMIT} 个。 */
1519
+ const COMMUNITY_RATING_BADGES = {
1520
+ "zero-permission": {
1521
+ label: "零权限",
1522
+ description: "没有申请任何权限。"
1523
+ },
1524
+ "least-privilege": {
1525
+ label: "最小权限",
1526
+ description: "声明的每项能力都用得上,安全满星。"
1527
+ },
1528
+ "no-network": {
1529
+ label: "不联网",
1530
+ description: "不访问任何网络。"
1531
+ },
1532
+ "scoped-network": {
1533
+ label: "限定地址联网",
1534
+ description: "只访问指定域名或用户在配置中填写的地址。"
1535
+ },
1536
+ "managed-secrets": {
1537
+ label: "凭据托管",
1538
+ description: "凭据都是配置中的凭据字段,经宿主读取,没有写进源码。"
1539
+ },
1540
+ "readable-source": {
1541
+ label: "源码可读",
1542
+ description: "没有混淆、压缩或内嵌大段编码内容。"
1543
+ },
1544
+ "open-source": {
1545
+ label: "开源",
1546
+ description: "填写了公开的源码仓库。"
1547
+ },
1548
+ "readable-errors": {
1549
+ label: "错误可读",
1550
+ description: "失败时都返回给用户看的说明,稳定满星。"
1551
+ },
1552
+ "stable-context": {
1553
+ label: "上下文稳定",
1554
+ description: "不占上下文,或注入的上下文稳定、不破坏提示缓存。"
1555
+ },
1556
+ "complete-docs": {
1557
+ label: "说明完整",
1558
+ description: "有图标和介绍,易用至少四星。"
1559
+ }
1560
+ };
1561
+ const COMMUNITY_RATING_BADGE_LIMIT = 4;
1562
+ /** 一次发布的评级:六维星级、综合评分(各维度平均,保留一位小数)与达成标签。 */
1563
+ const CommunityRatingSchema = z.object({
1564
+ standard: z.string().max(20),
1565
+ score: z.number().min(1).max(5),
1566
+ dimensions: z.array(z.object({
1567
+ key: z.string().max(40),
1568
+ stars: z.number().int().min(1).max(5),
1569
+ headline: z.string().max(200),
1570
+ cap: z.string().max(200).optional()
1571
+ })).max(16),
1572
+ badges: z.array(z.string().max(40)).max(32)
1573
+ });
1574
+ /** 市场的排序方式。 */
1575
+ const COMMUNITY_EXTENSION_SORTS = [
1576
+ {
1577
+ key: "updated",
1578
+ label: "最近更新"
1579
+ },
1580
+ {
1581
+ key: "score",
1582
+ label: "综合评分"
1583
+ },
1584
+ {
1585
+ key: "downloads",
1586
+ label: "下载最多"
1587
+ },
1588
+ {
1589
+ key: "newest",
1590
+ label: "最新上架"
1591
+ }
1592
+ ];
1593
+ const CommunityExtensionSortSchema = z.enum([
1594
+ "updated",
1595
+ "score",
1596
+ "downloads",
1597
+ "newest"
1293
1598
  ]);
1294
1599
  const CommunityReleaseIdSchema = z.string().regex(/^rel_[0-9A-Za-z]+$/u);
1295
1600
  const CommunityAccountSchema = z.object({
1296
1601
  handle: z.string().min(1).max(80),
1297
1602
  displayName: z.string().max(200),
1298
1603
  avatarUrl: z.string().url().nullable()
1299
- }).strict();
1604
+ });
1300
1605
  const CommunityEnvironmentSchema = z.enum([
1301
1606
  "production",
1302
1607
  "staging",
@@ -1310,7 +1615,7 @@ const CommunityStatusSchema = z.object({
1310
1615
  signedInAt: z.number().int().nullable(),
1311
1616
  /** 最近一次更新检查发现的可更新扩展数量(只读缓存,不发起网络请求)。 */
1312
1617
  updatesAvailable: z.number().int().nonnegative()
1313
- }).strict();
1618
+ });
1314
1619
  const CommunityPermissionItemSchema = z.object({
1315
1620
  key: z.string().max(120),
1316
1621
  level: z.enum([
@@ -1319,32 +1624,34 @@ const CommunityPermissionItemSchema = z.object({
1319
1624
  "high"
1320
1625
  ]),
1321
1626
  label: z.string().max(200),
1322
- detail: z.string().max(2e3).optional()
1323
- }).strict();
1627
+ detail: z.string().max(2e3).optional(),
1628
+ /** `host`: approved when installed on this machine; `agent`: approved when enabled for an agent. */
1629
+ layer: z.enum(["host", "agent"]).optional()
1630
+ });
1324
1631
  const CommunityReleaseSchema = z.object({
1325
1632
  id: CommunityReleaseIdSchema,
1326
1633
  reviewStatus: CommunityReviewStatusSchema,
1327
- grade: CommunityGradeSchema.nullable(),
1634
+ /** 审查完成后的评级;尚未审查、审查未完成或旧版社区时为 null。 */
1635
+ rating: CommunityRatingSchema.nullable(),
1328
1636
  permissions: z.array(CommunityPermissionItemSchema).max(64),
1329
1637
  packageSize: z.number().int().nonnegative(),
1330
1638
  requiresSdk: z.number().int().positive().nullable(),
1331
1639
  notes: z.string().max(2e3),
1332
1640
  createdAt: z.number().int()
1333
- }).strict();
1641
+ });
1334
1642
  /** 社区为官方扩展保留的发布者标识:官方扩展由多位官方成员维护,对外不显示个人账号。 */
1335
1643
  const COMMUNITY_OFFICIAL_HANDLE = "nekro-nxt";
1336
1644
  /** 发布者的展示文字:官方扩展显示「NekroNXT 官方」,其余显示 @账号。 */
1337
1645
  const communityPublisherLabel = (handle) => handle === "nekro-nxt" ? "NekroNXT 官方" : `@${handle}`;
1338
1646
  const CommunityExtensionSummarySchema = z.object({
1339
1647
  id: ExtensionIdSchema,
1340
- scope: z.enum([
1341
- "agent",
1342
- "host-adapter",
1343
- "host-ui"
1344
- ]),
1648
+ /** What the extension provides, derived from its Manifest; unknown future labels are dropped. */
1649
+ provides: z.array(z.string().max(32)).max(8),
1345
1650
  displayName: z.string().max(200),
1346
1651
  summary: z.string().max(1e3),
1347
1652
  tags: z.array(z.string().max(40)).max(16),
1653
+ /** 最新公开发布包内的扩展图标(社区的绝对地址);没有图标或旧版社区时为 null。 */
1654
+ iconUrl: z.string().url().nullable(),
1348
1655
  /** 由社区后台认定的官方扩展;此时发布者是社区保留的官方主页(`COMMUNITY_OFFICIAL_HANDLE`)。 */
1349
1656
  official: z.boolean(),
1350
1657
  publisher: CommunityAccountSchema,
@@ -1352,20 +1659,46 @@ const CommunityExtensionSummarySchema = z.object({
1352
1659
  downloads: z.number().int().nonnegative(),
1353
1660
  updatedAt: z.number().int(),
1354
1661
  pageUrl: z.string().url()
1355
- }).strict();
1662
+ });
1356
1663
  const CommunityExtensionDetailSchema = CommunityExtensionSummarySchema.extend({
1357
1664
  description: z.string().max(2e4),
1358
1665
  sourceUrl: z.string().url().nullable(),
1666
+ /** 公开的审查记录:评级、总评、各维度说明,以及发现与自动检查的标题。 */
1359
1667
  review: z.object({
1360
1668
  status: CommunityReviewStatusSchema,
1361
- grade: CommunityGradeSchema.nullable(),
1669
+ rating: CommunityRatingSchema.nullable(),
1362
1670
  summary: z.string().max(2e3).nullable(),
1363
- highlights: z.array(z.object({
1671
+ dimensions: z.array(z.object({
1672
+ key: z.string().max(40),
1673
+ notes: z.string().max(2e3)
1674
+ })).max(16),
1675
+ findings: z.array(z.object({
1676
+ dimension: z.string().max(40),
1364
1677
  severity: z.string().max(20),
1365
1678
  title: z.string().max(200)
1366
- }).strict()).max(16)
1367
- }).strict().nullable()
1368
- }).strict();
1679
+ })).max(64),
1680
+ checks: z.array(z.object({
1681
+ severity: z.string().max(20),
1682
+ title: z.string().max(200)
1683
+ })).max(64),
1684
+ reviewedAt: z.number().int().nullable()
1685
+ }).nullable()
1686
+ });
1687
+ /**
1688
+ * 发布时随包提交的条目信息(作者自己写的介绍)。首次发布用于建条目;之后提供了哪项就覆盖哪项,未提供的保持不变。
1689
+ */
1690
+ const COMMUNITY_LISTING_LIMITS = {
1691
+ summary: 160,
1692
+ description: 2e4,
1693
+ tags: 8,
1694
+ tag: 40
1695
+ };
1696
+ const CommunityListingInputSchema = z.object({
1697
+ summary: z.string().trim().max(COMMUNITY_LISTING_LIMITS.summary).optional(),
1698
+ description: z.string().max(COMMUNITY_LISTING_LIMITS.description).optional(),
1699
+ tags: z.array(z.string().trim().min(1).max(COMMUNITY_LISTING_LIMITS.tag)).max(COMMUNITY_LISTING_LIMITS.tags).optional(),
1700
+ sourceUrl: z.string().trim().url().refine((value) => /^https?:\/\//iu.test(value), "源码地址必须是 http(s) 链接。").optional()
1701
+ });
1369
1702
  const CommunityEndpointSchema = z.object({
1370
1703
  url: z.string().url(),
1371
1704
  source: z.enum([
@@ -1377,14 +1710,14 @@ const CommunityEndpointSchema = z.object({
1377
1710
  environmentUrl: z.string().url().nullable(),
1378
1711
  /** 当前地址是未加密的非本机地址。 */
1379
1712
  insecure: z.boolean()
1380
- }).strict();
1713
+ });
1381
1714
  const CommunitySourceSchema = z.object({
1382
1715
  kind: z.literal("community"),
1383
1716
  communityUrl: z.string().url(),
1384
1717
  releaseId: CommunityReleaseIdSchema,
1385
1718
  publisherHandle: z.string().min(1).max(80),
1386
1719
  installedAt: z.number().int().nonnegative()
1387
- }).strict();
1720
+ });
1388
1721
  const CommunityInstalledItemSchema = z.object({
1389
1722
  extensionId: ExtensionIdSchema,
1390
1723
  displayName: z.string(),
@@ -1400,39 +1733,26 @@ const CommunityInstalledItemSchema = z.object({
1400
1733
  latest: CommunityReleaseSchema.nullable(),
1401
1734
  updateAvailable: z.boolean(),
1402
1735
  addedPermissions: z.array(CommunityPermissionItemSchema)
1403
- }).strict();
1736
+ });
1404
1737
  const CommunityInstalledSchema = z.object({
1405
1738
  checkedAt: z.number().int().nullable(),
1406
1739
  items: z.array(CommunityInstalledItemSchema)
1407
- }).strict();
1740
+ });
1408
1741
  const CommunityMyExtensionSchema = CommunityExtensionSummarySchema.extend({
1409
- releases: z.array(CommunityReleaseSchema.extend({ withdrawn: z.boolean() }).strict()),
1742
+ releases: z.array(CommunityReleaseSchema.extend({ withdrawn: z.boolean() })),
1410
1743
  delisted: z.boolean(),
1411
1744
  delistedReason: z.string().nullable()
1412
- }).strict();
1413
- const COMMUNITY_REVIEW_DIMENSIONS = [
1414
- "security",
1415
- "transparency",
1416
- "reliability",
1417
- "context_cost",
1418
- "usability",
1419
- "maintainability",
1420
- "compliance"
1421
- ];
1745
+ });
1746
+ /** 审查发现可归属的维度:六个评级维度加合规。 */
1422
1747
  const COMMUNITY_REVIEW_DIMENSION_LABELS = {
1423
- security: "安全",
1424
- transparency: "源码透明",
1425
- reliability: "可靠性",
1426
- context_cost: "上下文与成本",
1427
- usability: "可用性",
1428
- maintainability: "可维护性",
1748
+ ...COMMUNITY_RATING_DIMENSION_LABELS,
1429
1749
  compliance: "合规"
1430
1750
  };
1431
1751
  /** 作者看到的完整审查报告。 */
1432
1752
  const CommunityReviewReportSchema = z.object({
1433
1753
  releaseId: CommunityReleaseIdSchema,
1434
1754
  status: CommunityReviewStatusSchema,
1435
- grade: CommunityGradeSchema.nullable(),
1755
+ rating: CommunityRatingSchema.nullable(),
1436
1756
  deterministic: z.array(z.object({
1437
1757
  severity: z.enum([
1438
1758
  "info",
@@ -1444,18 +1764,24 @@ const CommunityReviewReportSchema = z.object({
1444
1764
  detail: z.string(),
1445
1765
  file: z.string().optional(),
1446
1766
  line: z.number().int().optional()
1447
- }).strict()),
1767
+ })),
1448
1768
  ai: z.object({
1449
1769
  summary: z.string(),
1450
1770
  verdict: z.string(),
1451
- grade: CommunityGradeSchema,
1452
- dimensions: z.array(z.object({
1453
- key: z.enum(COMMUNITY_REVIEW_DIMENSIONS),
1454
- grade: CommunityGradeSchema,
1771
+ compliance: z.object({
1772
+ ok: z.boolean(),
1455
1773
  notes: z.string()
1456
- }).strict()),
1774
+ }).nullable(),
1775
+ dimensions: z.array(z.object({
1776
+ key: z.string(),
1777
+ stars: z.number().int().min(1).max(5),
1778
+ headline: z.string(),
1779
+ notes: z.string(),
1780
+ /** 不满五星时拿下一颗星的修改建议。 */
1781
+ nextStar: z.string().optional()
1782
+ })),
1457
1783
  findings: z.array(z.object({
1458
- dimension: z.enum(COMMUNITY_REVIEW_DIMENSIONS),
1784
+ dimension: z.string(),
1459
1785
  severity: z.enum([
1460
1786
  "info",
1461
1787
  "suggestion",
@@ -1468,9 +1794,9 @@ const CommunityReviewReportSchema = z.object({
1468
1794
  file: z.string().optional(),
1469
1795
  line: z.number().int().optional(),
1470
1796
  suggestion: z.string().optional()
1471
- }).strict()),
1797
+ })),
1472
1798
  exploitability: z.string().optional()
1473
- }).strict().nullable(),
1799
+ }).nullable(),
1474
1800
  model: z.string().nullable(),
1475
1801
  error: z.string().nullable(),
1476
1802
  decisions: z.array(z.object({
@@ -1478,10 +1804,10 @@ const CommunityReviewReportSchema = z.object({
1478
1804
  note: z.string(),
1479
1805
  by: z.string(),
1480
1806
  createdAt: z.number().int()
1481
- }).strict()),
1807
+ })),
1482
1808
  finishedAt: z.number().int().nullable(),
1483
1809
  reportUrl: z.string().url()
1484
- }).strict();
1810
+ });
1485
1811
  /** 安装者看到的审查标签:只描述审查发现,不做「安全」担保。 */
1486
1812
  const communityReviewLabel = (status) => {
1487
1813
  switch (status) {
@@ -1518,6 +1844,91 @@ const communityReviewLabel = (status) => {
1518
1844
  }
1519
1845
  };
1520
1846
  //#endregion
1847
+ //#region src/community-personas.ts
1848
+ /**
1849
+ * 社区人设在本机的投影:名称、头像、简介、作者介绍、标签与人设正文(对应智能体的 `persona`)。不含模型与扩展。
1850
+ * Host 宽松读取社区响应并归一到这些结构;头像改写为本机代理地址,页面不直接跨域读取社区图片。
1851
+ */
1852
+ const CommunityPersonaIdSchema = z.string().regex(/^psn_[0-9A-Za-z]+$/u);
1853
+ const CommunityPersonaRevisionIdSchema = z.string().regex(/^prv_[0-9A-Za-z]+$/u);
1854
+ /** 人设正文上限,与智能体设定一致。 */
1855
+ const COMMUNITY_PERSONA_MAX_LENGTH = 64 * 1024;
1856
+ /** 发布头像上限(社区约定 ≤512 KiB 的 PNG、JPEG 或 WebP)。 */
1857
+ const COMMUNITY_PERSONA_AVATAR_MAX_BYTES = 512 * 1024;
1858
+ const COMMUNITY_PERSONA_AVATAR_TYPES = [
1859
+ "image/png",
1860
+ "image/jpeg",
1861
+ "image/webp"
1862
+ ];
1863
+ const TagsSchema = z.array(z.string().min(1).max(40)).max(16);
1864
+ const CommunityPersonaSummarySchema = z.object({
1865
+ id: CommunityPersonaIdSchema,
1866
+ name: z.string().min(1).max(200),
1867
+ summary: z.string().max(1e3),
1868
+ tags: TagsSchema,
1869
+ /** 本机代理地址 `/api/community/personas/<id>/avatar?v=…`;没有头像时为 null。 */
1870
+ avatarUrl: z.string().startsWith("/api/community/personas/").nullable(),
1871
+ official: z.boolean(),
1872
+ publisher: CommunityAccountSchema,
1873
+ installs: z.number().int().nonnegative(),
1874
+ updatedAt: z.number().int(),
1875
+ pageUrl: z.string().url()
1876
+ });
1877
+ const CommunityPersonaDetailSchema = CommunityPersonaSummarySchema.extend({
1878
+ description: z.string().max(2e4),
1879
+ persona: z.string().max(COMMUNITY_PERSONA_MAX_LENGTH),
1880
+ revision: z.object({
1881
+ id: CommunityPersonaRevisionIdSchema,
1882
+ notes: z.string().max(2e3),
1883
+ createdAt: z.number().int()
1884
+ }),
1885
+ review: z.object({
1886
+ status: z.enum(["approved", "flagged"]),
1887
+ summary: z.string().max(2e3).nullable()
1888
+ }).nullable()
1889
+ });
1890
+ const CommunityPersonaReviewStatusSchema = z.enum([
1891
+ "pending",
1892
+ "approved",
1893
+ "flagged",
1894
+ "rejected"
1895
+ ]);
1896
+ const CommunityMyPersonaSchema = CommunityPersonaSummarySchema.extend({
1897
+ status: z.enum(["listed", "delisted"]),
1898
+ latestRevision: z.object({
1899
+ id: CommunityPersonaRevisionIdSchema,
1900
+ createdAt: z.number().int(),
1901
+ reviewStatus: CommunityPersonaReviewStatusSchema,
1902
+ reviewSummary: z.string().max(2e3).nullable()
1903
+ })
1904
+ });
1905
+ const CommunityMyPersonasSchema = z.object({
1906
+ items: z.array(CommunityMyPersonaSchema),
1907
+ /** 本机智能体最近一次发布到当前社区的人设,用于「更新已发布的人设」。 */
1908
+ agentLinks: z.record(AgentIdSchema, CommunityPersonaIdSchema)
1909
+ });
1910
+ /** 作者看到的审查状态文字。 */
1911
+ const communityPersonaReviewLabel = (status) => {
1912
+ switch (status) {
1913
+ case "approved": return {
1914
+ tone: "ok",
1915
+ label: "已公开"
1916
+ };
1917
+ case "pending": return {
1918
+ tone: "neutral",
1919
+ label: "审查中"
1920
+ };
1921
+ case "flagged": return {
1922
+ tone: "warn",
1923
+ label: "待人工复核"
1924
+ };
1925
+ case "rejected": return {
1926
+ tone: "bad",
1927
+ label: "未通过"
1928
+ };
1929
+ }
1930
+ };
1931
+ //#endregion
1521
1932
  //#region src/host-api.ts
1522
1933
  const EmptyParamsSchema = z.object({}).strict();
1523
1934
  const NoRequestBodySchema = z.undefined();
@@ -1652,6 +2063,24 @@ const AgentModelSchema = z.object({
1652
2063
  model: NonEmptyStringSchema,
1653
2064
  reasoningEffort: NonEmptyStringSchema.optional()
1654
2065
  }).strict();
2066
+ /**
2067
+ * An enable or disable request of one agent extension that has not settled: `waiting` until the agent reaches a safe
2068
+ * gap (its current reply ends), or `failed` with the reason until the next request replaces it.
2069
+ */
2070
+ /** What one approval asks the user to grant and whether the current grant already covers it. */
2071
+ const ExtensionPermissionRequirementSchema = z.object({
2072
+ declaration: HostUiPermissionDeclarationSchema,
2073
+ permissionDigest: z.string().regex(/^[a-f0-9]{64}$/u),
2074
+ approvalRequired: z.boolean()
2075
+ }).strict();
2076
+ const ExtensionActivationTransitionSchema = z.object({
2077
+ agentId: AgentIdSchema,
2078
+ target: z.enum(["enabled", "disabled"]),
2079
+ extensionRevisionId: ExtensionRevisionIdSchema.optional(),
2080
+ state: z.enum(["waiting", "failed"]),
2081
+ message: z.string().optional(),
2082
+ since: z.number().int().safe().nonnegative()
2083
+ }).strict();
1655
2084
  const ImageUnderstandingPolicyApiSchema = z.object({
1656
2085
  history: z.object({
1657
2086
  mode: z.literal("persistent-distinct"),
@@ -1679,7 +2108,11 @@ const AgentCapabilitiesSchema = z.object({
1679
2108
  developmentShell: z.boolean(),
1680
2109
  unrestrictedFileAccess: z.boolean(),
1681
2110
  /** Absent in older clients means on. */
1682
- scheduledTasks: z.boolean().default(true)
2111
+ scheduledTasks: z.boolean().default(true),
2112
+ /** Tools are called from one TypeScript program (`run_code`); takes effect only with `developmentShell`. */
2113
+ codeRun: z.boolean().default(false),
2114
+ /** Network for commands; absent in older clients means on. */
2115
+ commandNetwork: z.boolean().default(true)
1683
2116
  }).strict();
1684
2117
  const DynamicClientApprovalPolicySchema = z.enum(["manual", "automatic"]);
1685
2118
  const NotificationEventKeySchema = z.enum(["dynamic-client-approval-requested"]);
@@ -1737,7 +2170,11 @@ const CreateAgentRequestSchema = AgentRevisionRequestContentSchema.extend({ capa
1737
2170
  const ReviseAgentRequestSchema = AgentRevisionRequestContentSchema.extend({ expectedCurrentRevisionId: AgentRevisionIdSchema }).superRefine((value, context) => {
1738
2171
  validatePersonaDocumentProjection(value, context);
1739
2172
  });
1740
- const UpdateAgentCapabilitiesRequestSchema = AgentCapabilitiesSchema.partial().extend({ scheduledTasks: z.boolean().optional() }).strict().refine((value) => Object.values(value).some((entry) => entry !== void 0), "至少提供一个能力。");
2173
+ const UpdateAgentCapabilitiesRequestSchema = AgentCapabilitiesSchema.partial().extend({
2174
+ scheduledTasks: z.boolean().optional(),
2175
+ codeRun: z.boolean().optional(),
2176
+ commandNetwork: z.boolean().optional()
2177
+ }).strict().refine((value) => Object.values(value).some((entry) => entry !== void 0), "至少提供一个能力。");
1741
2178
  const TriggerPolicySchema = z.enum([
1742
2179
  "always",
1743
2180
  "mentioned-or-replied",
@@ -1800,7 +2237,9 @@ const HostSnapshotMessageSchema = z.object({
1800
2237
  parts: z.array(SnapshotMessagePartSchema),
1801
2238
  sender: z.object({
1802
2239
  memberId: ChannelMemberIdSchema,
1803
- displayName: z.string().optional()
2240
+ displayName: z.string().optional(),
2241
+ /** The sender is the account of this agent on this host, answering the channel through another connection. */
2242
+ localAgentId: AgentIdSchema.optional()
1804
2243
  }).strict().optional(),
1805
2244
  mentionedConnectionAccount: z.boolean().optional(),
1806
2245
  activityKey: AdapterActivityKeySchema.optional(),
@@ -1922,7 +2361,7 @@ const ChannelRuntimeUsageSchema = z.object({
1922
2361
  cacheWriteTokens: z.number().int().nonnegative().optional(),
1923
2362
  reasoningTokens: z.number().int().nonnegative().optional()
1924
2363
  }).strict();
1925
- const ChannelRuntimeToolSchema = z.object({
2364
+ const channelRuntimeToolFields = {
1926
2365
  callId: NonEmptyStringSchema,
1927
2366
  name: NonEmptyStringSchema,
1928
2367
  displayName: NonEmptyStringSchema,
@@ -1941,6 +2380,13 @@ const ChannelRuntimeToolSchema = z.object({
1941
2380
  "unknown"
1942
2381
  ]).optional(),
1943
2382
  durationMs: z.number().int().nonnegative().optional()
2383
+ };
2384
+ const ChannelRuntimeToolSchema = z.object({
2385
+ ...channelRuntimeToolFields,
2386
+ /** Source of a `run_code` program. */
2387
+ code: z.string().optional(),
2388
+ /** Tools a `run_code` program called, in the order they started. */
2389
+ children: z.array(z.object(channelRuntimeToolFields).strict()).optional()
1944
2390
  }).strict();
1945
2391
  const ChannelRuntimeStepSchema = z.object({
1946
2392
  step: z.number().int().nonnegative(),
@@ -1954,6 +2400,16 @@ const ChannelRuntimeStepSchema = z.object({
1954
2400
  firstTokenMs: z.number().int().nonnegative().optional(),
1955
2401
  usage: ChannelRuntimeUsageSchema.optional()
1956
2402
  }).strict();
2403
+ /** One message that entered the model's input during a turn: channel admissions and host or DSH injections. */
2404
+ const ChannelRuntimeInputSchema = z.object({
2405
+ messageId: z.string().min(1),
2406
+ /** DSH `user/message` source kind, e.g. `nekro-nxt-channel` or `nekro-nxt-handoff`. */
2407
+ source: z.string().min(1),
2408
+ /** Channel Events carried by a channel admission. */
2409
+ eventCount: z.number().int().positive().optional(),
2410
+ preview: z.string().optional(),
2411
+ at: z.number().int().safe().nonnegative().optional()
2412
+ }).strict();
1957
2413
  const ChannelRuntimeTurnSchema = z.object({
1958
2414
  turn: z.number().int().nonnegative(),
1959
2415
  state: z.enum([
@@ -1985,7 +2441,9 @@ const ChannelRuntimeTurnSchema = z.object({
1985
2441
  /** Session log time the turn closed; absent while it is still running. */
1986
2442
  endedAt: z.number().int().safe().nonnegative().optional(),
1987
2443
  /** Newest Channel Event of the admission that opened this turn; absent for non-channel turns. */
1988
- triggerEventId: ChannelEventIdSchema.optional()
2444
+ triggerEventId: ChannelEventIdSchema.optional(),
2445
+ /** Messages that entered the model's input during the turn, in log order; absent when there were none. */
2446
+ inputs: z.array(ChannelRuntimeInputSchema).optional()
1989
2447
  }).strict();
1990
2448
  const ChannelRuntimeOccupancySchema = z.object({
1991
2449
  projectedTokens: z.number().int().nonnegative(),
@@ -1994,7 +2452,9 @@ const ChannelRuntimeOccupancySchema = z.object({
1994
2452
  systemTokens: z.number().int().nonnegative(),
1995
2453
  toolsTokens: z.number().int().nonnegative(),
1996
2454
  messageTokens: z.number().int().nonnegative()
1997
- }).strict().optional()
2455
+ }).strict().optional(),
2456
+ /** Pictures in the conversation; their tokens are not in the breakdown, so they make up most of the rest. */
2457
+ imageCount: z.number().int().nonnegative().optional()
1998
2458
  }).strict();
1999
2459
  const ChannelRuntimeCacheSampleSchema = z.object({
2000
2460
  turn: z.number().int().nonnegative(),
@@ -2048,6 +2508,41 @@ const ChannelRuntimePerformanceSchema = z.object({
2048
2508
  samples: z.array(ChannelRuntimePerformanceSampleSchema)
2049
2509
  }).strict()
2050
2510
  }).strict();
2511
+ /** What the agent remembered or looked up, newest first; the admin sees it, the model does not. */
2512
+ const ChannelMemoryActivitySchema = z.discriminatedUnion("kind", [
2513
+ z.object({
2514
+ kind: z.literal("backlog-folded"),
2515
+ at: z.number().nonnegative().optional(),
2516
+ foldedCount: z.number().int().nonnegative(),
2517
+ shownCount: z.number().int().nonnegative(),
2518
+ foldedImageCount: z.number().int().nonnegative()
2519
+ }).strict(),
2520
+ z.object({
2521
+ kind: z.literal("history-search"),
2522
+ at: z.number().nonnegative().optional(),
2523
+ query: z.string(),
2524
+ hits: z.number().int().nonnegative(),
2525
+ sender: z.string().optional()
2526
+ }).strict(),
2527
+ z.object({
2528
+ kind: z.literal("notes-updated"),
2529
+ at: z.number().nonnegative().optional(),
2530
+ revision: z.number().int().nonnegative(),
2531
+ chars: z.number().int().nonnegative()
2532
+ }).strict(),
2533
+ z.object({
2534
+ kind: z.literal("member-notes-updated"),
2535
+ at: z.number().nonnegative().optional(),
2536
+ memberId: z.string(),
2537
+ name: z.string().optional(),
2538
+ chars: z.number().int().nonnegative()
2539
+ }).strict(),
2540
+ z.object({
2541
+ kind: z.literal("idle-review"),
2542
+ at: z.number().nonnegative().optional(),
2543
+ quietMinutes: z.number().int().nonnegative()
2544
+ }).strict()
2545
+ ]);
2051
2546
  const ChannelRuntimeProjectionSchema = z.object({
2052
2547
  channelId: ChannelIdSchema,
2053
2548
  agentId: AgentIdSchema.optional(),
@@ -2058,12 +2553,173 @@ const ChannelRuntimeProjectionSchema = z.object({
2058
2553
  occupancy: ChannelRuntimeOccupancySchema.optional(),
2059
2554
  cache: ChannelRuntimeCacheSchema.optional(),
2060
2555
  performance: ChannelRuntimePerformanceSchema.optional(),
2556
+ memory: z.array(ChannelMemoryActivitySchema).optional(),
2061
2557
  turns: z.array(ChannelRuntimeTurnSchema)
2062
2558
  }).strict();
2063
2559
  const ChannelRuntimeSseDataSchema = ChannelRuntimeProjectionSchema.extend({
2064
2560
  revision: z.number().int().positive(),
2065
2561
  truncated: z.boolean().optional()
2066
2562
  }).strict();
2563
+ const ChannelRuntimeContextSchema = z.object({
2564
+ available: z.boolean(),
2565
+ route: z.object({
2566
+ provider: z.string(),
2567
+ model: z.string(),
2568
+ contextWindow: z.number().int().positive().optional(),
2569
+ reasoningEffort: z.string().optional(),
2570
+ temperature: z.number().optional(),
2571
+ maxTokens: z.number().int().positive().optional()
2572
+ }).strict().optional(),
2573
+ instructions: z.array(z.object({
2574
+ role: z.enum(["system", "developer"]),
2575
+ text: z.string(),
2576
+ truncated: z.boolean()
2577
+ }).strict()),
2578
+ tools: z.array(z.object({
2579
+ name: z.string(),
2580
+ description: z.string().optional(),
2581
+ parameters: z.string().optional()
2582
+ }).strict()),
2583
+ changes: z.array(z.object({
2584
+ at: z.number().nonnegative().optional(),
2585
+ reason: z.enum([
2586
+ "initial",
2587
+ "resume",
2588
+ "change",
2589
+ "series"
2590
+ ]),
2591
+ toolCount: z.number().int().nonnegative()
2592
+ }).strict())
2593
+ }).strict();
2594
+ const ChannelPromptPartSchema = z.object({
2595
+ document: PromptDocumentV1Schema,
2596
+ /** Notes only: the agent may not rewrite them. */
2597
+ locked: z.boolean(),
2598
+ /** 0 before the first save; send it back as `expectedRevision`. */
2599
+ revision: z.number().int().nonnegative(),
2600
+ maxChars: z.number().int().positive(),
2601
+ updatedBy: z.enum(["admin", "agent"]).optional(),
2602
+ updatedAt: z.number().int().nonnegative().optional(),
2603
+ revisions: z.array(z.object({
2604
+ revision: z.number().int().positive(),
2605
+ document: PromptDocumentV1Schema,
2606
+ updatedBy: z.enum(["admin", "agent"]),
2607
+ updatedAt: z.number().int().nonnegative()
2608
+ }).strict())
2609
+ }).strict();
2610
+ /**
2611
+ * What the agent answering a channel reads about it, each part with recent earlier versions to restore: the admin's
2612
+ * instructions (system prompt) and the agent's own notes (runtime context).
2613
+ */
2614
+ const ChannelPromptViewSchema = z.object({
2615
+ instructions: ChannelPromptPartSchema,
2616
+ notes: ChannelPromptPartSchema
2617
+ }).strict();
2618
+ /**
2619
+ * How much of a channel's unread backlog reaches the agent at once, and when it looks back on its own. Uncertain
2620
+ * trade-offs stay per channel: a busy meme group and a long tabletop session want different budgets.
2621
+ */
2622
+ const ChannelContextPolicySchema = z.object({
2623
+ /** Text characters of a backlog read message by message; older messages collapse into one line. 0: no limit. */
2624
+ backlogTextChars: z.number().int().nonnegative().max(1e6),
2625
+ /** Backlog images shown as pictures, newest first; the rest stay references the agent can open. */
2626
+ backlogImages: z.number().int().nonnegative().max(20),
2627
+ /** Quiet minutes after which the agent reviews the conversation and updates its notes. 0: off. */
2628
+ idleReviewMinutes: z.number().int().nonnegative().max(1440)
2629
+ }).strict();
2630
+ const DEFAULT_CHANNEL_CONTEXT_POLICY = Object.freeze({
2631
+ backlogTextChars: 4e4,
2632
+ backlogImages: 6,
2633
+ idleReviewMinutes: 45
2634
+ });
2635
+ const ChannelContextPolicyViewSchema = z.object({
2636
+ policy: ChannelContextPolicySchema,
2637
+ defaults: ChannelContextPolicySchema,
2638
+ /** False while the channel follows the defaults. */
2639
+ custom: z.boolean()
2640
+ }).strict();
2641
+ /** Whether a newer release exists on the build's own channel; development builds are never compared. */
2642
+ const ProductUpdateStatusSchema = z.object({
2643
+ channel: z.enum([
2644
+ "stable",
2645
+ "preview",
2646
+ "development"
2647
+ ]),
2648
+ currentVersion: z.string(),
2649
+ /** Short commit of a release build. */
2650
+ currentCommit: z.string().optional(),
2651
+ state: z.enum([
2652
+ "unknown",
2653
+ "up-to-date",
2654
+ "available",
2655
+ "failed",
2656
+ "unsupported"
2657
+ ]),
2658
+ latest: z.object({
2659
+ version: z.string(),
2660
+ commit: z.string().optional(),
2661
+ url: z.string().url(),
2662
+ publishedAt: z.number().int().nonnegative().optional()
2663
+ }).strict().optional(),
2664
+ checkedAt: z.number().int().nonnegative().optional(),
2665
+ error: z.string().optional(),
2666
+ autoCheck: z.boolean()
2667
+ }).strict();
2668
+ /** Pause between consecutive messages an agent sends to one channel; longer messages wait a little longer. */
2669
+ const MessagePacingSchema = z.enum([
2670
+ "off",
2671
+ "fast",
2672
+ "normal",
2673
+ "slow"
2674
+ ]);
2675
+ const DEFAULT_MESSAGE_PACING = "normal";
2676
+ const MessagePacingSettingsSchema = z.object({ pacing: MessagePacingSchema }).strict();
2677
+ /** `keyword`: SQLite keyword search only; `builtin`: keywords fused with the built-in semantic model. */
2678
+ const RetrievalModeSchema = z.enum(["keyword", "builtin"]);
2679
+ /** Search used by extension indexes (表情包与扩展素材能力 §6.4). */
2680
+ const RetrievalStatusSchema = z.object({
2681
+ mode: RetrievalModeSchema,
2682
+ builtin: z.object({
2683
+ model: z.string(),
2684
+ /** False where no inference runtime is published for this system and processor. */
2685
+ supported: z.boolean(),
2686
+ downloadBytes: z.number().int().nonnegative(),
2687
+ install: z.discriminatedUnion("state", [
2688
+ z.object({ state: z.literal("not-installed") }).strict(),
2689
+ z.object({
2690
+ state: z.literal("downloading"),
2691
+ receivedBytes: z.number().int().nonnegative(),
2692
+ totalBytes: z.number().int().nonnegative()
2693
+ }).strict(),
2694
+ z.object({ state: z.literal("installed") }).strict(),
2695
+ z.object({
2696
+ state: z.literal("failed"),
2697
+ error: z.string()
2698
+ }).strict()
2699
+ ])
2700
+ }).strict(),
2701
+ vectors: z.object({
2702
+ documents: z.number().int().nonnegative(),
2703
+ embedded: z.number().int().nonnegative(),
2704
+ state: z.enum([
2705
+ "idle",
2706
+ "running",
2707
+ "ready"
2708
+ ]),
2709
+ error: z.string().optional()
2710
+ }).strict()
2711
+ }).strict();
2712
+ /** What the agent keeps about individual members of one channel; each note comes with that member's messages. */
2713
+ const ChannelMemberNotesViewSchema = z.object({
2714
+ notes: z.array(z.object({
2715
+ memberId: ChannelMemberIdSchema,
2716
+ displayName: z.string().optional(),
2717
+ text: z.string(),
2718
+ updatedBy: z.enum(["admin", "agent"]),
2719
+ updatedAt: z.number().int().nonnegative()
2720
+ }).strict()),
2721
+ maxChars: z.number().int().positive()
2722
+ }).strict();
2067
2723
  const AdapterConnectionCreationSchema = z.object({
2068
2724
  mode: z.enum(["schema-form", "qr-login"]),
2069
2725
  actionLabel: z.string().trim().min(1).optional(),
@@ -2092,7 +2748,8 @@ const AdapterConnectionDescriptorSchema = z.object({
2092
2748
  "internal",
2093
2749
  "direct",
2094
2750
  "group"
2095
- ])).optional()
2751
+ ])).optional(),
2752
+ directedAt: z.enum(["member", "message"]).optional()
2096
2753
  }).strict()),
2097
2754
  features: z.object({ processingFeedback: z.object({ channelKinds: z.array(z.enum(["direct", "group"])).min(1) }).strict().optional() }).strict(),
2098
2755
  diagnostics: z.object({
@@ -2302,6 +2959,27 @@ const ScheduledTaskSchema = z.object({
2302
2959
  lastFiredAt: z.number().int().safe().optional(),
2303
2960
  createdAt: z.number().int().safe()
2304
2961
  }).strict();
2962
+ /** The Node that runs `run_code` programs, and the download the desktop app offers when there is none. */
2963
+ const CodeRunAvailabilitySchema = z.object({
2964
+ available: z.boolean(),
2965
+ source: z.enum([
2966
+ "host",
2967
+ "system",
2968
+ "downloaded"
2969
+ ]).optional(),
2970
+ version: z.string().optional(),
2971
+ download: z.object({
2972
+ version: z.string(),
2973
+ state: z.enum([
2974
+ "idle",
2975
+ "downloading",
2976
+ "failed"
2977
+ ]),
2978
+ receivedBytes: z.number().int().nonnegative().optional(),
2979
+ totalBytes: z.number().int().nonnegative().optional(),
2980
+ error: z.string().optional()
2981
+ }).strict().optional()
2982
+ }).strict();
2305
2983
  const HostSnapshotSchema = z.object({
2306
2984
  upgrade: HostUpgradeSummarySchema.optional(),
2307
2985
  cursor: HostSyncCursorSchema,
@@ -2325,6 +3003,13 @@ const HostSnapshotSchema = z.object({
2325
3003
  }).strict()),
2326
3004
  capabilityAvailability: z.object({
2327
3005
  subagents: z.object({ available: z.boolean() }).strict(),
3006
+ /** Optional in older hosts, which never offer `run_code`. */
3007
+ codeRun: CodeRunAvailabilitySchema.optional(),
3008
+ /** What this host can confine for commands beyond file writes; optional in older hosts. */
3009
+ commandConfinement: z.object({
3010
+ readScope: z.boolean(),
3011
+ networkControl: z.boolean()
3012
+ }).strict().optional(),
2328
3013
  webSearch: z.object({
2329
3014
  provider: z.literal("deepseek-official"),
2330
3015
  available: z.boolean(),
@@ -2400,11 +3085,15 @@ const HostSnapshotSchema = z.object({
2400
3085
  unreadCount: 0,
2401
3086
  unreadCapped: false
2402
3087
  }),
3088
+ /** Other agents on this host that answer the same platform channel through another connection; absent when none. */
3089
+ localAgentIds: z.array(AgentIdSchema).min(1).optional(),
2403
3090
  bindings: z.array(z.object({
2404
3091
  channelId: ChannelIdSchema,
2405
3092
  agentId: AgentIdSchema,
2406
3093
  triggerPolicy: TriggerPolicySchema,
2407
3094
  processingFeedback: z.enum(["auto", "off"]).default("auto"),
3095
+ /** Absent means `observe`. */
3096
+ localAgentMessages: z.enum(["observe", "trigger"]).optional(),
2408
3097
  activityTriggerOverrides: ActivityTriggerOverridesSchema.default({}),
2409
3098
  boundAt: z.number().int().safe().nonnegative()
2410
3099
  }).strict())
@@ -2483,11 +3172,8 @@ const HostSnapshotSchema = z.object({
2483
3172
  }).strict()).default([]),
2484
3173
  extensions: z.array(z.object({
2485
3174
  id: ExtensionIdSchema,
2486
- scope: z.enum([
2487
- "agent",
2488
- "host-adapter",
2489
- "host-ui"
2490
- ]),
3175
+ /** What the latest Revision provides; listing and filtering only. */
3176
+ provides: z.array(ExtensionProvideSchema),
2491
3177
  slug: NonEmptyStringSchema,
2492
3178
  displayName: z.string(),
2493
3179
  description: z.string(),
@@ -2497,15 +3183,18 @@ const HostSnapshotSchema = z.object({
2497
3183
  revisionNumber: z.number().int().positive(),
2498
3184
  format: z.enum(["current", "unavailable"]).optional(),
2499
3185
  ui: ExtensionUiContributionsSchema.default(EMPTY_EXTENSION_UI_CONTRIBUTIONS),
2500
- configSchema: ConfigSchemaDocumentSchema.optional(),
3186
+ /** The host instance's configuration form (`config.host`). */
3187
+ hostConfigSchema: ConfigSchemaDocumentSchema.optional(),
3188
+ /** Each enabled agent's configuration form (`config.agent`). */
3189
+ agentConfigSchema: ConfigSchemaDocumentSchema.optional(),
3190
+ /** 扩展包自带图标的读取路径(同源、按摘要寻址、可长期缓存);没有图标时缺省。 */
3191
+ iconUrl: z.string().regex(/^\/api\/extensions\/[^/]+\/revisions\/[^/]+\/icon\/[a-f0-9]{64}\.(?:svg|png|webp)$/u).optional(),
2501
3192
  createdAt: z.number().int().safe().nonnegative(),
2502
- /** 从社区安装的保存记录的来源;本机保存与文件导入没有来源。 */
3193
+ /** 从社区安装的版本的来源;本机保存与文件导入没有来源。 */
2503
3194
  source: CommunitySourceSchema.optional(),
2504
- scope: z.enum([
2505
- "agent",
2506
- "host-adapter",
2507
- "host-ui"
2508
- ]),
3195
+ provides: z.array(ExtensionProvideSchema),
3196
+ /** Whether this Revision can be enabled for agents (agent-layer contributions or capabilities). */
3197
+ agentLayer: z.boolean(),
2509
3198
  contributions: z.array(z.string()),
2510
3199
  verification: z.object({
2511
3200
  verifiedAt: z.number().int().nonnegative(),
@@ -2522,9 +3211,11 @@ const HostSnapshotSchema = z.object({
2522
3211
  renderedPages: z.array(HostPageContributionSchema).max(8).optional(),
2523
3212
  usedUiComponents: z.array(HostUiKitComponentNameSchema).optional(),
2524
3213
  pageGeometry: z.array(HostUiPageGeometryEvidenceSchema).max(8).optional(),
2525
- permissions: HostUiPermissionDeclarationSchema.optional(),
2526
- permissionDigest: z.string().regex(/^[a-f0-9]{64}$/u).optional(),
2527
- permissionApprovalRequired: z.boolean().optional(),
3214
+ permissions: ExtensionPermissionsSchema.optional(),
3215
+ /** Installing this Revision on the machine, against the current host grant. */
3216
+ hostPermission: ExtensionPermissionRequirementSchema.optional(),
3217
+ /** Enabling this Revision for an agent that has no grant yet. */
3218
+ agentPermission: ExtensionPermissionRequirementSchema.optional(),
2528
3219
  adapter: z.object({
2529
3220
  apiVersion: z.literal(2),
2530
3221
  key: NonEmptyStringSchema,
@@ -2572,10 +3263,14 @@ const HostSnapshotSchema = z.object({
2572
3263
  observedAt: z.number().int().safe().nonnegative()
2573
3264
  }).strict()).optional()
2574
3265
  }).strict()),
3266
+ /** Present only while some agent's enable or disable request is waiting or has failed. */
3267
+ activationTransitions: z.array(ExtensionActivationTransitionSchema).optional(),
2575
3268
  installation: z.object({
2576
3269
  extensionRevisionId: ExtensionRevisionIdSchema,
2577
3270
  installedAt: z.number().int().safe().nonnegative(),
3271
+ /** Secret fields are removed; `configuredSecrets` lists those the Host stores. */
2578
3272
  config: JsonValueSchema.default({}),
3273
+ configuredSecrets: z.array(z.string()).optional(),
2579
3274
  runtime: z.object({
2580
3275
  status: z.enum([
2581
3276
  "active",
@@ -2586,11 +3281,8 @@ const HostSnapshotSchema = z.object({
2586
3281
  observedAt: z.number().int().safe().nonnegative()
2587
3282
  }).optional()
2588
3283
  }).strict().optional(),
2589
- hostUiPermission: z.object({
2590
- declaration: HostUiPermissionDeclarationSchema,
2591
- permissionDigest: z.string().regex(/^[a-f0-9]{64}$/u),
2592
- approvalRequired: z.boolean()
2593
- }).strict().optional(),
3284
+ /** Installing the latest Revision on this machine, against the current host grant. */
3285
+ hostPermission: ExtensionPermissionRequirementSchema.optional(),
2594
3286
  hostClientDiagnostic: z.object({
2595
3287
  revisionId: ExtensionRevisionIdSchema,
2596
3288
  status: z.enum(["loaded", "failed"]),
@@ -2948,6 +3640,19 @@ const LlmProviderCredentialSchema = z.object({
2948
3640
  source: z.string().optional(),
2949
3641
  writable: z.boolean()
2950
3642
  }).strict();
3643
+ /**
3644
+ * The latest connection test that still describes the provider's saved address, protocol and API key. Tests made
3645
+ * before one of those changed are dropped. Never carries a key, request or response body.
3646
+ */
3647
+ const LlmProviderTestResultSchema = z.object({
3648
+ /** Epoch milliseconds when the test finished. */
3649
+ at: z.number().int().nonnegative(),
3650
+ ok: z.boolean(),
3651
+ /** Short failure reason shown to the user; absent when the test passed. */
3652
+ message: z.string().max(240).optional(),
3653
+ /** The model the test asked. */
3654
+ model: NonEmptyStringSchema.optional()
3655
+ }).strict();
2951
3656
  const LlmProviderViewSchema = z.object({
2952
3657
  provider: NonEmptyStringSchema,
2953
3658
  displayName: z.string(),
@@ -2964,7 +3669,9 @@ const LlmProviderViewSchema = z.object({
2964
3669
  /** The model list was edited on this host; built-in providers can restore their own catalog. */
2965
3670
  modelsCustomized: z.boolean(),
2966
3671
  /** The provider's adapter can list the models its endpoint offers. */
2967
- discoverable: z.boolean()
3672
+ discoverable: z.boolean(),
3673
+ /** `null` when the current configuration was never tested; absent from hosts that do not record tests. */
3674
+ lastTest: LlmProviderTestResultSchema.nullable().optional()
2968
3675
  }).strict();
2969
3676
  const LlmProviderSettingsSchema = z.object({
2970
3677
  writable: z.boolean(),
@@ -3005,11 +3712,7 @@ const ExtensionImportInspectionSchema = z.object({
3005
3712
  revisionId: ExtensionRevisionIdSchema,
3006
3713
  slug: NonEmptyStringSchema,
3007
3714
  displayName: NonEmptyStringSchema,
3008
- scope: z.enum([
3009
- "agent",
3010
- "host-adapter",
3011
- "host-ui"
3012
- ]),
3715
+ provides: z.array(ExtensionProvideSchema),
3013
3716
  idempotent: z.boolean(),
3014
3717
  slugConflict: z.boolean()
3015
3718
  }).strict();
@@ -3056,6 +3759,7 @@ const agentExtensionParam = z.object({
3056
3759
  agentId: AgentIdSchema,
3057
3760
  extensionId: ExtensionIdSchema
3058
3761
  }).strict();
3762
+ const PermissionApprovalSchema = z.object({ permissionDigest: z.string().regex(/^[a-f0-9]{64}$/u) }).strict();
3059
3763
  const extensionParam = z.object({ extensionId: ExtensionIdSchema }).strict();
3060
3764
  const dshPluginPackageParam = z.object({ packageId: DshPluginPackageIdSchema }).strict();
3061
3765
  const dshPluginEntryParam = z.object({ entryId: DshPluginEntryIdSchema }).strict();
@@ -3391,6 +4095,8 @@ const HostApiContracts = {
3391
4095
  channelId: ChannelIdSchema,
3392
4096
  triggerPolicy: TriggerPolicySchema,
3393
4097
  processingFeedback: z.enum(["auto", "off"]).optional(),
4098
+ /** Messages from another local agent's account: `observe` keeps them as context unless they @ this agent. */
4099
+ localAgentMessages: z.enum(["observe", "trigger"]).optional(),
3394
4100
  activityTriggerOverrides: ActivityTriggerOverridesSchema.optional()
3395
4101
  }).strict(),
3396
4102
  response: z.object({
@@ -3398,6 +4104,7 @@ const HostApiContracts = {
3398
4104
  agentId: AgentIdSchema,
3399
4105
  triggerPolicy: TriggerPolicySchema,
3400
4106
  processingFeedback: z.enum(["auto", "off"]).default("auto"),
4107
+ localAgentMessages: z.enum(["observe", "trigger"]).optional(),
3401
4108
  activityTriggerOverrides: ActivityTriggerOverridesSchema.default({}),
3402
4109
  boundAt: z.number().int().safe().nonnegative()
3403
4110
  }).strict(),
@@ -3492,6 +4199,181 @@ const HostApiContracts = {
3492
4199
  }).strict(),
3493
4200
  error: HostApiErrorSchema
3494
4201
  }),
4202
+ getChannelRuntimeContext: defineContract({
4203
+ method: "GET",
4204
+ path: "/api/channels/:channelId/runtime/context",
4205
+ params: channelParam,
4206
+ request: NoRequestBodySchema,
4207
+ response: ChannelRuntimeContextSchema,
4208
+ error: HostApiErrorSchema
4209
+ }),
4210
+ getChannelRuntimeInput: defineContract({
4211
+ method: "GET",
4212
+ path: "/api/channels/:channelId/runtime/inputs/:messageId",
4213
+ params: z.object({
4214
+ channelId: ChannelIdSchema,
4215
+ messageId: z.string().trim().min(1).max(200)
4216
+ }).strict(),
4217
+ request: NoRequestBodySchema,
4218
+ response: z.object({
4219
+ messageId: z.string(),
4220
+ available: z.boolean(),
4221
+ source: z.string().optional(),
4222
+ text: z.string().optional(),
4223
+ truncated: z.boolean()
4224
+ }).strict(),
4225
+ error: HostApiErrorSchema
4226
+ }),
4227
+ getChannelPrompt: defineContract({
4228
+ method: "GET",
4229
+ path: "/api/channels/:channelId/prompt",
4230
+ params: channelParam,
4231
+ request: NoRequestBodySchema,
4232
+ response: ChannelPromptViewSchema,
4233
+ error: HostApiErrorSchema
4234
+ }),
4235
+ updateChannelPrompt: defineContract({
4236
+ method: "PUT",
4237
+ path: "/api/channels/:channelId/prompt",
4238
+ params: channelParam,
4239
+ request: z.object({
4240
+ kind: z.enum(["instructions", "notes"]),
4241
+ document: PromptDocumentV1Schema,
4242
+ /** Notes only; ignored for instructions. */
4243
+ locked: z.boolean(),
4244
+ /** The revision the edit started from; a newer stored revision rejects the save. */
4245
+ expectedRevision: z.number().int().nonnegative()
4246
+ }).strict(),
4247
+ response: ChannelPromptViewSchema,
4248
+ error: HostApiErrorSchema
4249
+ }),
4250
+ getProductUpdates: defineContract({
4251
+ method: "GET",
4252
+ path: "/api/product/updates",
4253
+ params: EmptyParamsSchema,
4254
+ request: NoRequestBodySchema,
4255
+ response: ProductUpdateStatusSchema,
4256
+ error: HostApiErrorSchema
4257
+ }),
4258
+ checkProductUpdates: defineContract({
4259
+ method: "POST",
4260
+ path: "/api/product/updates/check",
4261
+ params: EmptyParamsSchema,
4262
+ request: NoRequestBodySchema,
4263
+ response: ProductUpdateStatusSchema,
4264
+ error: HostApiErrorSchema
4265
+ }),
4266
+ updateProductUpdateSettings: defineContract({
4267
+ method: "PUT",
4268
+ path: "/api/product/updates/settings",
4269
+ params: EmptyParamsSchema,
4270
+ request: z.object({ autoCheck: z.boolean() }).strict(),
4271
+ response: ProductUpdateStatusSchema,
4272
+ error: HostApiErrorSchema
4273
+ }),
4274
+ getMessagePacingSettings: defineContract({
4275
+ method: "GET",
4276
+ path: "/api/settings/message-pacing",
4277
+ params: EmptyParamsSchema,
4278
+ request: NoRequestBodySchema,
4279
+ response: MessagePacingSettingsSchema,
4280
+ error: HostApiErrorSchema
4281
+ }),
4282
+ updateMessagePacingSettings: defineContract({
4283
+ method: "PUT",
4284
+ path: "/api/settings/message-pacing",
4285
+ params: EmptyParamsSchema,
4286
+ request: MessagePacingSettingsSchema,
4287
+ response: MessagePacingSettingsSchema,
4288
+ error: HostApiErrorSchema
4289
+ }),
4290
+ getRetrievalStatus: defineContract({
4291
+ method: "GET",
4292
+ path: "/api/settings/retrieval",
4293
+ params: EmptyParamsSchema,
4294
+ request: NoRequestBodySchema,
4295
+ response: RetrievalStatusSchema,
4296
+ error: HostApiErrorSchema
4297
+ }),
4298
+ updateRetrievalMode: defineContract({
4299
+ method: "PUT",
4300
+ path: "/api/settings/retrieval",
4301
+ params: EmptyParamsSchema,
4302
+ request: z.object({ mode: RetrievalModeSchema }).strict(),
4303
+ response: RetrievalStatusSchema,
4304
+ error: HostApiErrorSchema
4305
+ }),
4306
+ downloadRetrievalModel: defineContract({
4307
+ method: "POST",
4308
+ path: "/api/settings/retrieval/model/download",
4309
+ params: EmptyParamsSchema,
4310
+ request: NoRequestBodySchema,
4311
+ response: RetrievalStatusSchema,
4312
+ error: HostApiErrorSchema
4313
+ }),
4314
+ removeRetrievalModel: defineContract({
4315
+ method: "DELETE",
4316
+ path: "/api/settings/retrieval/model",
4317
+ params: EmptyParamsSchema,
4318
+ request: NoRequestBodySchema,
4319
+ response: RetrievalStatusSchema,
4320
+ error: HostApiErrorSchema
4321
+ }),
4322
+ downloadCodeRunNode: defineContract({
4323
+ invalidatesSnapshot: true,
4324
+ method: "POST",
4325
+ path: "/api/runtimes/code-run-node/download",
4326
+ params: EmptyParamsSchema,
4327
+ request: NoRequestBodySchema,
4328
+ response: CodeRunAvailabilitySchema,
4329
+ error: HostApiErrorSchema
4330
+ }),
4331
+ removeCodeRunNode: defineContract({
4332
+ invalidatesSnapshot: true,
4333
+ method: "DELETE",
4334
+ path: "/api/runtimes/code-run-node",
4335
+ params: EmptyParamsSchema,
4336
+ request: NoRequestBodySchema,
4337
+ response: CodeRunAvailabilitySchema,
4338
+ error: HostApiErrorSchema
4339
+ }),
4340
+ getChannelMemberNotes: defineContract({
4341
+ method: "GET",
4342
+ path: "/api/channels/:channelId/member-notes",
4343
+ params: channelParam,
4344
+ request: NoRequestBodySchema,
4345
+ response: ChannelMemberNotesViewSchema,
4346
+ error: HostApiErrorSchema
4347
+ }),
4348
+ updateChannelMemberNote: defineContract({
4349
+ method: "PUT",
4350
+ path: "/api/channels/:channelId/member-notes/:memberId",
4351
+ params: z.object({
4352
+ channelId: ChannelIdSchema,
4353
+ memberId: ChannelMemberIdSchema
4354
+ }).strict(),
4355
+ /** An empty text forgets the member. */
4356
+ request: z.object({ text: z.string().max(2e3) }).strict(),
4357
+ response: ChannelMemberNotesViewSchema,
4358
+ error: HostApiErrorSchema
4359
+ }),
4360
+ getChannelContextPolicy: defineContract({
4361
+ method: "GET",
4362
+ path: "/api/channels/:channelId/context-policy",
4363
+ params: channelParam,
4364
+ request: NoRequestBodySchema,
4365
+ response: ChannelContextPolicyViewSchema,
4366
+ error: HostApiErrorSchema
4367
+ }),
4368
+ updateChannelContextPolicy: defineContract({
4369
+ method: "PUT",
4370
+ path: "/api/channels/:channelId/context-policy",
4371
+ params: channelParam,
4372
+ /** `null` returns the channel to the defaults. */
4373
+ request: z.object({ policy: ChannelContextPolicySchema.nullable() }).strict(),
4374
+ response: ChannelContextPolicyViewSchema,
4375
+ error: HostApiErrorSchema
4376
+ }),
3495
4377
  resetChannelContext: defineContract({
3496
4378
  invalidatesSnapshot: true,
3497
4379
  method: "POST",
@@ -3825,11 +4707,11 @@ const HostApiContracts = {
3825
4707
  path: "/api/community/extensions",
3826
4708
  params: z.object({
3827
4709
  query: z.string().trim().max(80).optional(),
3828
- scope: z.enum([
3829
- "agent",
3830
- "host-adapter",
3831
- "host-ui"
3832
- ]).optional(),
4710
+ provides: ExtensionProvideSchema.optional(),
4711
+ /** 只列社区后台认定的官方扩展。 */
4712
+ official: z.enum(["1"]).optional(),
4713
+ /** 排序方式,默认最近更新;游标只在同一种排序下有效。 */
4714
+ sort: CommunityExtensionSortSchema.optional(),
3833
4715
  cursor: z.string().max(200).optional()
3834
4716
  }).strict(),
3835
4717
  request: NoRequestBodySchema,
@@ -3952,7 +4834,9 @@ const HostApiContracts = {
3952
4834
  request: z.object({
3953
4835
  extensionId: ExtensionIdSchema,
3954
4836
  revisionId: ExtensionRevisionIdSchema,
3955
- notes: z.string().max(2e3)
4837
+ notes: z.string().max(2e3),
4838
+ /** 作者填写的条目信息;省略的字段不改动社区上已有的内容。 */
4839
+ listing: CommunityListingInputSchema.optional()
3956
4840
  }).strict(),
3957
4841
  response: z.object({
3958
4842
  releaseId: CommunityReleaseIdSchema,
@@ -3966,6 +4850,102 @@ const HostApiContracts = {
3966
4850
  }).strict(),
3967
4851
  error: HostApiErrorSchema
3968
4852
  }),
4853
+ listCommunityPersonas: defineContract({
4854
+ timeoutMs: 3e4,
4855
+ method: "GET",
4856
+ path: "/api/community/personas",
4857
+ params: z.object({
4858
+ query: z.string().trim().min(1).max(200).optional(),
4859
+ tag: z.string().trim().min(1).max(40).optional(),
4860
+ official: z.literal("1").optional(),
4861
+ cursor: z.string().min(1).max(500).optional()
4862
+ }).strict(),
4863
+ request: NoRequestBodySchema,
4864
+ response: z.object({
4865
+ items: z.array(CommunityPersonaSummarySchema),
4866
+ nextCursor: z.string().nullable()
4867
+ }).strict(),
4868
+ error: HostApiErrorSchema
4869
+ }),
4870
+ getCommunityPersona: defineContract({
4871
+ timeoutMs: 3e4,
4872
+ method: "GET",
4873
+ path: "/api/community/personas/:personaId",
4874
+ params: z.object({ personaId: CommunityPersonaIdSchema }).strict(),
4875
+ request: NoRequestBodySchema,
4876
+ response: CommunityPersonaDetailSchema,
4877
+ error: HostApiErrorSchema
4878
+ }),
4879
+ /**
4880
+ * 把社区人设装进本机:新建一个智能体,或为现有智能体保存一次只换设定(及可选名称)的新配置。头像下载后作为
4881
+ * 智能体头像;下载失败不影响安装。`expectedRevisionId` 是用户看过的修订,社区已更新时拒绝,避免装入未看过的内容。
4882
+ */
4883
+ installCommunityPersona: defineContract({
4884
+ invalidatesSnapshot: true,
4885
+ timeoutMs: 6e4,
4886
+ method: "POST",
4887
+ path: "/api/community/personas/:personaId/install",
4888
+ params: z.object({ personaId: CommunityPersonaIdSchema }).strict(),
4889
+ request: z.discriminatedUnion("target", [z.object({
4890
+ target: z.literal("new"),
4891
+ expectedRevisionId: CommunityPersonaRevisionIdSchema,
4892
+ displayName: z.string().trim().min(1).max(80),
4893
+ model: AgentModelSchema,
4894
+ useAvatar: z.boolean()
4895
+ }).strict(), z.object({
4896
+ target: z.literal("replace"),
4897
+ expectedRevisionId: CommunityPersonaRevisionIdSchema,
4898
+ agentId: AgentIdSchema,
4899
+ expectedCurrentRevisionId: AgentRevisionIdSchema,
4900
+ /** 同时改名;省略时保留原名称。 */
4901
+ displayName: z.string().trim().min(1).max(80).optional(),
4902
+ useAvatar: z.boolean()
4903
+ }).strict()]),
4904
+ response: z.object({
4905
+ agentId: AgentIdSchema,
4906
+ channelId: ChannelIdSchema.nullable(),
4907
+ currentRevisionId: AgentRevisionIdSchema,
4908
+ avatar: z.enum([
4909
+ "applied",
4910
+ "none",
4911
+ "failed"
4912
+ ])
4913
+ }).strict(),
4914
+ error: HostApiErrorSchema
4915
+ }),
4916
+ listCommunityMyPersonas: defineContract({
4917
+ timeoutMs: 3e4,
4918
+ method: "GET",
4919
+ path: "/api/community/mine/personas",
4920
+ params: EmptyParamsSchema,
4921
+ request: NoRequestBodySchema,
4922
+ response: CommunityMyPersonasSchema,
4923
+ error: HostApiErrorSchema
4924
+ }),
4925
+ /** 把智能体的设定分享到社区;带 `personaId` 时更新自己已发布的人设(生成新修订并重新审查)。 */
4926
+ publishCommunityPersona: defineContract({
4927
+ timeoutMs: 6e4,
4928
+ method: "POST",
4929
+ path: "/api/community/personas/publish",
4930
+ params: EmptyParamsSchema,
4931
+ request: z.object({
4932
+ agentId: AgentIdSchema,
4933
+ personaId: CommunityPersonaIdSchema.optional(),
4934
+ name: z.string().trim().min(1).max(80),
4935
+ summary: z.string().trim().min(1).max(200),
4936
+ description: z.string().max(2e4),
4937
+ tags: z.array(z.string().trim().min(1).max(40)).max(16),
4938
+ persona: z.string().trim().min(1).max(COMMUNITY_PERSONA_MAX_LENGTH),
4939
+ notes: z.string().max(2e3).optional(),
4940
+ /** 页面缩放后的头像(Base64);省略时不上传头像,更新时保留社区上的原头像。 */
4941
+ avatar: z.object({
4942
+ mediaType: z.enum(COMMUNITY_PERSONA_AVATAR_TYPES),
4943
+ base64: z.string().min(1).max(Math.ceil(512 * 1024 * 4 / 3) + 4)
4944
+ }).strict().optional()
4945
+ }).strict(),
4946
+ response: CommunityMyPersonaSchema,
4947
+ error: HostApiErrorSchema
4948
+ }),
3969
4949
  testMcpServer: defineContract({
3970
4950
  timeoutMs: 3e4,
3971
4951
  method: "POST",
@@ -4367,8 +5347,18 @@ const HostApiContracts = {
4367
5347
  method: "POST",
4368
5348
  path: "/api/extensions/:extensionId/revisions/:revisionId/call",
4369
5349
  params: extensionRevisionParam,
5350
+ /**
5351
+ * A panel's call to its extension's host instance. The Host checks the anchor (the agent has the extension
5352
+ * enabled; the channel or connection exists) and hands the extension the resolved caller.
5353
+ */
4370
5354
  request: z.object({
4371
- agentId: AgentIdSchema,
5355
+ /** Absent: the call comes from the extension itself, like a page call. */
5356
+ anchor: z.object({
5357
+ kind: ExtensionPanelAnchorSchema,
5358
+ id: NonEmptyStringSchema
5359
+ }).strict().optional(),
5360
+ /** The agent the panel is shown for; must be the responding agent of an anchored channel. */
5361
+ agentId: AgentIdSchema.optional(),
4372
5362
  method: NonEmptyStringSchema,
4373
5363
  input: JsonValueSchema.optional()
4374
5364
  }).strict(),
@@ -4405,16 +5395,26 @@ const HostApiContracts = {
4405
5395
  params: agentExtensionParam,
4406
5396
  request: z.object({
4407
5397
  revisionId: ExtensionRevisionIdSchema,
4408
- permissionApproval: z.object({ permissionDigest: z.string().regex(/^[a-f0-9]{64}$/u) }).strict().optional()
5398
+ /** Approval of the agent-layer capabilities. */
5399
+ permissionApproval: PermissionApprovalSchema.optional(),
5400
+ /** Approval of the host layer when enabling also installs or switches the extension on this machine. */
5401
+ hostPermissionApproval: PermissionApprovalSchema.optional()
4409
5402
  }).strict(),
4410
- response: z.object({ activation: z.object({
4411
- agentId: AgentIdSchema,
4412
- extensionId: ExtensionIdSchema,
4413
- extensionRevisionId: ExtensionRevisionIdSchema,
4414
- config: JsonValueSchema,
4415
- configuredSecrets: z.array(z.string()).optional(),
4416
- activatedAt: z.number().int().safe().nonnegative()
4417
- }).strict() }).strict(),
5403
+ /**
5404
+ * The committed Activation, or — while the agent is still replying — `pending` with the accepted request; it then
5405
+ * takes effect at the agent's next safe gap and its progress appears in the snapshot's `activationTransitions`.
5406
+ */
5407
+ response: z.object({
5408
+ activation: z.object({
5409
+ agentId: AgentIdSchema,
5410
+ extensionId: ExtensionIdSchema,
5411
+ extensionRevisionId: ExtensionRevisionIdSchema,
5412
+ config: JsonValueSchema,
5413
+ configuredSecrets: z.array(z.string()).optional(),
5414
+ activatedAt: z.number().int().safe().nonnegative()
5415
+ }).strict().optional(),
5416
+ pending: ExtensionActivationTransitionSchema.optional()
5417
+ }).strict().refine((value) => value.activation === void 0 !== (value.pending === void 0), "启用结果必须二选一。"),
4418
5418
  error: HostApiErrorSchema
4419
5419
  }),
4420
5420
  deactivateExtension: defineContract({
@@ -4423,7 +5423,11 @@ const HostApiContracts = {
4423
5423
  path: "/api/agents/:agentId/extensions/:extensionId/activation",
4424
5424
  params: agentExtensionParam,
4425
5425
  request: NoRequestBodySchema,
4426
- response: z.object({ disabled: z.literal(true) }).strict(),
5426
+ /** `pending` is present when the agent is still replying; the Activation is removed at its next safe gap. */
5427
+ response: z.object({
5428
+ disabled: z.literal(true),
5429
+ pending: ExtensionActivationTransitionSchema.optional()
5430
+ }).strict(),
4427
5431
  error: HostApiErrorSchema
4428
5432
  }),
4429
5433
  updateExtensionActivationConfig: defineContract({
@@ -4448,8 +5452,15 @@ const HostApiContracts = {
4448
5452
  method: "PUT",
4449
5453
  path: "/api/extensions/:extensionId/installation/config",
4450
5454
  params: extensionParam,
4451
- request: z.object({ config: JsonValueSchema }).strict(),
4452
- response: z.object({ config: JsonValueSchema }).strict(),
5455
+ request: z.object({
5456
+ config: JsonValueSchema,
5457
+ /** Write-only credential drafts keyed by secret field; an absent or empty draft keeps the stored one. */
5458
+ secrets: z.record(z.string(), z.string().max(8192)).optional()
5459
+ }).strict(),
5460
+ response: z.object({
5461
+ config: JsonValueSchema,
5462
+ configuredSecrets: z.array(z.string()).optional()
5463
+ }).strict(),
4453
5464
  error: HostApiErrorSchema
4454
5465
  }),
4455
5466
  installHostExtension: defineContract({
@@ -4460,7 +5471,10 @@ const HostApiContracts = {
4460
5471
  params: extensionParam,
4461
5472
  request: z.object({
4462
5473
  revisionId: ExtensionRevisionIdSchema,
4463
- permissionApproval: z.object({ permissionDigest: z.string().regex(/^[a-f0-9]{64}$/u) }).strict().optional()
5474
+ /** Approval of the host layer (browser permissions and `permissions.host`). */
5475
+ permissionApproval: PermissionApprovalSchema.optional(),
5476
+ /** Approval of expanded agent-layer capabilities for the agents that move to this Revision. */
5477
+ agentPermissionApproval: PermissionApprovalSchema.optional()
4464
5478
  }).strict(),
4465
5479
  response: z.object({ installation: z.object({
4466
5480
  extensionId: ExtensionIdSchema,
@@ -4689,6 +5703,6 @@ function buildHostApiPath(name, input) {
4689
5703
  return buildValidatedHostApiPath(HostApiContracts[name], input);
4690
5704
  }
4691
5705
  //#endregion
4692
- export { ACTIVITY_MAX_BUCKETS, ACTIVITY_MAX_WINDOW_MS, ACTIVITY_MIN_BUCKET_MS, ADAPTER_PANEL_ANCHORS, AGENT_PANEL_ANCHORS, ActivityQuerySchema, AdapterActivityKeySchema, AdmissionIdSchema, AgentAppearanceSchema, AgentIdSchema, AgentRevisionChangedFieldSchema, AgentRevisionHistorySchema, AgentRevisionIdSchema, AssetIdSchema, AttentionItemSchema, AttentionListSchema, AuthoringAttemptIdSchema, AuthoringTaskIdSchema, CHANNEL_UNREAD_COUNT_CAP, COMMUNITY_OFFICIAL_HANDLE, COMMUNITY_REVIEW_DIMENSIONS, COMMUNITY_REVIEW_DIMENSION_LABELS, COMMUNITY_REVIEW_STATUSES, CONFIG_SCHEMA_MAX_BYTES, ChannelActivitySeriesSchema, ChannelActivitySummarySchema, ChannelEventIdSchema, ChannelFactSseDataSchema, ChannelFactSseItemSchema, ChannelIdSchema, ChannelMemberIdSchema, ChannelPendingContextSchema, ChannelRuntimeCacheSampleSchema, ChannelRuntimeCacheSchema, ChannelRuntimeOccupancySchema, ChannelRuntimePerformanceSampleSchema, ChannelRuntimePerformanceSchema, ChannelRuntimePhaseSchema, ChannelRuntimeProjectionSchema, ChannelRuntimeSseDataSchema, ChannelRuntimeStepSchema, ChannelRuntimeToolSchema, ChannelRuntimeTurnSchema, ChannelRuntimeUsageSchema, ClientNotificationFeedResponseSchema, ClientNotificationSchema, CommunityAccountSchema, CommunityEndpointSchema, CommunityEnvironmentSchema, CommunityExtensionDetailSchema, CommunityExtensionSummarySchema, CommunityGradeSchema, CommunityInstalledItemSchema, CommunityInstalledSchema, CommunityMyExtensionSchema, CommunityPermissionItemSchema, 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_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_SDK_LEVEL, EXTENSION_STORAGE_DEFAULT_QUOTA_BYTES, EXTENSION_STORAGE_MAX_QUOTA_BYTES, EXTENSION_STORAGE_SCOPES, EpisodeHandoffIdSchema, EpisodeIdSchema, ExtensionCapabilitiesSchema, ExtensionConfigDeclarationSchema, ExtensionContextContributionSchema, ExtensionDeclaredJobSchema, ExtensionIdSchema, ExtensionImportInspectionSchema, ExtensionInboundHookCapabilitySchema, ExtensionJobsCapabilitySchema, ExtensionLlmCapabilitySchema, ExtensionMcpCapabilitySchema, ExtensionMcpServerNameSchema, ExtensionMcpServerSchema, ExtensionMcpValueSchema, ExtensionNetworkCapabilitySchema, ExtensionNetworkDomainSchema, ExtensionPanelAnchorSchema, ExtensionPanelDeclarationSchema, ExtensionPlatformCapabilitySchema, ExtensionRequiresSchema, ExtensionRevisionIdSchema, ExtensionStorageCapabilitySchema, ExtensionStorageScopeSchema, ExtensionUiContributionsSchema, HOST_UI_KIT_COMPONENT_NAMES, HostApiContracts, HostApiErrorSchema, HostConnectionEventSchema, HostIconNameSchema, 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, LlmProviderViewSchema, LogicalMessageIdSchema, MANAGEMENT_PAIR_PROOF_PREFIX, ManagementChallengeResponseSchema, ManagementDeviceEnrollmentRequestSchema, ManagementDeviceEnrollmentResponseSchema, ManagementDeviceIdSchema, ManagementDeviceViewSchema, ManagementSessionRequestSchema, ManagementSessionResponseSchema, McpServerFormSchema, MessagePartSchema, MessagePartsSchema, MessageRendererContributionSchema, NonEmptyMessagePartsSchema, NotificationEventKeySchema, NotificationSettingsViewSchema, OutboundIntentIdSchema, 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, buildHostApiContractPath, buildHostApiPath, communityPublisherLabel, communityReviewLabel, configDescription, configFieldKind, configFields, configSchema, configSecretKeys, extensionCapabilitiesExpand, insecureHttpManagementPairProofMessage, managementPairProofMessage, mcpSecretFields, messagePartAssetId, messagePartAssetIds, messagePartsSearchText, normalizePromptDocument, parseConfigValue, parseJsonValue, parseMessageParts, promptDocumentFromText, promptDocumentPlainText, richPartContextText, summarizeExtensionCapabilities, validateConfigValue };
5706
+ 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, ChannelContextPolicySchema, ChannelContextPolicyViewSchema, ChannelEventIdSchema, ChannelFactSseDataSchema, ChannelFactSseItemSchema, ChannelIdSchema, ChannelMemberIdSchema, ChannelMemberNotesViewSchema, ChannelMemoryActivitySchema, ChannelPendingContextSchema, ChannelPromptViewSchema, ChannelRuntimeCacheSampleSchema, ChannelRuntimeCacheSchema, ChannelRuntimeContextSchema, ChannelRuntimeInputSchema, ChannelRuntimeOccupancySchema, ChannelRuntimePerformanceSampleSchema, ChannelRuntimePerformanceSchema, ChannelRuntimePhaseSchema, ChannelRuntimeProjectionSchema, ChannelRuntimeSseDataSchema, ChannelRuntimeStepSchema, ChannelRuntimeToolSchema, ChannelRuntimeTurnSchema, ChannelRuntimeUsageSchema, ClientNotificationFeedResponseSchema, ClientNotificationSchema, CodeRunAvailabilitySchema, 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, DEFAULT_CHANNEL_CONTEXT_POLICY, DEFAULT_MESSAGE_PACING, 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_ASSET_LIBRARY_DEFAULT_QUOTA_BYTES, EXTENSION_ASSET_LIBRARY_MAX_QUOTA_BYTES, EXTENSION_CONTEXT_DYNAMIC_MAX_CHARS, EXTENSION_CONTEXT_STATIC_MAX_CHARS, EXTENSION_DATA_HOOK_PERMISSIONS, EXTENSION_INBOUND_HOOK_MAX_TIMEOUT_MS, EXTENSION_INDEX_MAX_FILTERS, EXTENSION_INDEX_MAX_TEXT_FIELDS, EXTENSION_JOB_MAX_RUNTIME, EXTENSION_LLM_MAX_CALLS_PER_TURN, EXTENSION_LLM_MAX_OUTPUT_TOKENS, EXTENSION_MODEL_MAX_CALLS_PER_MINUTE, EXTENSION_PROVIDES, EXTENSION_SDK_BASE_LEVEL, EXTENSION_SDK_LEVEL, EXTENSION_SDK_RELEASES, EXTENSION_STORAGE_DEFAULT_QUOTA_BYTES, EXTENSION_STORAGE_MAX_QUOTA_BYTES, EXTENSION_STORAGE_SCOPES, EpisodeHandoffIdSchema, EpisodeIdSchema, ExtensionActivationTransitionSchema, ExtensionAssetLibraryCapabilitySchema, ExtensionAssetsCapabilitySchema, ExtensionCapabilitiesSchema, ExtensionConfigDeclarationSchema, ExtensionContextContributionSchema, ExtensionDeclaredJobSchema, ExtensionIdSchema, ExtensionImportInspectionSchema, ExtensionInboundHookCapabilitySchema, ExtensionIndexCapabilitySchema, ExtensionIndexCollectionSchema, ExtensionJobsCapabilitySchema, ExtensionLayeredConfigSchema, ExtensionLlmCapabilitySchema, ExtensionMcpCapabilitySchema, ExtensionMcpServerNameSchema, ExtensionMcpServerSchema, ExtensionMcpValueSchema, ExtensionModelsCapabilitySchema, 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, MessagePacingSchema, MessagePacingSettingsSchema, 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, ProductUpdateStatusSchema, PromptDocumentV1Schema, PromptSegmentSchema, RICH_EXTENSION_MAX_BYTES, RetrievalModeSchema, RetrievalStatusSchema, 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, extensionSdkVersion, hostLayerAsCapabilities, hostPageRailOrder, hostPermissionDeclaration, insecureHttpManagementPairProofMessage, managementPairProofMessage, mcpSecretFields, messagePartAssetId, messagePartAssetIds, messagePartsSearchText, normalizePromptDocument, parseConfigValue, parseJsonValue, parseMessageParts, promptDocumentFromText, promptDocumentPlainText, requiredExtensionSdkLevel, richPartContextText, summarizeExtensionCapabilities, validateConfigValue };
4693
5707
 
4694
5708
  //# sourceMappingURL=index.mjs.map