@nekro-nxt/contracts 0.3.0 → 0.5.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.
Files changed (37) hide show
  1. package/README.md +2 -0
  2. package/dist/index.mjs +2512 -78
  3. package/dist/index.mjs.map +1 -1
  4. package/lib/types/commands.d.ts +408 -0
  5. package/lib/types/commands.d.ts.map +1 -0
  6. package/lib/types/community-feedback-host.d.ts +442 -0
  7. package/lib/types/community-feedback-host.d.ts.map +1 -0
  8. package/lib/types/community-feedback.d.ts +1072 -0
  9. package/lib/types/community-feedback.d.ts.map +1 -0
  10. package/lib/types/community-personas.d.ts +4 -0
  11. package/lib/types/community-personas.d.ts.map +1 -1
  12. package/lib/types/community.d.ts +251 -13
  13. package/lib/types/community.d.ts.map +1 -1
  14. package/lib/types/domain.d.ts +33 -0
  15. package/lib/types/domain.d.ts.map +1 -1
  16. package/lib/types/extension-capabilities.d.ts +105 -3
  17. package/lib/types/extension-capabilities.d.ts.map +1 -1
  18. package/lib/types/extension-ui.d.ts +86 -7
  19. package/lib/types/extension-ui.d.ts.map +1 -1
  20. package/lib/types/host-api.d.ts +11109 -3874
  21. package/lib/types/host-api.d.ts.map +1 -1
  22. package/lib/types/index.d.ts +4 -0
  23. package/lib/types/index.d.ts.map +1 -1
  24. package/lib/types/logs.d.ts +355 -0
  25. package/lib/types/logs.d.ts.map +1 -0
  26. package/package.json +1 -1
  27. package/src/commands.ts +366 -0
  28. package/src/community-feedback-host.ts +121 -0
  29. package/src/community-feedback.ts +289 -0
  30. package/src/community.ts +56 -1
  31. package/src/domain.ts +59 -6
  32. package/src/extension-capabilities.ts +159 -8
  33. package/src/extension-ui.ts +40 -0
  34. package/src/host-api.ts +1540 -67
  35. package/src/index.ts +5 -0
  36. package/src/logs.ts +138 -0
  37. package/src/management-api.ts +1 -1
package/dist/index.mjs CHANGED
@@ -1,5 +1,28 @@
1
1
  import { z } from "zod";
2
2
  //#region src/domain.ts
3
+ /** Rendered send-tool result consumed by both the agent and the product detail view. */
4
+ const MessageDeliverySummarySchema = z.object({
5
+ status: z.enum([
6
+ "sent",
7
+ "partially-sent",
8
+ "failed",
9
+ "unknown"
10
+ ]),
11
+ issues: z.array(z.object({
12
+ status: z.enum(["failed", "unknown"]),
13
+ message: z.string().max(1e3),
14
+ kind: z.enum([
15
+ "transient",
16
+ "permanent",
17
+ "rate-limited",
18
+ "authentication",
19
+ "invalid"
20
+ ]).optional(),
21
+ action: z.string().max(120).optional(),
22
+ retcode: z.number().int().safe().optional()
23
+ }).strict()).max(20),
24
+ omittedIssues: z.number().int().nonnegative().optional()
25
+ }).strict();
3
26
  const brandedId = (prefix, brand) => z.string().regex(new RegExp(`^${prefix}_[0-9A-Za-z]+$`), `${brand} has an invalid format.`).brand(brand);
4
27
  const AgentIdSchema = brandedId("agt", "AgentId");
5
28
  const AgentRevisionIdSchema = brandedId("arev", "AgentRevisionId");
@@ -23,6 +46,7 @@ const DshPluginEntryIdSchema = brandedId("dse", "DshPluginEntryId");
23
46
  const HostUiPageInstanceIdSchema = brandedId("hup", "HostUiPageInstanceId");
24
47
  const AuthoringTaskIdSchema = brandedId("aut", "AuthoringTaskId");
25
48
  const AuthoringAttemptIdSchema = brandedId("aua", "AuthoringAttemptId");
49
+ const SubConversationIdSchema = brandedId("cnv", "SubConversationId");
26
50
  const AdapterActivityKeySchema = z.string().trim().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/u, "Adapter activity key has an invalid format.");
27
51
  const PromptTextSegmentSchema = z.object({
28
52
  type: z.literal("text"),
@@ -119,7 +143,12 @@ const MessagePartSchema = z.discriminatedUnion("type", [
119
143
  z.object({
120
144
  type: z.literal("image"),
121
145
  assetId: AssetIdSchema,
122
- alt: z.string().optional()
146
+ alt: z.string().optional(),
147
+ /**
148
+ * The platform reported the picture as a sticker. A hint only: a sticker dragged in from a desktop client and
149
+ * pictures from platforms without this signal arrive unmarked.
150
+ */
151
+ sticker: z.literal(true).optional()
123
152
  }).strict(),
124
153
  z.object({
125
154
  type: z.literal("file"),
@@ -151,17 +180,17 @@ const NonEmptyMessagePartsSchema = MessagePartsSchema.min(1);
151
180
  function parseMessageParts(input) {
152
181
  return MessagePartsSchema.parse(input);
153
182
  }
154
- const collectRichAssetIds = (value, into) => {
183
+ const collectRichAssetIds = (value, into, imagesOnly = false) => {
155
184
  if (value === null || value === void 0 || typeof value === "boolean" || typeof value === "number") return;
156
185
  if (typeof value === "string") return;
157
186
  if (Array.isArray(value)) {
158
- for (const item of value) collectRichAssetIds(item, into);
187
+ for (const item of value) collectRichAssetIds(item, into, imagesOnly);
159
188
  return;
160
189
  }
161
- for (const [key, child] of Object.entries(value)) if ((key === "imageAssetId" || key === "previewAssetId") && typeof child === "string") {
190
+ for (const [key, child] of Object.entries(value)) if ((key === "imageAssetId" || key === "previewAssetId" || !imagesOnly && (key === "audioAssetId" || key === "fileAssetId")) && typeof child === "string") {
162
191
  const parsed = AssetIdSchema.safeParse(child);
163
192
  if (parsed.success) into.push(parsed.data);
164
- } else collectRichAssetIds(child, into);
193
+ } else collectRichAssetIds(child, into, imagesOnly);
165
194
  };
166
195
  const messagePartAssetIds = (part) => {
167
196
  if (part.type === "image" || part.type === "file" || part.type === "audio") return [part.assetId];
@@ -172,6 +201,14 @@ const messagePartAssetIds = (part) => {
172
201
  return ids;
173
202
  };
174
203
  const messagePartAssetId = (part) => messagePartAssetIds(part)[0];
204
+ /** Only actual pictures enter visual context; forwarded files and recordings retain their own media kind. */
205
+ const messagePartImageAssetIds = (part) => {
206
+ if (part.type === "image") return [part.assetId];
207
+ if (part.type !== "rich") return [];
208
+ const ids = part.previewAssetId ? [part.previewAssetId] : [];
209
+ collectRichAssetIds(part.extension, ids, true);
210
+ return ids;
211
+ };
175
212
  const asJsonRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
176
213
  const richItemLine = (value) => {
177
214
  const item = asJsonRecord(value);
@@ -182,10 +219,14 @@ const richItemLine = (value) => {
182
219
  const cardSummary = typeof card?.["summary"] === "string" ? card["summary"] : typeof card?.["title"] === "string" ? card["title"] : void 0;
183
220
  const imageName = typeof item["imageName"] === "string" ? item["imageName"] : void 0;
184
221
  const imageText = typeof item["imageAssetId"] === "string" ? `[图片${imageName ? ` ${imageName}` : ""}]` : void 0;
222
+ const audioText = typeof item["audioAssetId"] === "string" ? `[语音 ${item["audioAssetId"]}]` : void 0;
223
+ const fileText = typeof item["fileAssetId"] === "string" ? `[${typeof item["fileMediaType"] === "string" && item["fileMediaType"].startsWith("video/") ? "视频" : "文件"} ${item["fileAssetId"]}${typeof item["fileName"] === "string" ? `:${item["fileName"]}` : ""}]` : void 0;
185
224
  const body = [
186
225
  text,
187
226
  cardSummary ? `[卡片] ${cardSummary}` : void 0,
188
- imageText
227
+ imageText,
228
+ audioText,
229
+ fileText
189
230
  ].filter((part) => Boolean(part && part.length > 0)).join(" ");
190
231
  if (!sender && !body) return void 0;
191
232
  return sender ? `${sender}:${body}` : body;
@@ -524,9 +565,47 @@ const configSchema = {
524
565
  /**
525
566
  * Host capability level this build implements. A Revision that declares `requires.sdk` above it is rejected at
526
567
  * 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).
568
+ * 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
569
+ * images, the search index and host-layer model calls. Level 9 adds the structured logger and explicit chat commands. Level 10 adds version lineage, the data version with its
570
+ * migration hook and administrator-only commands. Level 11 lists the pictures of an inbound message to inbound hooks.
571
+ */
572
+ const EXTENSION_SDK_LEVEL = 11;
573
+ /** Lineage, `dataVersion` and administrator-only commands need this level; packages that carry them declare it. */
574
+ const EXTENSION_GOVERNANCE_SDK_LEVEL = 10;
575
+ /**
576
+ * The first NekroNXT version of each capability level, so users read "needs NekroNXT 0.5.0" rather than a level
577
+ * number. Add the row for a new level in the change that raises EXTENSION_SDK_LEVEL; a test keeps the two in step.
528
578
  */
529
- const EXTENSION_SDK_LEVEL = 7;
579
+ const EXTENSION_SDK_RELEASES = [
580
+ {
581
+ level: 6,
582
+ version: "0.3.0"
583
+ },
584
+ {
585
+ level: 7,
586
+ version: "0.4.0"
587
+ },
588
+ {
589
+ level: 8,
590
+ version: "0.5.0"
591
+ },
592
+ {
593
+ level: 9,
594
+ version: "0.6.0"
595
+ },
596
+ {
597
+ level: 10,
598
+ version: "0.6.0"
599
+ },
600
+ {
601
+ level: 11,
602
+ version: "0.6.0"
603
+ }
604
+ ];
605
+ /** The oldest NekroNXT version that supports `level`; undefined for a level no release supports yet. */
606
+ const extensionSdkVersion = (level) => EXTENSION_SDK_RELEASES.find((release) => release.level >= level)?.version;
607
+ /** Manifest V7 itself; extensions that use nothing newer need this level. */
608
+ const EXTENSION_SDK_BASE_LEVEL = 7;
530
609
  const ExtensionRequiresSchema = z.object({ sdk: z.number().int().min(1).max(1e3) }).strict();
531
610
  /** `api.example.com` or `*.example.com` (subdomains only); lower-case DNS labels, no scheme, port or path. */
532
611
  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 +682,45 @@ const ExtensionPlatformCapabilitySchema = z.object({
603
682
  /** Adapters whose raw API passthrough the extension may call. */
604
683
  raw: z.array(AdapterKeySchema).max(8).default([])
605
684
  }).strict();
685
+ const EXTENSION_ASSET_LIBRARY_DEFAULT_QUOTA_BYTES = 2 * 1024 * 1024 * 1024;
686
+ const EXTENSION_ASSET_LIBRARY_MAX_QUOTA_BYTES = 32 * 1024 * 1024 * 1024;
687
+ const ExtensionAssetLibraryCapabilitySchema = z.object({ quotaBytes: z.number().int().min(1024 * 1024).max(EXTENSION_ASSET_LIBRARY_MAX_QUOTA_BYTES).optional() }).strict();
688
+ /**
689
+ * `write` creates Assets in the current channel; `library` keeps Assets in the extension's own library so they can be
690
+ * used in any channel later.
691
+ */
692
+ const ExtensionAssetsCapabilitySchema = z.object({
693
+ write: z.literal(true).optional(),
694
+ library: ExtensionAssetLibraryCapabilitySchema.optional()
695
+ }).strict().refine((value) => value.write !== void 0 || value.library !== void 0, "assets 至少声明 write 或 library。");
696
+ const IndexNameSchema = z.string().trim().regex(/^[a-z][a-z0-9_]{0,31}$/u, "索引、字段和过滤项名称只能使用小写字母、数字和下划线,以字母开头。");
697
+ const EXTENSION_INDEX_MAX_TEXT_FIELDS = 4;
698
+ const EXTENSION_INDEX_MAX_FILTERS = 4;
699
+ /**
700
+ * One searchable collection. Text fields are matched by keywords (and vectors when the Host has them enabled); weights
701
+ * rank keyword matches. Filter fields hold short keyword values, possibly several per document.
702
+ */
703
+ const ExtensionIndexCollectionSchema = z.object({
704
+ name: IndexNameSchema,
705
+ fields: z.array(z.object({
706
+ name: IndexNameSchema,
707
+ weight: z.number().min(.1).max(10).default(1)
708
+ }).strict()).min(1).max(4),
709
+ filters: z.array(IndexNameSchema).max(4).default([])
710
+ }).strict().superRefine((value, context) => {
711
+ const names = [...value.fields.map(({ name }) => name), ...value.filters];
712
+ if (new Set(names).size !== names.length) context.addIssue({
713
+ code: "custom",
714
+ message: "同一索引里的字段与过滤项不能重名。"
715
+ });
716
+ });
717
+ const ExtensionIndexCapabilitySchema = z.object({ collections: z.array(ExtensionIndexCollectionSchema).min(1).max(4).refine((value) => new Set(value.map(({ name }) => name)).size === value.length, "索引名称不能重复。") }).strict();
718
+ const EXTENSION_MODEL_MAX_CALLS_PER_MINUTE = 120;
719
+ /** Calls to a model the user picks from the Host's configured models, with images allowed; host layer only. */
720
+ const ExtensionModelsCapabilitySchema = z.object({
721
+ maxCallsPerMinute: z.number().int().min(1).max(120),
722
+ maxOutputTokens: z.number().int().min(64).max(EXTENSION_LLM_MAX_OUTPUT_TOKENS)
723
+ }).strict();
606
724
  /** A header or environment value: literal text, or the current value of a `meta.role: 'secret'` config field. */
607
725
  const ExtensionMcpValueSchema = z.union([z.string().max(4096), z.object({ secret: z.string().trim().min(1).max(64) }).strict()]);
608
726
  /** Becomes the model-facing tool prefix `mcp__<name>__`. */
@@ -663,7 +781,10 @@ const mcpTarget = (server) => server.transport === "stdio" ? JSON.stringify([
663
781
  const ExtensionCapabilitiesSchema = z.object({
664
782
  network: ExtensionNetworkCapabilitySchema.optional(),
665
783
  storage: ExtensionStorageCapabilitySchema.optional(),
666
- assets: z.object({ write: z.literal(true) }).strict().optional(),
784
+ assets: ExtensionAssetsCapabilitySchema.optional(),
785
+ index: ExtensionIndexCapabilitySchema.optional(),
786
+ /** Host layer only; the agent layer uses `llm`, which runs on the agent's own model. */
787
+ models: ExtensionModelsCapabilitySchema.optional(),
667
788
  history: z.object({ read: z.literal(true) }).strict().optional(),
668
789
  inboundHook: ExtensionInboundHookCapabilitySchema.optional(),
669
790
  jobs: ExtensionJobsCapabilitySchema.optional(),
@@ -678,7 +799,12 @@ const ExtensionCapabilitiesSchema = z.object({
678
799
  */
679
800
  const HostLayerCapabilitiesSchema = z.object({
680
801
  network: ExtensionNetworkCapabilitySchema.optional(),
681
- storage: z.object({ quotaBytes: z.number().int().min(1024).max(EXTENSION_STORAGE_MAX_QUOTA_BYTES).optional() }).strict().optional()
802
+ storage: z.object({ quotaBytes: z.number().int().min(1024).max(EXTENSION_STORAGE_MAX_QUOTA_BYTES).optional() }).strict().optional(),
803
+ /** The same library agent attachments use; the host instance lists and imports into it. */
804
+ assets: z.object({ library: ExtensionAssetLibraryCapabilitySchema }).strict().optional(),
805
+ /** The same collections agent attachments declare; pages search and maintain them. */
806
+ index: ExtensionIndexCapabilitySchema.optional(),
807
+ models: ExtensionModelsCapabilitySchema.optional()
682
808
  }).strict();
683
809
  /** Host-layer capabilities in the agent-capability shape, so digests, expansion and summaries share one implementation. */
684
810
  const hostLayerAsCapabilities = (host) => host === void 0 || Object.keys(host).length === 0 ? void 0 : {
@@ -686,7 +812,10 @@ const hostLayerAsCapabilities = (host) => host === void 0 || Object.keys(host).l
686
812
  ...host.storage === void 0 ? {} : { storage: {
687
813
  scopes: ["shared"],
688
814
  ...host.storage.quotaBytes === void 0 ? {} : { quotaBytes: host.storage.quotaBytes }
689
- } }
815
+ } },
816
+ ...host.assets === void 0 ? {} : { assets: { library: host.assets.library } },
817
+ ...host.index === void 0 ? {} : { index: host.index },
818
+ ...host.models === void 0 ? {} : { models: host.models }
690
819
  };
691
820
  const NETWORK_MODE_RANK = {
692
821
  domains: 0,
@@ -710,7 +839,9 @@ const extensionCapabilitiesExpand = (previous, next) => {
710
839
  if (next === void 0) return false;
711
840
  if (networkExpands(previous?.network, next.network)) return true;
712
841
  if (next.storage?.scopes.some((scope) => !(previous?.storage?.scopes ?? []).includes(scope))) return true;
713
- if (next.assets !== void 0 && previous?.assets === void 0) return true;
842
+ if (next.assets?.write !== void 0 && previous?.assets?.write === void 0) return true;
843
+ if (next.assets?.library !== void 0 && previous?.assets?.library === void 0) return true;
844
+ if (next.models !== void 0 && (previous?.models === void 0 || next.models.maxCallsPerMinute > previous.models.maxCallsPerMinute || next.models.maxOutputTokens > previous.models.maxOutputTokens)) return true;
714
845
  if (next.history !== void 0 && previous?.history === void 0) return true;
715
846
  const platformKey = ({ adapter, action }) => `${adapter}:${action}`;
716
847
  const previousActions = new Set((previous?.platform?.actions ?? []).map(platformKey));
@@ -725,6 +856,7 @@ const extensionCapabilitiesExpand = (previous, next) => {
725
856
  if (next.llm !== void 0 && (previous?.llm === void 0 || next.llm.maxCallsPerTurn > previous.llm.maxCallsPerTurn || next.llm.maxOutputTokens > previous.llm.maxOutputTokens)) return true;
726
857
  return false;
727
858
  };
859
+ const formatLibraryQuota = (bytes) => bytes >= 1024 * 1024 * 1024 ? `${+(bytes / 1024 / 1024 / 1024).toFixed(1)} GB` : `${Math.round(bytes / 1024 / 1024)} MB`;
728
860
  /**
729
861
  * User-facing summary of declared capabilities, in a stable order, for approval and inspection pages. `layer: 'host'`
730
862
  * phrases host-layer capabilities (passed through {@link hostLayerAsCapabilities}) for the host instance.
@@ -764,11 +896,29 @@ const summarizeExtensionCapabilities = (capabilities, options = {}) => {
764
896
  label: shared ? "保存数据,并在启用它的智能体之间共享" : "为这个智能体保存数据"
765
897
  });
766
898
  }
767
- if (capabilities.assets !== void 0) items.push({
899
+ if (capabilities.assets?.write !== void 0) items.push({
768
900
  key: "assets",
769
901
  risk: "normal",
770
902
  label: "在当前频道生成图片或文件"
771
903
  });
904
+ if (capabilities.assets?.library !== void 0) items.push({
905
+ key: "assets.library",
906
+ risk: "sensitive",
907
+ label: "把频道里的图片收进扩展资源库,之后可以在其他频道使用",
908
+ detail: `最多 ${formatLibraryQuota(capabilities.assets.library.quotaBytes ?? 2147483648)}`
909
+ });
910
+ if (capabilities.index !== void 0) items.push({
911
+ key: "index",
912
+ risk: "normal",
913
+ label: "建立可搜索的索引",
914
+ detail: capabilities.index.collections.map(({ name }) => name).join("、")
915
+ });
916
+ if (capabilities.models !== void 0) items.push({
917
+ key: "models",
918
+ risk: "sensitive",
919
+ label: "使用本机已配置的模型,可以发送图片",
920
+ detail: `每分钟最多 ${capabilities.models.maxCallsPerMinute} 次,计入所选模型的用量`
921
+ });
772
922
  if (capabilities.history !== void 0) items.push({
773
923
  key: "history",
774
924
  risk: "normal",
@@ -1014,7 +1164,21 @@ const ExtensionPermissionsSchema = z.object({
1014
1164
  networkOrigins: z.array(HostUiNetworkOriginSchema).max(32).default([]),
1015
1165
  host: HostLayerCapabilitiesSchema.optional(),
1016
1166
  agent: ExtensionCapabilitiesSchema.optional()
1017
- }).strict().superRefine(checkBrowserPermissions);
1167
+ }).strict().superRefine(checkBrowserPermissions).superRefine((value, context) => {
1168
+ if (value.agent?.models !== void 0) context.addIssue({
1169
+ code: "custom",
1170
+ path: ["agent", "models"],
1171
+ message: "models 只能在 permissions.host 中声明;智能体层使用 llm 调用智能体自己的模型。"
1172
+ });
1173
+ for (const collection of value.agent?.index?.collections ?? []) {
1174
+ const host = value.host?.index?.collections.find(({ name }) => name === collection.name);
1175
+ if (host !== void 0 && JSON.stringify(host) !== JSON.stringify(collection)) context.addIssue({
1176
+ code: "custom",
1177
+ path: ["agent", "index"],
1178
+ message: `索引 ${collection.name} 在 permissions.host 与 permissions.agent 中的定义不一致。`
1179
+ });
1180
+ }
1181
+ });
1018
1182
  const EMPTY_EXTENSION_PERMISSIONS = {
1019
1183
  permissions: [],
1020
1184
  networkOrigins: []
@@ -1206,6 +1370,447 @@ const EXTENSION_DATA_HOOK_PERMISSIONS = {
1206
1370
  useConnection: "connections.read",
1207
1371
  useChannelRuntime: "runtime.read"
1208
1372
  };
1373
+ /**
1374
+ * The capability level a set of permissions needs: Manifest V7 itself, or the level that introduced the newest
1375
+ * capability it declares. Packaging and import compare it with `requires.sdk`, so an extension cannot claim a level
1376
+ * too old for what it uses.
1377
+ */
1378
+ const requiredExtensionSdkLevel = (permissions) => {
1379
+ const level8 = [
1380
+ permissions?.host?.assets === void 0 ? void 0 : "扩展资源库",
1381
+ permissions?.agent?.assets?.library === void 0 ? void 0 : "扩展资源库",
1382
+ permissions?.host?.index === void 0 && permissions?.agent?.index === void 0 ? void 0 : "检索索引",
1383
+ permissions?.host?.models === void 0 ? void 0 : "本机层模型调用"
1384
+ ].filter((name) => name !== void 0);
1385
+ return level8.length > 0 ? {
1386
+ level: 8,
1387
+ capabilities: [...new Set(level8)]
1388
+ } : {
1389
+ level: 7,
1390
+ capabilities: []
1391
+ };
1392
+ };
1393
+ //#endregion
1394
+ //#region src/commands.ts
1395
+ const COMMAND_DEFAULT_TIMEOUT_SECONDS = 60;
1396
+ const COMMAND_MAX_TIMEOUT_SECONDS = 600;
1397
+ /**
1398
+ * Who may run a command. `channel-admin` is granted per channel; `admin` is an instance administrator (the signed-in
1399
+ * console or a platform account listed in Settings → Administrators) and also holds every channel's `channel-admin`.
1400
+ */
1401
+ const CommandPermissionSchema = z.enum([
1402
+ "public",
1403
+ "channel-admin",
1404
+ "admin"
1405
+ ]);
1406
+ const nameSchema = z.string().min(1).max(64).regex(/^[\p{L}\p{N}_-]+$/u);
1407
+ const scalarSchema = z.union([
1408
+ z.string(),
1409
+ z.number().finite(),
1410
+ z.boolean()
1411
+ ]);
1412
+ const CommandParameterSchema = z.object({
1413
+ name: nameSchema,
1414
+ description: z.string().max(500).optional(),
1415
+ kind: z.enum(["positional", "option"]),
1416
+ type: z.enum([
1417
+ "string",
1418
+ "number",
1419
+ "integer",
1420
+ "boolean"
1421
+ ]),
1422
+ required: z.boolean().optional(),
1423
+ default: scalarSchema.optional(),
1424
+ choices: z.array(scalarSchema).min(1).max(100).optional(),
1425
+ min: z.number().finite().optional(),
1426
+ max: z.number().finite().optional()
1427
+ }).strict();
1428
+ const CommandDefinitionSchema = z.object({
1429
+ name: nameSchema,
1430
+ aliases: z.array(nameSchema).max(16).default([]),
1431
+ description: z.string().min(1).max(1e3),
1432
+ parameters: z.array(CommandParameterSchema).max(32).default([]),
1433
+ examples: z.array(z.string().max(2e3)).max(16).default([]),
1434
+ minimumPermission: CommandPermissionSchema.default("public"),
1435
+ enabledByDefault: z.boolean().default(true),
1436
+ /**
1437
+ * Where the result goes when an administrator runs the command from the console (Web or Desktop) in an external
1438
+ * channel. `local` (default) shows it in the console only; `channel` also sends it through the bot account, and
1439
+ * the console labels the command accordingly. Platform-originated commands always reply in their conversation.
1440
+ */
1441
+ consoleReply: z.enum(["local", "channel"]).default("local"),
1442
+ /**
1443
+ * How long an extension handler may run before it is cancelled and recorded as timed out, so a stuck handler
1444
+ * cannot hold the channel's command queue. Built-in commands ignore it.
1445
+ */
1446
+ timeoutSeconds: z.number().int().min(1).max(600).default(60)
1447
+ }).strict().superRefine((definition, ctx) => {
1448
+ const names = [definition.name, ...definition.aliases];
1449
+ if (new Set(names).size !== names.length) ctx.addIssue({
1450
+ code: "custom",
1451
+ message: "命令名称和别名不能重复。"
1452
+ });
1453
+ if (new Set(definition.parameters.map((p) => p.name)).size !== definition.parameters.length) ctx.addIssue({
1454
+ code: "custom",
1455
+ message: "参数名称不能重复。"
1456
+ });
1457
+ let optional = false;
1458
+ for (const p of definition.parameters) {
1459
+ if (p.min !== void 0 && p.max !== void 0 && p.min > p.max) ctx.addIssue({
1460
+ code: "custom",
1461
+ message: `参数 ${p.name} 的范围无效。`
1462
+ });
1463
+ if (p.kind === "positional") {
1464
+ if (optional && p.required) ctx.addIssue({
1465
+ code: "custom",
1466
+ message: "必填位置参数必须在可选参数之前。"
1467
+ });
1468
+ if (!p.required || p.default !== void 0) optional = true;
1469
+ }
1470
+ if (p.default !== void 0) try {
1471
+ if (validateValue(p, String(p.default)) !== p.default) throw new Error("默认值类型不匹配。");
1472
+ } catch {
1473
+ ctx.addIssue({
1474
+ code: "custom",
1475
+ message: `参数 ${p.name} 的默认值无效。`
1476
+ });
1477
+ }
1478
+ }
1479
+ });
1480
+ const CommandPolicySchema = z.object({
1481
+ enabled: z.boolean().optional(),
1482
+ permission: CommandPermissionSchema.optional()
1483
+ }).strict();
1484
+ const CommandExecutionIdentitySchema = z.object({
1485
+ source: z.enum(["web", "platform"]),
1486
+ connectionId: ConnectionIdSchema.optional(),
1487
+ platformUserId: z.string().optional(),
1488
+ displayName: z.string(),
1489
+ viewerId: z.string().optional()
1490
+ }).strict();
1491
+ const CommandResultSchema = z.object({
1492
+ parts: z.array(MessagePartSchema).min(1).max(32).refine((parts) => parts.every((p) => [
1493
+ "text",
1494
+ "image",
1495
+ "file"
1496
+ ].includes(p.type)), "命令结果仅支持文本、图片和文件。"),
1497
+ summary: z.string().max(2e3).optional()
1498
+ }).strict();
1499
+ /** An execution may send a few progress replies before its final result. */
1500
+ const COMMAND_MAX_PROGRESS_REPLIES = 5;
1501
+ const CommandReplySchema = z.object({
1502
+ /** Position within the execution; the final result always has the highest ordinal. */
1503
+ ordinal: z.number().int().nonnegative(),
1504
+ kind: z.enum(["progress", "final"]),
1505
+ parts: CommandResultSchema.shape.parts,
1506
+ /** Set once the reply has an Outbound; absent with `error` means planning failed. */
1507
+ intentId: OutboundIntentIdSchema.optional(),
1508
+ error: z.string().optional()
1509
+ }).strict();
1510
+ const CommandExecutionRecordSchema = z.object({
1511
+ id: z.string().min(1),
1512
+ channelId: ChannelIdSchema,
1513
+ source: z.enum(["web", "platform"]),
1514
+ requestId: z.string().min(1).max(200),
1515
+ eventId: ChannelEventIdSchema.optional(),
1516
+ rawText: z.string(),
1517
+ identity: CommandExecutionIdentitySchema,
1518
+ commandName: z.string().optional(),
1519
+ commandVersion: z.string().optional(),
1520
+ extensionRevisionId: ExtensionRevisionIdSchema.optional(),
1521
+ agentId: AgentIdSchema.optional(),
1522
+ agentRevisionId: AgentRevisionIdSchema.optional(),
1523
+ status: z.enum([
1524
+ "pending",
1525
+ "running",
1526
+ "succeeded",
1527
+ "failed",
1528
+ "uncertain"
1529
+ ]),
1530
+ result: CommandResultSchema.optional(),
1531
+ error: z.string().optional(),
1532
+ /** Replies in send order. A platform command's replies go to its conversation; see `replyLocal`. */
1533
+ replies: z.array(CommandReplySchema).max(6).default([]),
1534
+ /** No reply is sent on purpose (unauthorized or unknown platform command, or console-local result). */
1535
+ replySuppressed: z.boolean().optional(),
1536
+ /** The result was kept in the console on purpose and never sent to the platform. */
1537
+ replyLocal: z.boolean().optional(),
1538
+ createdAt: z.number().int().nonnegative(),
1539
+ completedAt: z.number().int().nonnegative().optional()
1540
+ }).strict();
1541
+ /** Replies that still need an Outbound or a recorded failure. */
1542
+ const undeliveredCommandReplies = (record) => record.replySuppressed === true ? [] : record.replies.filter((reply) => reply.intentId === void 0 && reply.error === void 0);
1543
+ const CommandCatalogEntrySchema = z.object({
1544
+ definition: CommandDefinitionSchema,
1545
+ fullName: z.string(),
1546
+ source: z.string(),
1547
+ extensionRevisionId: ExtensionRevisionIdSchema.optional(),
1548
+ enabled: z.boolean(),
1549
+ permission: CommandPermissionSchema,
1550
+ usage: z.string(),
1551
+ available: z.boolean(),
1552
+ unavailableReason: z.string().optional(),
1553
+ globalPolicy: CommandPolicySchema.optional(),
1554
+ channelPolicy: CommandPolicySchema.optional()
1555
+ }).strict();
1556
+ /** Shell-like quoting without evaluation or interpolation. */
1557
+ function tokenizeCommand(text) {
1558
+ const tokens = [];
1559
+ let value = "", quote = "", escaped = false, started = false;
1560
+ for (const char of text) {
1561
+ if (escaped) {
1562
+ value += char;
1563
+ escaped = false;
1564
+ started = true;
1565
+ continue;
1566
+ }
1567
+ if (char === "\\") {
1568
+ escaped = true;
1569
+ started = true;
1570
+ continue;
1571
+ }
1572
+ if (quote) {
1573
+ if (char === quote) quote = "";
1574
+ else value += char;
1575
+ continue;
1576
+ }
1577
+ if (char === "\"" || char === "'") {
1578
+ quote = char;
1579
+ started = true;
1580
+ continue;
1581
+ }
1582
+ if (/\s/u.test(char)) {
1583
+ if (started) tokens.push(value);
1584
+ value = "";
1585
+ started = false;
1586
+ continue;
1587
+ }
1588
+ value += char;
1589
+ started = true;
1590
+ }
1591
+ if (escaped || quote) throw new Error("引号或转义未闭合。");
1592
+ if (started) tokens.push(value);
1593
+ return tokens;
1594
+ }
1595
+ function validateValue(p, raw) {
1596
+ let value = raw;
1597
+ if (p.type === "boolean") {
1598
+ if (!["true", "false"].includes(raw)) throw new Error(`参数 ${p.name} 必须为 true 或 false。`);
1599
+ value = raw === "true";
1600
+ } else if (p.type !== "string") {
1601
+ value = Number(raw);
1602
+ if (raw.trim() === "" || !Number.isFinite(value) || p.type === "integer" && !Number.isSafeInteger(value)) throw new Error(`参数 ${p.name} 必须为${p.type === "integer" ? "整数" : "数字"}。`);
1603
+ }
1604
+ const size = typeof value === "string" ? [...value].length : typeof value === "number" ? value : void 0;
1605
+ if (size !== void 0 && (p.min !== void 0 && size < p.min || p.max !== void 0 && size > p.max)) throw new Error(`参数 ${p.name} 超出允许范围。`);
1606
+ if (p.choices !== void 0 && !p.choices.includes(value)) throw new Error(`参数 ${p.name} 必须为:${p.choices.join("、")}。`);
1607
+ return value;
1608
+ }
1609
+ function parseCommandArguments(definition, tokens) {
1610
+ const args = /* @__PURE__ */ new Map();
1611
+ const positions = definition.parameters.filter((p) => p.kind === "positional");
1612
+ let index = 0, options = true;
1613
+ for (let i = 0; i < tokens.length; i++) {
1614
+ const token = tokens[i];
1615
+ if (options && token === "--") {
1616
+ options = false;
1617
+ continue;
1618
+ }
1619
+ let p, raw = token;
1620
+ if (options && token.startsWith("--")) {
1621
+ const equal = token.indexOf("=");
1622
+ const key = token.slice(2, equal < 0 ? void 0 : equal);
1623
+ p = definition.parameters.find((p) => p.kind === "option" && p.name === key);
1624
+ if (!p) throw new Error(`未知选项:--${key}`);
1625
+ if (equal >= 0) raw = token.slice(equal + 1);
1626
+ else if (p.type === "boolean" && (tokens[i + 1] === void 0 || !["true", "false"].includes(tokens[i + 1]))) raw = "true";
1627
+ else {
1628
+ const next = tokens[++i];
1629
+ if (next === void 0 || next.startsWith("--")) throw new Error(`选项 --${key} 缺少值。`);
1630
+ raw = next;
1631
+ }
1632
+ } else {
1633
+ p = positions[index++];
1634
+ if (!p) throw new Error(`多余参数:${token}`);
1635
+ }
1636
+ if (args.has(p.name)) throw new Error(`重复参数:${p.name}`);
1637
+ args.set(p.name, validateValue(p, raw));
1638
+ }
1639
+ for (const p of definition.parameters) {
1640
+ if (args.has(p.name)) continue;
1641
+ if (p.default !== void 0) args.set(p.name, p.default);
1642
+ else if (p.required) throw new Error(`缺少参数:${p.kind === "option" ? "--" : ""}${p.name}`);
1643
+ }
1644
+ return Object.fromEntries(args);
1645
+ }
1646
+ function commandUsage(definition, name = definition.name) {
1647
+ return "/" + name + definition.parameters.map((p) => {
1648
+ const value = p.kind === "option" ? `--${p.name} ${p.type === "boolean" ? "[true|false]" : `<${p.name}>`}` : `<${p.name}>`;
1649
+ return " " + (p.required ? value : `[${value}]`);
1650
+ }).join("");
1651
+ }
1652
+ function recognizeCommand(parts, botMemberId, options = {}) {
1653
+ let input = parts;
1654
+ while (input.length > 1 && input[0]?.type === "text" && input[0].text.trim() === "") input = input.slice(1);
1655
+ let addressed = options.addressed === true;
1656
+ let mentionPart = false;
1657
+ if (input[0]?.type === "mention") {
1658
+ if (botMemberId === void 0 || input[0].memberId !== botMemberId) return { kind: "chat" };
1659
+ input = input.slice(1);
1660
+ addressed = true;
1661
+ mentionPart = true;
1662
+ }
1663
+ if (options.requireMention === true && !addressed) return { kind: "chat" };
1664
+ if (input.length === 0 || input.some((p) => p.type !== "text")) return { kind: "chat" };
1665
+ let text = input.map((p) => p.type === "text" ? p.text : "").join("").trimStart();
1666
+ if (options.addressed === true && !mentionPart) text = text.replace(/^@\S+\s+/u, "");
1667
+ if (text.startsWith("//")) return {
1668
+ kind: "escaped",
1669
+ parts: [{
1670
+ type: "text",
1671
+ text: text.slice(1)
1672
+ }]
1673
+ };
1674
+ if (!text.startsWith("/")) return { kind: "chat" };
1675
+ return {
1676
+ kind: "command",
1677
+ text
1678
+ };
1679
+ }
1680
+ /** The command name a recognized text invokes (`/name args` → `name`). */
1681
+ const commandNameOf = (text) => /^\/(\S*)/u.exec(text.trimStart())?.[1] ?? "";
1682
+ //#endregion
1683
+ //#region src/logs.ts
1684
+ /** Log summaries are labels; leave structured diagnostics and stacks untouched. */
1685
+ function formatLogMessage(message) {
1686
+ return message.trimEnd().replace(/[。.]$/u, "");
1687
+ }
1688
+ const hostLogLevelSchema = z.enum([
1689
+ "debug",
1690
+ "info",
1691
+ "warn",
1692
+ "error"
1693
+ ]);
1694
+ const hostLogSourceKindSchema = z.enum([
1695
+ "system",
1696
+ "dsh-plugin",
1697
+ "extension",
1698
+ "connection",
1699
+ "unknown"
1700
+ ]);
1701
+ const hostLogSourceSchema = z.object({
1702
+ kind: hostLogSourceKindSchema,
1703
+ id: z.string().min(1).max(512),
1704
+ name: z.string().min(1).max(512),
1705
+ version: z.string().max(512).optional(),
1706
+ component: z.string().max(512).optional()
1707
+ }).strict();
1708
+ const hostLogScopeSchema = z.object({
1709
+ extensionId: z.string().max(512).optional(),
1710
+ revisionId: z.string().max(512).optional(),
1711
+ connectionId: z.string().max(512).optional(),
1712
+ agentId: z.string().max(512).optional(),
1713
+ channelId: z.string().max(512).optional(),
1714
+ sessionId: z.string().max(512).optional(),
1715
+ episodeId: z.string().max(512).optional(),
1716
+ operationId: z.string().max(512).optional()
1717
+ }).strict();
1718
+ const hostLogEntrySchema = z.object({
1719
+ id: z.string(),
1720
+ sequence: z.number().int().nonnegative(),
1721
+ timestamp: z.iso.datetime(),
1722
+ runId: z.string(),
1723
+ level: hostLogLevelSchema,
1724
+ message: z.string(),
1725
+ source: hostLogSourceSchema,
1726
+ scope: hostLogScopeSchema.optional(),
1727
+ details: z.json().optional(),
1728
+ code: z.string().optional(),
1729
+ redacted: z.boolean(),
1730
+ truncated: z.boolean()
1731
+ }).strict();
1732
+ const hostLogQuerySchema = z.object({
1733
+ levels: z.array(hostLogLevelSchema).max(4).optional(),
1734
+ sourceKinds: z.array(hostLogSourceKindSchema).max(5).optional(),
1735
+ sourceIds: z.array(z.string().max(512)).max(100).optional(),
1736
+ sources: z.array(hostLogSourceSchema.pick({
1737
+ kind: true,
1738
+ id: true
1739
+ })).max(100).optional(),
1740
+ scope: hostLogScopeSchema.optional(),
1741
+ keyword: z.string().max(1e3).optional(),
1742
+ from: z.iso.datetime().optional(),
1743
+ to: z.iso.datetime().optional(),
1744
+ olderCursor: z.string().max(128).optional(),
1745
+ afterCursor: z.string().max(128).optional(),
1746
+ headCursor: z.string().max(128).optional(),
1747
+ limit: z.number().int().min(1).max(500).optional()
1748
+ }).strict();
1749
+ const hostLogPageSchema = z.object({
1750
+ entries: z.array(hostLogEntrySchema),
1751
+ olderCursor: z.string().nullable(),
1752
+ headCursor: z.string(),
1753
+ hasMore: z.boolean(),
1754
+ gap: z.enum(["expired", "reset"]).optional()
1755
+ }).strict();
1756
+ const hostLogSettingsSchema = z.object({
1757
+ retentionDays: z.number().int().min(1).max(30),
1758
+ maxSizeMiB: z.number().int().min(64).max(2048),
1759
+ revision: z.number().int().nonnegative()
1760
+ }).strict();
1761
+ const hostLogSettingsUpdateSchema = hostLogSettingsSchema;
1762
+ const hostLogDebugRequestSchema = z.object({
1763
+ source: hostLogSourceSchema.pick({
1764
+ kind: true,
1765
+ id: true
1766
+ }).optional(),
1767
+ durationMinutes: z.union([
1768
+ z.literal(5),
1769
+ z.literal(15),
1770
+ z.literal(30)
1771
+ ]).default(15)
1772
+ }).strict();
1773
+ const hostLogDebugLeaseSchema = hostLogDebugRequestSchema.extend({
1774
+ id: z.string(),
1775
+ expiresAt: z.iso.datetime()
1776
+ });
1777
+ const hostLogStatusSchema = z.object({
1778
+ state: z.enum([
1779
+ "ready",
1780
+ "degraded",
1781
+ "closed"
1782
+ ]),
1783
+ runId: z.string(),
1784
+ headCursor: z.string(),
1785
+ bytes: z.number().nonnegative(),
1786
+ count: z.number().int().nonnegative(),
1787
+ oldestTimestamp: z.iso.datetime().nullable(),
1788
+ newestTimestamp: z.iso.datetime().nullable(),
1789
+ queuedBytes: z.number().nonnegative(),
1790
+ droppedCount: z.number().int().nonnegative(),
1791
+ debugLeases: z.array(hostLogDebugLeaseSchema),
1792
+ error: z.string().optional()
1793
+ }).strict();
1794
+ const hostLogStreamEventSchema = z.discriminatedUnion("type", [
1795
+ z.object({
1796
+ type: z.literal("entries"),
1797
+ entries: z.array(hostLogEntrySchema),
1798
+ cursor: z.string()
1799
+ }),
1800
+ z.object({
1801
+ type: z.literal("gap"),
1802
+ reason: z.enum([
1803
+ "expired",
1804
+ "reset",
1805
+ "overflow"
1806
+ ]),
1807
+ cursor: z.string()
1808
+ }),
1809
+ z.object({
1810
+ type: z.literal("status"),
1811
+ status: hostLogStatusSchema
1812
+ })
1813
+ ]);
1209
1814
  //#endregion
1210
1815
  //#region src/runtime-compatibility.ts
1211
1816
  const RuntimeCompatibilityDiagnosticSchema = z.object({
@@ -1330,7 +1935,7 @@ const ClientNotificationSchema = z.object({
1330
1935
  title: z.string().trim().min(1).max(80),
1331
1936
  body: z.string().trim().min(1).max(240),
1332
1937
  occurredAt: z.number().int().nonnegative(),
1333
- route: z.string().regex(/^\/(?:(?:live|channels|agents|workshop|wiring|settings|apps|work|connections|users|extensions)(?:\/[^?#]*)?)?$/u).optional()
1938
+ route: z.string().regex(/^\/(?:(?:live|channels|agents|workshop|wiring|settings|community|apps|work|connections|users|extensions)(?:\/[^?#]*)?)?$/u).optional()
1334
1939
  }).strict();
1335
1940
  const MANAGEMENT_PAIR_PROOF_PREFIX = "nxt-management-pair-v1";
1336
1941
  const managementPairProofMessage = (input) => [
@@ -1470,6 +2075,8 @@ const CommunityExtensionSortSchema = z.enum([
1470
2075
  ]);
1471
2076
  const CommunityReleaseIdSchema = z.string().regex(/^rel_[0-9A-Za-z]+$/u);
1472
2077
  const CommunityAccountSchema = z.object({
2078
+ /** Immutable community identity; absent when connected to a community predating feedback support. */
2079
+ id: z.string().min(1).max(100).optional(),
1473
2080
  handle: z.string().min(1).max(80),
1474
2081
  displayName: z.string().max(200),
1475
2082
  avatarUrl: z.string().url().nullable()
@@ -1480,6 +2087,7 @@ const CommunityEnvironmentSchema = z.enum([
1480
2087
  "development"
1481
2088
  ]);
1482
2089
  const CommunityStatusSchema = z.object({
2090
+ features: z.array(z.string()).optional(),
1483
2091
  communityUrl: z.string().url(),
1484
2092
  /** 社区自我声明的环境;连不上或旧版社区时为 null。 */
1485
2093
  environment: CommunityEnvironmentSchema.nullable(),
@@ -1509,7 +2117,13 @@ const CommunityReleaseSchema = z.object({
1509
2117
  packageSize: z.number().int().nonnegative(),
1510
2118
  requiresSdk: z.number().int().positive().nullable(),
1511
2119
  notes: z.string().max(2e3),
1512
- createdAt: z.number().int()
2120
+ createdAt: z.number().int(),
2121
+ /** Release number on the community line; absent from older communities. */
2122
+ number: z.number().int().positive().optional(),
2123
+ /** Revision the release contains and its lineage, so NekroNXT can tell fast-forward from divergence. */
2124
+ revisionId: ExtensionRevisionIdSchema.optional(),
2125
+ parentRevisionId: ExtensionRevisionIdSchema.nullable().optional(),
2126
+ ancestry: z.array(ExtensionRevisionIdSchema).max(256).optional()
1513
2127
  });
1514
2128
  /** 社区为官方扩展保留的发布者标识:官方扩展由多位官方成员维护,对外不显示个人账号。 */
1515
2129
  const COMMUNITY_OFFICIAL_HANDLE = "nekro-nxt";
@@ -1530,7 +2144,18 @@ const CommunityExtensionSummarySchema = z.object({
1530
2144
  latest: CommunityReleaseSchema.nullable(),
1531
2145
  downloads: z.number().int().nonnegative(),
1532
2146
  updatedAt: z.number().int(),
1533
- pageUrl: z.string().url()
2147
+ pageUrl: z.string().url(),
2148
+ /**
2149
+ * The extension and version this one is a branch of; null for an original line or an older community. Without a
2150
+ * displayName the origin is not public on the community.
2151
+ */
2152
+ branchOf: z.object({
2153
+ extensionId: ExtensionIdSchema,
2154
+ revisionId: ExtensionRevisionIdSchema.nullable(),
2155
+ displayName: z.string().max(200).nullable()
2156
+ }).nullable().optional(),
2157
+ /** Public branches made from this extension. */
2158
+ branchCount: z.number().int().nonnegative().optional()
1534
2159
  });
1535
2160
  const CommunityExtensionDetailSchema = CommunityExtensionSummarySchema.extend({
1536
2161
  description: z.string().max(2e4),
@@ -1590,6 +2215,45 @@ const CommunitySourceSchema = z.object({
1590
2215
  publisherHandle: z.string().min(1).max(80),
1591
2216
  installedAt: z.number().int().nonnegative()
1592
2217
  });
2218
+ /**
2219
+ * How this machine's current version of one extension relates to the community's newest public release, with the
2220
+ * action that relation calls for. `role` says whether this machine may publish the line or only follows it.
2221
+ */
2222
+ const CommunitySyncItemSchema = z.object({
2223
+ extensionId: ExtensionIdSchema,
2224
+ displayName: z.string(),
2225
+ communityUrl: z.string().url(),
2226
+ role: z.enum(["owner", "subscriber"]),
2227
+ currentRevisionId: ExtensionRevisionIdSchema,
2228
+ currentVersionLabel: z.string(),
2229
+ /** Release the current version is, when it is one. */
2230
+ currentRelease: z.object({
2231
+ id: CommunityReleaseIdSchema,
2232
+ number: z.number().int().positive().nullable()
2233
+ }).nullable(),
2234
+ /** `remote-ahead`: update; `local-ahead`: publish (owner) or local changes (subscriber); `diverged`: merge first. */
2235
+ status: z.enum([
2236
+ "same",
2237
+ "remote-ahead",
2238
+ "local-ahead",
2239
+ "diverged",
2240
+ "unrelated",
2241
+ "unknown"
2242
+ ]),
2243
+ found: z.boolean(),
2244
+ delisted: z.boolean(),
2245
+ delistedReason: z.string().nullable(),
2246
+ /** The release the current version came from was withdrawn by its author. */
2247
+ releaseWithdrawn: z.boolean(),
2248
+ latest: CommunityReleaseSchema.nullable(),
2249
+ /** The user chose to keep local changes over `latest`; it is not offered again. */
2250
+ dismissed: z.boolean(),
2251
+ addedPermissions: z.array(CommunityPermissionItemSchema)
2252
+ });
2253
+ const CommunitySyncSchema = z.object({
2254
+ checkedAt: z.number().int().nullable(),
2255
+ items: z.array(CommunitySyncItemSchema)
2256
+ });
1593
2257
  const CommunityInstalledItemSchema = z.object({
1594
2258
  extensionId: ExtensionIdSchema,
1595
2259
  displayName: z.string(),
@@ -1801,6 +2465,371 @@ const communityPersonaReviewLabel = (status) => {
1801
2465
  }
1802
2466
  };
1803
2467
  //#endregion
2468
+ //#region src/community-feedback.ts
2469
+ const COMMUNITY_FEEDBACK_STATUSES = [
2470
+ "new",
2471
+ "needs_info",
2472
+ "triaged",
2473
+ "planned",
2474
+ "fixed",
2475
+ "duplicate",
2476
+ "wontfix",
2477
+ "withdrawn"
2478
+ ];
2479
+ const CommunityFeedbackStatusSchema = z.enum(COMMUNITY_FEEDBACK_STATUSES);
2480
+ const COMMUNITY_FEEDBACK_STATUS_LABELS = {
2481
+ new: "新反馈",
2482
+ needs_info: "需要补充",
2483
+ triaged: "已确认",
2484
+ planned: "已计划",
2485
+ fixed: "已修复",
2486
+ duplicate: "重复",
2487
+ wontfix: "不处理",
2488
+ withdrawn: "已撤回"
2489
+ };
2490
+ const CommunityFeedbackKindSchema = z.enum([
2491
+ "bug",
2492
+ "suggestion",
2493
+ "question"
2494
+ ]);
2495
+ const CommunityFeedbackIdSchema = z.string().regex(/^fbk_[0-9a-z]{26}$/u).brand();
2496
+ const CommunityFeedbackRefSchema = z.string().regex(/^FB-[1-9][0-9]*$/u);
2497
+ const CommunityFeedbackTargetSchema = z.union([z.literal("nxt"), z.object({
2498
+ extensionId: z.string().regex(/^ext_[0-9A-Za-z]+$/u),
2499
+ version: z.string().max(120).optional()
2500
+ }).strict()]);
2501
+ const version = z.string().trim().min(1).max(120);
2502
+ const timestamp = z.number().int().nonnegative();
2503
+ const CommunityFeedbackExtensionDiagnosticSchema = z.object({
2504
+ extensionId: z.string().max(100),
2505
+ version,
2506
+ accessLevel: z.string().max(80).optional(),
2507
+ activation: z.enum(["host", "agent"]).optional()
2508
+ }).strict();
2509
+ const CommunityFeedbackDiagnosticEntrySchema = z.object({
2510
+ kind: z.enum([
2511
+ "compatibility",
2512
+ "extension",
2513
+ "connection"
2514
+ ]),
2515
+ summary: z.string().max(2e3),
2516
+ extensionId: z.string().max(100).optional()
2517
+ }).strict();
2518
+ /** An explicit allowlist: credentials, account grants and arbitrary host configuration never cross this boundary. */
2519
+ const CommunityFeedbackDiagnosticsSchema = z.object({
2520
+ nxtVersion: version.optional(),
2521
+ releaseChannel: z.enum([
2522
+ "stable",
2523
+ "preview",
2524
+ "development"
2525
+ ]).optional(),
2526
+ hostKind: z.enum(["desktop", "server"]).optional(),
2527
+ platform: z.string().max(80).optional(),
2528
+ arch: z.string().max(40).optional(),
2529
+ dshVersion: version.optional(),
2530
+ adapters: z.array(z.string().max(100)).max(64).optional(),
2531
+ agent: z.object({
2532
+ accessLevel: z.string().max(80),
2533
+ subagents: z.boolean(),
2534
+ fileTools: z.boolean(),
2535
+ webSearch: z.boolean(),
2536
+ dynamicCreation: z.boolean(),
2537
+ developmentShell: z.boolean(),
2538
+ unrestrictedFileAccess: z.boolean(),
2539
+ scheduledTasks: z.boolean(),
2540
+ codeRun: z.boolean(),
2541
+ commandNetwork: z.boolean(),
2542
+ communityFeedbackAuto: z.boolean()
2543
+ }).strict().optional(),
2544
+ extensions: z.array(CommunityFeedbackExtensionDiagnosticSchema).max(256).optional(),
2545
+ entries: z.array(CommunityFeedbackDiagnosticEntrySchema).max(32).optional(),
2546
+ instanceId: z.string().min(1).max(100).optional()
2547
+ }).strict();
2548
+ const CommunityFeedbackExcerptSchema = z.array(z.object({
2549
+ speaker: z.string().max(80),
2550
+ text: z.string().max(6e3)
2551
+ }).strict()).max(8);
2552
+ const CommunityFeedbackCreateSchema = z.object({
2553
+ clientRequestId: z.string().min(1).max(160),
2554
+ kind: CommunityFeedbackKindSchema,
2555
+ target: CommunityFeedbackTargetSchema,
2556
+ title: z.string().trim().min(1).max(120),
2557
+ body: z.string().trim().min(1).max(8e3),
2558
+ diagnostics: CommunityFeedbackDiagnosticsSchema.default({}),
2559
+ excerpt: CommunityFeedbackExcerptSchema.optional(),
2560
+ excerptSharedWithAuthor: z.boolean().default(false),
2561
+ source: z.enum([
2562
+ "assistant",
2563
+ "assistant_auto",
2564
+ "form",
2565
+ "web"
2566
+ ]),
2567
+ instanceId: z.string().min(1).max(100).optional()
2568
+ }).strict();
2569
+ const CommunityFeedbackMessageInputSchema = z.object({
2570
+ body: z.string().trim().min(1).max(4e3),
2571
+ audience: z.enum(["everyone", "staff"]).default("everyone")
2572
+ }).strict();
2573
+ const CommunityFeedbackSupplementSchema = z.object({
2574
+ diagnostics: CommunityFeedbackDiagnosticsSchema.optional(),
2575
+ excerpt: CommunityFeedbackExcerptSchema.optional(),
2576
+ excerptSharedWithAuthor: z.boolean().optional()
2577
+ }).strict();
2578
+ const CommunityFeedbackWithdrawSchema = z.object({ deleteText: z.boolean().default(false) }).strict();
2579
+ const CommunityFeedbackConfirmSchema = z.object({ clientVersion: version }).strict();
2580
+ const CommunityFeedbackReopenSchema = z.object({ note: z.string().trim().min(1).max(2e3) }).strict();
2581
+ const CommunityFeedbackAffectedSchema = z.object({
2582
+ diagnostics: CommunityFeedbackDiagnosticsSchema.optional(),
2583
+ nxtVersion: version.optional()
2584
+ }).strict();
2585
+ const CommunityFeedbackTransitionSchema = z.object({
2586
+ status: CommunityFeedbackStatusSchema,
2587
+ fixedIn: version.optional(),
2588
+ duplicateOf: CommunityFeedbackRefSchema.optional(),
2589
+ note: z.string().trim().max(2e3).optional()
2590
+ }).strict();
2591
+ const CommunityFeedbackLabelsSchema = z.object({
2592
+ labels: z.array(z.string().trim().min(1).max(40)).max(20),
2593
+ priority: z.enum([
2594
+ "low",
2595
+ "normal",
2596
+ "high"
2597
+ ]).nullable()
2598
+ }).strict();
2599
+ const CommunityFeedbackLinkSchema = z.object({ githubUrl: z.string().url().max(1e3).refine((value) => /^https:\/\/github\.com\/[^/]+\/[^/]+\/issues\/[1-9][0-9]*$/u.test(value)).nullable() }).strict();
2600
+ const CommunityFeedbackVisibilitySchema = z.object({ visibility: z.enum(["private", "public"]) }).strict();
2601
+ const CommunityFeedbackEventDataSchema = z.object({
2602
+ from: CommunityFeedbackStatusSchema.optional(),
2603
+ to: CommunityFeedbackStatusSchema.optional(),
2604
+ fixedIn: version.nullable().optional(),
2605
+ duplicateOf: CommunityFeedbackRefSchema.nullable().optional(),
2606
+ note: z.string().max(2e3).optional(),
2607
+ labels: z.array(z.string()).optional(),
2608
+ priority: z.enum([
2609
+ "low",
2610
+ "normal",
2611
+ "high"
2612
+ ]).nullable().optional(),
2613
+ visibility: z.enum(["private", "public"]).optional(),
2614
+ clientVersion: version.optional(),
2615
+ messageId: z.string().optional(),
2616
+ audience: z.enum(["everyone", "staff"]).optional(),
2617
+ deleteText: z.boolean().optional(),
2618
+ affected: z.boolean().optional()
2619
+ }).strict();
2620
+ const CommunityFeedbackEventSchema = z.object({
2621
+ seq: z.number().int().positive(),
2622
+ ref: CommunityFeedbackRefSchema,
2623
+ type: z.enum([
2624
+ "created",
2625
+ "message",
2626
+ "status_changed",
2627
+ "labeled",
2628
+ "priority_changed",
2629
+ "linked_issue",
2630
+ "duplicate_marked",
2631
+ "fixed_in_set",
2632
+ "visibility_changed",
2633
+ "affected_added",
2634
+ "withdrawn",
2635
+ "reopened",
2636
+ "supplemented",
2637
+ "fix_confirmed"
2638
+ ]),
2639
+ actorKind: z.enum([
2640
+ "user",
2641
+ "admin",
2642
+ "author",
2643
+ "token",
2644
+ "system"
2645
+ ]).optional(),
2646
+ actor: z.string().optional(),
2647
+ tokenId: z.string().optional(),
2648
+ data: CommunityFeedbackEventDataSchema,
2649
+ createdAt: timestamp,
2650
+ title: z.string().optional(),
2651
+ status: CommunityFeedbackStatusSchema.optional()
2652
+ });
2653
+ const CommunityFeedbackMessageSchema = z.object({
2654
+ id: z.string(),
2655
+ authorKind: z.enum([
2656
+ "user",
2657
+ "admin",
2658
+ "author",
2659
+ "system"
2660
+ ]),
2661
+ author: z.string().nullable(),
2662
+ audience: z.enum(["everyone", "staff"]),
2663
+ body: z.string(),
2664
+ createdAt: timestamp
2665
+ });
2666
+ const CommunityFeedbackSummarySchema = z.object({
2667
+ id: CommunityFeedbackIdSchema,
2668
+ ref: CommunityFeedbackRefSchema,
2669
+ title: z.string(),
2670
+ kind: CommunityFeedbackKindSchema.optional(),
2671
+ target: CommunityFeedbackTargetSchema.optional(),
2672
+ status: CommunityFeedbackStatusSchema,
2673
+ fixedIn: version.nullable(),
2674
+ affectedCount: z.number().int().nonnegative(),
2675
+ source: CommunityFeedbackCreateSchema.shape.source.optional(),
2676
+ confirmedCount: z.number().int().nonnegative().optional(),
2677
+ createdAt: timestamp.optional(),
2678
+ updatedAt: timestamp.optional()
2679
+ });
2680
+ /** Optional private fields are emitted only by the server's role-specific projection. */
2681
+ const CommunityFeedbackSchema = CommunityFeedbackSummarySchema.extend({
2682
+ access: z.enum([
2683
+ "owner",
2684
+ "admin",
2685
+ "author",
2686
+ "subscriber",
2687
+ "public"
2688
+ ]),
2689
+ body: z.string().optional(),
2690
+ diagnostics: CommunityFeedbackDiagnosticsSchema.optional(),
2691
+ excerpt: CommunityFeedbackExcerptSchema.nullable().optional(),
2692
+ excerptSharedWithAuthor: z.boolean().optional(),
2693
+ messages: z.array(CommunityFeedbackMessageSchema).optional(),
2694
+ events: z.array(CommunityFeedbackEventSchema).optional(),
2695
+ submitter: z.string().optional(),
2696
+ instanceId: z.string().nullable().optional(),
2697
+ priority: z.enum([
2698
+ "low",
2699
+ "normal",
2700
+ "high"
2701
+ ]).nullable().optional(),
2702
+ labels: z.array(z.string()).optional(),
2703
+ visibility: z.enum(["private", "public"]).optional(),
2704
+ duplicateOf: CommunityFeedbackRefSchema.nullable().optional(),
2705
+ githubUrl: z.string().nullable().optional(),
2706
+ closedAt: timestamp.nullable().optional(),
2707
+ purgedAt: timestamp.nullable().optional(),
2708
+ confirmed: z.boolean().default(false),
2709
+ affected: z.boolean().default(false),
2710
+ affectedDiagnostics: z.array(z.object({
2711
+ user: z.string(),
2712
+ diagnostics: CommunityFeedbackDiagnosticsSchema.nullable(),
2713
+ nxtVersion: version.nullable(),
2714
+ createdAt: timestamp
2715
+ })).optional()
2716
+ });
2717
+ const CommunityFeedbackListSchema = z.object({
2718
+ items: z.array(CommunityFeedbackSummarySchema),
2719
+ cursor: z.string().nullable()
2720
+ });
2721
+ const CommunityFeedbackChangesSchema = z.object({
2722
+ events: z.array(CommunityFeedbackEventSchema),
2723
+ cursor: z.number().int().nonnegative(),
2724
+ hasMore: z.boolean()
2725
+ });
2726
+ const CommunityFeedbackDigestSchema = z.object({
2727
+ since: timestamp,
2728
+ counts: z.object({
2729
+ status: z.record(CommunityFeedbackStatusSchema, z.number().int().nonnegative()),
2730
+ kind: z.record(CommunityFeedbackKindSchema, z.number().int().nonnegative()),
2731
+ target: z.record(z.enum(["nxt", "extension"]), z.number().int().nonnegative()),
2732
+ extensions: z.record(z.string(), z.number().int().nonnegative())
2733
+ }),
2734
+ newItems: z.array(CommunityFeedbackSummarySchema),
2735
+ awaitingReply: z.array(CommunityFeedbackSummarySchema),
2736
+ mostAffected: z.array(CommunityFeedbackSummarySchema),
2737
+ unconfirmedFixes: z.array(CommunityFeedbackSummarySchema),
2738
+ fixedCount: z.number().int().nonnegative()
2739
+ });
2740
+ //#endregion
2741
+ //#region src/community-feedback-host.ts
2742
+ const CommunityFeedbackDraftIdSchema = z.string().regex(/^fbd_[0-9A-Za-z]+$/u).brand();
2743
+ const CommunityFeedbackDraftStateSchema = z.enum([
2744
+ "awaiting",
2745
+ "sending",
2746
+ "sent",
2747
+ "failed",
2748
+ "discarded"
2749
+ ]);
2750
+ const CommunityFeedbackDraftSchema = z.object({
2751
+ id: CommunityFeedbackDraftIdSchema,
2752
+ communityUrl: z.string().url(),
2753
+ communityUserId: z.string().min(1).nullable(),
2754
+ agentId: AgentIdSchema.nullable(),
2755
+ channelId: ChannelIdSchema.nullable(),
2756
+ kind: CommunityFeedbackKindSchema,
2757
+ target: CommunityFeedbackTargetSchema,
2758
+ title: z.string().max(120),
2759
+ body: z.string().max(8e3),
2760
+ excerpt: CommunityFeedbackExcerptSchema.nullable(),
2761
+ excerptSharedWithAuthor: z.boolean(),
2762
+ diagnostics: CommunityFeedbackDiagnosticsSchema,
2763
+ state: CommunityFeedbackDraftStateSchema,
2764
+ requestedBy: z.string(),
2765
+ auto: z.boolean(),
2766
+ error: z.string().nullable(),
2767
+ createdAt: z.number().int().nonnegative(),
2768
+ updatedAt: z.number().int().nonnegative()
2769
+ }).strict();
2770
+ const CommunityFeedbackItemSchema = z.object({
2771
+ ref: CommunityFeedbackRefSchema,
2772
+ communityUrl: z.string().url(),
2773
+ communityUserId: z.string().min(1),
2774
+ channelId: ChannelIdSchema.nullable(),
2775
+ draftId: CommunityFeedbackDraftIdSchema.nullable(),
2776
+ title: z.string(),
2777
+ kind: CommunityFeedbackKindSchema.nullable(),
2778
+ target: CommunityFeedbackTargetSchema.nullable(),
2779
+ status: CommunityFeedbackStatusSchema,
2780
+ fixedIn: z.string().nullable(),
2781
+ unread: z.boolean(),
2782
+ lastEventSeq: z.number().int().nonnegative(),
2783
+ createdAt: z.number().int().nonnegative(),
2784
+ updatedAt: z.number().int().nonnegative()
2785
+ }).strict();
2786
+ const CommunityFeedbackDraftInputSchema = z.object({
2787
+ kind: CommunityFeedbackKindSchema,
2788
+ target: CommunityFeedbackTargetSchema,
2789
+ title: z.string().trim().min(1).max(120),
2790
+ body: z.string().trim().min(1).max(8e3),
2791
+ conversationRefs: z.array(LogicalMessageIdSchema).max(8).optional()
2792
+ }).strict();
2793
+ const CommunityFeedbackDraftUpdateSchema = z.object({
2794
+ title: z.string().trim().min(1).max(120),
2795
+ body: z.string().trim().min(1).max(8e3),
2796
+ includeExcerpt: z.boolean(),
2797
+ excerptSharedWithAuthor: z.boolean().default(false),
2798
+ expectedUpdatedAt: z.number().int().nonnegative()
2799
+ }).strict();
2800
+ const CommunityFeedbackSettingsSchema = z.object({
2801
+ enabled: z.boolean(),
2802
+ supported: z.boolean(),
2803
+ signedIn: z.boolean(),
2804
+ communityUrl: z.string().url(),
2805
+ communityUserId: z.string().nullable(),
2806
+ consentedAt: z.number().int().nonnegative().nullable()
2807
+ }).strict();
2808
+ const CommunityFeedbackSettingsUpdateSchema = z.object({
2809
+ enabled: z.boolean(),
2810
+ consent: z.boolean().default(false)
2811
+ }).strict();
2812
+ const CommunityFeedbackSnapshotSchema = z.object({
2813
+ enabled: z.boolean(),
2814
+ signedIn: z.boolean(),
2815
+ pendingDrafts: z.number().int().nonnegative(),
2816
+ unread: z.number().int().nonnegative()
2817
+ }).strict();
2818
+ const CommunityFeedbackLocalListSchema = z.object({
2819
+ drafts: z.array(CommunityFeedbackDraftSchema),
2820
+ items: z.array(CommunityFeedbackItemSchema),
2821
+ syncError: z.string().optional()
2822
+ }).strict();
2823
+ const CommunityFeedbackPayloadSchema = z.object({
2824
+ payload: CommunityFeedbackCreateSchema,
2825
+ redactions: z.array(z.string())
2826
+ }).strict();
2827
+ const CommunityFeedbackLastPayloadSchema = z.object({
2828
+ ref: CommunityFeedbackRefSchema,
2829
+ sentAt: z.number().int().nonnegative(),
2830
+ payload: CommunityFeedbackCreateSchema
2831
+ }).strict().nullable();
2832
+ //#endregion
1804
2833
  //#region src/host-api.ts
1805
2834
  const EmptyParamsSchema = z.object({}).strict();
1806
2835
  const NoRequestBodySchema = z.undefined();
@@ -1840,6 +2869,9 @@ const DynamicAttemptErrorSchema = z.object({
1840
2869
  ]),
1841
2870
  message: z.string(),
1842
2871
  stack: z.string().optional(),
2872
+ /** A render failure also names the contribution slot that failed and whether its frame gave up. */
2873
+ slot: NonEmptyStringSchema.optional(),
2874
+ abdicated: z.boolean().optional(),
1843
2875
  pluginId: DynamicIdSchema,
1844
2876
  packageId: DynamicIdSchema,
1845
2877
  pluginRunId: DynamicIdSchema
@@ -1864,7 +2896,8 @@ const AuthoringTaskStatusSchema = z.enum([
1864
2896
  "failed",
1865
2897
  "interrupted",
1866
2898
  "stopped",
1867
- "completed"
2899
+ "completed",
2900
+ "paused"
1868
2901
  ]);
1869
2902
  const AuthoringAttemptStateSchema = z.enum([
1870
2903
  "drafting",
@@ -1903,6 +2936,8 @@ const AuthoringAttemptSummarySchema = z.object({
1903
2936
  message: z.string(),
1904
2937
  repairable: z.boolean()
1905
2938
  }).strict().optional(),
2939
+ /** Verified without loading its interface, because no browser was available; the interface itself is unchecked. */
2940
+ uiUnverified: z.boolean().optional(),
1906
2941
  createdAt: z.number().int().nonnegative(),
1907
2942
  settledAt: z.number().int().nonnegative().optional()
1908
2943
  }).strict();
@@ -1914,6 +2949,15 @@ const AuthoringTaskSummarySchema = z.object({
1914
2949
  title: z.string(),
1915
2950
  requirementSummary: z.string(),
1916
2951
  status: AuthoringTaskStatusSchema,
2952
+ /** `create` builds a new extension; `revise` changes `targetExtensionId` starting from `baseRevisionId`. */
2953
+ kind: z.enum(["create", "revise"]).default("create"),
2954
+ targetExtensionId: ExtensionIdSchema.optional(),
2955
+ baseRevisionId: ExtensionRevisionIdSchema.optional(),
2956
+ referenceRevisionId: ExtensionRevisionIdSchema.optional(),
2957
+ /** Why the task is paused; it continues when the agent picks it up in a later conversation. */
2958
+ pausedReason: z.string().optional(),
2959
+ /** The conversation the task runs in is live, so its candidate can be previewed directly. */
2960
+ live: z.boolean().default(false),
1917
2961
  approvalPolicy: z.enum(["risk-stable", "fully-automatic"]),
1918
2962
  approvedRiskDigest: z.string().regex(/^[a-f0-9]{64}$/u).optional(),
1919
2963
  revision: z.number().int().positive(),
@@ -1972,6 +3016,19 @@ const ImageUnderstandingPolicyApiSchema = z.object({
1972
3016
  maxTokens: z.number().int().min(256).max(8192)
1973
3017
  }).strict()])
1974
3018
  }).strict();
3019
+ const CommandAccountServiceSchema = z.enum(["github"]);
3020
+ const CommandAccountUsageSchema = z.enum([
3021
+ "read",
3022
+ "issues",
3023
+ "pull-requests",
3024
+ "push"
3025
+ ]);
3026
+ const CommandAccountGrantSchema = z.object({
3027
+ service: CommandAccountServiceSchema,
3028
+ accountId: NonEmptyStringSchema.max(64),
3029
+ /** Told to the agent as guidance, not enforced; empty gives no hint. */
3030
+ usage: z.array(CommandAccountUsageSchema).max(4).default([])
3031
+ }).strict();
1975
3032
  const AgentCapabilitiesSchema = z.object({
1976
3033
  subagents: z.boolean(),
1977
3034
  fileTools: z.boolean(),
@@ -1980,10 +3037,28 @@ const AgentCapabilitiesSchema = z.object({
1980
3037
  developmentShell: z.boolean(),
1981
3038
  unrestrictedFileAccess: z.boolean(),
1982
3039
  /** Absent in older clients means on. */
1983
- scheduledTasks: z.boolean().default(true)
3040
+ scheduledTasks: z.boolean().default(true),
3041
+ /** Tools are called from one TypeScript program (`run_code`); takes effect only with `developmentShell`. */
3042
+ codeRun: z.boolean().default(false),
3043
+ /** Network for commands; absent in older clients means on. */
3044
+ commandNetwork: z.boolean().default(true),
3045
+ communityFeedbackAuto: z.boolean().default(false),
3046
+ /** Accounts this agent's commands may act as; absent in older clients means none. */
3047
+ commandAccounts: z.array(CommandAccountGrantSchema).max(8).default([]),
3048
+ /**
3049
+ * What the agent may do with extensions without the console: `manual` only develops and test-runs, `confirm` asks
3050
+ * an administrator in the channel for every step, `autonomous` takes ordinary steps that only affect itself.
3051
+ */
3052
+ extensionAutonomy: z.enum([
3053
+ "manual",
3054
+ "confirm",
3055
+ "autonomous"
3056
+ ]).default("manual"),
3057
+ /** Whose requests make the agent develop or change extensions: anyone in the channel, or administrators only. */
3058
+ extensionRequesters: z.enum(["everyone", "admins"]).default("everyone")
1984
3059
  }).strict();
1985
3060
  const DynamicClientApprovalPolicySchema = z.enum(["manual", "automatic"]);
1986
- const NotificationEventKeySchema = z.enum(["dynamic-client-approval-requested"]);
3061
+ const NotificationEventKeySchema = z.enum(["dynamic-client-approval-requested", "community-feedback-update"]);
1987
3062
  const NotificationSettingsViewSchema = z.object({
1988
3063
  revision: z.number().int().positive().optional(),
1989
3064
  system: z.object({ enabled: z.boolean() }).strict(),
@@ -1992,7 +3067,10 @@ const NotificationSettingsViewSchema = z.object({
1992
3067
  serverUrl: z.url(),
1993
3068
  deviceKeyConfigured: z.boolean()
1994
3069
  }).strict(),
1995
- events: z.record(NotificationEventKeySchema, z.boolean())
3070
+ events: z.object({
3071
+ "dynamic-client-approval-requested": z.boolean(),
3072
+ "community-feedback-update": z.boolean().default(true)
3073
+ }).strict()
1996
3074
  }).strict();
1997
3075
  const UpdateNotificationSettingsRequestSchema = z.object({
1998
3076
  expectedRevision: z.number().int().positive().optional(),
@@ -2003,7 +3081,10 @@ const UpdateNotificationSettingsRequestSchema = z.object({
2003
3081
  deviceKey: z.string().trim().min(1).max(2048).optional(),
2004
3082
  clearDeviceKey: z.boolean().optional()
2005
3083
  }).strict(),
2006
- events: z.record(NotificationEventKeySchema, z.boolean())
3084
+ events: z.object({
3085
+ "dynamic-client-approval-requested": z.boolean(),
3086
+ "community-feedback-update": z.boolean().optional()
3087
+ }).strict()
2007
3088
  }).strict().refine((value) => !(value.bark.deviceKey !== void 0 && value.bark.clearDeviceKey === true), {
2008
3089
  message: "不能同时更新并清除 Bark Device Key。",
2009
3090
  path: ["bark"]
@@ -2038,7 +3119,19 @@ const CreateAgentRequestSchema = AgentRevisionRequestContentSchema.extend({ capa
2038
3119
  const ReviseAgentRequestSchema = AgentRevisionRequestContentSchema.extend({ expectedCurrentRevisionId: AgentRevisionIdSchema }).superRefine((value, context) => {
2039
3120
  validatePersonaDocumentProjection(value, context);
2040
3121
  });
2041
- const UpdateAgentCapabilitiesRequestSchema = AgentCapabilitiesSchema.partial().extend({ scheduledTasks: z.boolean().optional() }).strict().refine((value) => Object.values(value).some((entry) => entry !== void 0), "至少提供一个能力。");
3122
+ const UpdateAgentCapabilitiesRequestSchema = AgentCapabilitiesSchema.partial().extend({
3123
+ scheduledTasks: z.boolean().optional(),
3124
+ codeRun: z.boolean().optional(),
3125
+ commandNetwork: z.boolean().optional(),
3126
+ communityFeedbackAuto: z.boolean().optional(),
3127
+ commandAccounts: z.array(CommandAccountGrantSchema).max(8).optional(),
3128
+ extensionAutonomy: z.enum([
3129
+ "manual",
3130
+ "confirm",
3131
+ "autonomous"
3132
+ ]).optional(),
3133
+ extensionRequesters: z.enum(["everyone", "admins"]).optional()
3134
+ }).strict().refine((value) => Object.values(value).some((entry) => entry !== void 0), "至少提供一个能力。");
2042
3135
  const TriggerPolicySchema = z.enum([
2043
3136
  "always",
2044
3137
  "mentioned-or-replied",
@@ -2063,7 +3156,8 @@ const SnapshotMessagePartSchema = z.discriminatedUnion("type", [
2063
3156
  z.object({
2064
3157
  type: z.literal("image"),
2065
3158
  assetId: AssetIdSchema,
2066
- alt: z.string().optional()
3159
+ alt: z.string().optional(),
3160
+ sticker: z.literal(true).optional()
2067
3161
  }).strict(),
2068
3162
  z.object({
2069
3163
  type: z.literal("file"),
@@ -2122,7 +3216,14 @@ const HostSnapshotMessageSchema = z.object({
2122
3216
  action: z.enum(["retry", "confirm-delivered"]),
2123
3217
  resolvedAt: z.number().int().safe().nonnegative()
2124
3218
  }).strict().optional(),
2125
- origin: z.enum(["admin-console"]).optional(),
3219
+ origin: z.enum([
3220
+ "admin-console",
3221
+ "command",
3222
+ "extension-notice"
3223
+ ]).optional(),
3224
+ command: CommandExecutionRecordSchema.optional(),
3225
+ /** A host notice about extension work: a request an administrator must confirm, or what an action did. */
3226
+ extensionNotice: z.object({ requestNumber: z.number().int().positive().optional() }).strict().optional(),
2126
3227
  /** What the agent's inbound hooks decided for this message, when anything differs from the default. */
2127
3228
  inboundHook: z.object({
2128
3229
  trigger: z.enum([
@@ -2192,7 +3293,9 @@ const PlatformUserListResponseSchema = z.object({
2192
3293
  }).strict(),
2193
3294
  activeChannelCount: z.number().int().nonnegative(),
2194
3295
  channelPreview: z.array(PlatformUserChannelPreviewSchema).max(3),
2195
- historicalOnly: z.boolean()
3296
+ historicalOnly: z.boolean(),
3297
+ /** Listed in Settings → Administrators. */
3298
+ administrator: z.boolean().default(false)
2196
3299
  }).strict()),
2197
3300
  facets: z.object({
2198
3301
  adapters: z.array(PlatformUserFacetAdapterSchema),
@@ -2225,7 +3328,7 @@ const ChannelRuntimeUsageSchema = z.object({
2225
3328
  cacheWriteTokens: z.number().int().nonnegative().optional(),
2226
3329
  reasoningTokens: z.number().int().nonnegative().optional()
2227
3330
  }).strict();
2228
- const ChannelRuntimeToolSchema = z.object({
3331
+ const channelRuntimeToolFields = {
2229
3332
  callId: NonEmptyStringSchema,
2230
3333
  name: NonEmptyStringSchema,
2231
3334
  displayName: NonEmptyStringSchema,
@@ -2244,7 +3347,14 @@ const ChannelRuntimeToolSchema = z.object({
2244
3347
  "unknown"
2245
3348
  ]).optional(),
2246
3349
  durationMs: z.number().int().nonnegative().optional()
2247
- }).strict();
3350
+ };
3351
+ const ChannelRuntimeToolSchema = z.object({
3352
+ ...channelRuntimeToolFields,
3353
+ /** Source of a `run_code` program. */
3354
+ code: z.string().optional(),
3355
+ /** Tools a `run_code` program called, in the order they started. */
3356
+ children: z.array(z.object(channelRuntimeToolFields).strict()).optional()
3357
+ }).strict();
2248
3358
  const ChannelRuntimeStepSchema = z.object({
2249
3359
  step: z.number().int().nonnegative(),
2250
3360
  tools: z.array(ChannelRuntimeToolSchema),
@@ -2309,7 +3419,9 @@ const ChannelRuntimeOccupancySchema = z.object({
2309
3419
  systemTokens: z.number().int().nonnegative(),
2310
3420
  toolsTokens: z.number().int().nonnegative(),
2311
3421
  messageTokens: z.number().int().nonnegative()
2312
- }).strict().optional()
3422
+ }).strict().optional(),
3423
+ /** Pictures in the conversation; their tokens are not in the breakdown, so they make up most of the rest. */
3424
+ imageCount: z.number().int().nonnegative().optional()
2313
3425
  }).strict();
2314
3426
  const ChannelRuntimeCacheSampleSchema = z.object({
2315
3427
  turn: z.number().int().nonnegative(),
@@ -2363,6 +3475,41 @@ const ChannelRuntimePerformanceSchema = z.object({
2363
3475
  samples: z.array(ChannelRuntimePerformanceSampleSchema)
2364
3476
  }).strict()
2365
3477
  }).strict();
3478
+ /** What the agent remembered or looked up, newest first; the admin sees it, the model does not. */
3479
+ const ChannelMemoryActivitySchema = z.discriminatedUnion("kind", [
3480
+ z.object({
3481
+ kind: z.literal("backlog-folded"),
3482
+ at: z.number().nonnegative().optional(),
3483
+ foldedCount: z.number().int().nonnegative(),
3484
+ shownCount: z.number().int().nonnegative(),
3485
+ foldedImageCount: z.number().int().nonnegative()
3486
+ }).strict(),
3487
+ z.object({
3488
+ kind: z.literal("history-search"),
3489
+ at: z.number().nonnegative().optional(),
3490
+ query: z.string(),
3491
+ hits: z.number().int().nonnegative(),
3492
+ sender: z.string().optional()
3493
+ }).strict(),
3494
+ z.object({
3495
+ kind: z.literal("notes-updated"),
3496
+ at: z.number().nonnegative().optional(),
3497
+ revision: z.number().int().nonnegative(),
3498
+ chars: z.number().int().nonnegative()
3499
+ }).strict(),
3500
+ z.object({
3501
+ kind: z.literal("member-notes-updated"),
3502
+ at: z.number().nonnegative().optional(),
3503
+ memberId: z.string(),
3504
+ name: z.string().optional(),
3505
+ chars: z.number().int().nonnegative()
3506
+ }).strict(),
3507
+ z.object({
3508
+ kind: z.literal("idle-review"),
3509
+ at: z.number().nonnegative().optional(),
3510
+ quietMinutes: z.number().int().nonnegative()
3511
+ }).strict()
3512
+ ]);
2366
3513
  const ChannelRuntimeProjectionSchema = z.object({
2367
3514
  channelId: ChannelIdSchema,
2368
3515
  agentId: AgentIdSchema.optional(),
@@ -2373,6 +3520,7 @@ const ChannelRuntimeProjectionSchema = z.object({
2373
3520
  occupancy: ChannelRuntimeOccupancySchema.optional(),
2374
3521
  cache: ChannelRuntimeCacheSchema.optional(),
2375
3522
  performance: ChannelRuntimePerformanceSchema.optional(),
3523
+ memory: z.array(ChannelMemoryActivitySchema).optional(),
2376
3524
  turns: z.array(ChannelRuntimeTurnSchema)
2377
3525
  }).strict();
2378
3526
  const ChannelRuntimeSseDataSchema = ChannelRuntimeProjectionSchema.extend({
@@ -2410,10 +3558,9 @@ const ChannelRuntimeContextSchema = z.object({
2410
3558
  toolCount: z.number().int().nonnegative()
2411
3559
  }).strict())
2412
3560
  }).strict();
2413
- /** A channel's own instructions for whoever answers it, with recent earlier versions to restore. */
2414
- const ChannelPromptViewSchema = z.object({
3561
+ const ChannelPromptPartSchema = z.object({
2415
3562
  document: PromptDocumentV1Schema,
2416
- /** The agent may not rewrite a locked prompt. */
3563
+ /** Notes only: the agent may not rewrite them. */
2417
3564
  locked: z.boolean(),
2418
3565
  /** 0 before the first save; send it back as `expectedRevision`. */
2419
3566
  revision: z.number().int().nonnegative(),
@@ -2427,6 +3574,178 @@ const ChannelPromptViewSchema = z.object({
2427
3574
  updatedAt: z.number().int().nonnegative()
2428
3575
  }).strict())
2429
3576
  }).strict();
3577
+ /**
3578
+ * What the agent answering a channel reads about it, each part with recent earlier versions to restore: the admin's
3579
+ * instructions (system prompt) and the agent's own notes (runtime context).
3580
+ */
3581
+ const ChannelPromptViewSchema = z.object({
3582
+ instructions: ChannelPromptPartSchema,
3583
+ notes: ChannelPromptPartSchema
3584
+ }).strict();
3585
+ /**
3586
+ * How much of a channel's unread backlog reaches the agent at once, and when it looks back on its own. Uncertain
3587
+ * trade-offs stay per channel: a busy meme group and a long tabletop session want different budgets.
3588
+ */
3589
+ const ChannelContextPolicySchema = z.object({
3590
+ /** Text characters of a backlog read message by message; older messages collapse into one line. 0: no limit. */
3591
+ backlogTextChars: z.number().int().nonnegative().max(1e6),
3592
+ /** Backlog images shown as pictures, newest first; the rest stay references the agent can open. */
3593
+ backlogImages: z.number().int().nonnegative().max(20),
3594
+ /** Quiet minutes after which the agent reviews the conversation and updates its notes. 0: off. */
3595
+ idleReviewMinutes: z.number().int().nonnegative().max(1440)
3596
+ }).strict();
3597
+ const DEFAULT_CHANNEL_CONTEXT_POLICY = Object.freeze({
3598
+ backlogTextChars: 4e4,
3599
+ backlogImages: 6,
3600
+ idleReviewMinutes: 45
3601
+ });
3602
+ const ChannelContextPolicyViewSchema = z.object({
3603
+ policy: ChannelContextPolicySchema,
3604
+ defaults: ChannelContextPolicySchema,
3605
+ /** False while the channel follows the defaults. */
3606
+ custom: z.boolean()
3607
+ }).strict();
3608
+ /** Whether a newer release exists on the build's own channel; development builds are never compared. */
3609
+ const ProductUpdateStatusSchema = z.object({
3610
+ channel: z.enum([
3611
+ "stable",
3612
+ "preview",
3613
+ "development"
3614
+ ]),
3615
+ currentVersion: z.string(),
3616
+ /** Short commit of a release build. */
3617
+ currentCommit: z.string().optional(),
3618
+ state: z.enum([
3619
+ "unknown",
3620
+ "up-to-date",
3621
+ "available",
3622
+ "failed",
3623
+ "unsupported"
3624
+ ]),
3625
+ latest: z.object({
3626
+ version: z.string(),
3627
+ commit: z.string().optional(),
3628
+ url: z.string().url(),
3629
+ publishedAt: z.number().int().nonnegative().optional()
3630
+ }).strict().optional(),
3631
+ checkedAt: z.number().int().nonnegative().optional(),
3632
+ error: z.string().optional(),
3633
+ autoCheck: z.boolean()
3634
+ }).strict();
3635
+ /** Pause between consecutive messages an agent sends to one channel; longer messages wait a little longer. */
3636
+ const MessagePacingSchema = z.enum([
3637
+ "off",
3638
+ "fast",
3639
+ "normal",
3640
+ "slow"
3641
+ ]);
3642
+ const DEFAULT_MESSAGE_PACING = "normal";
3643
+ const MessagePacingSettingsSchema = z.object({ pacing: MessagePacingSchema }).strict();
3644
+ /**
3645
+ * A conversation of its own under a channel's conversation (docs/NekroNxt界面交互模型.md §5.6): the agent opens one
3646
+ * for a separate piece of work, and the host opens scripted ones to check creation candidates. It has its own log
3647
+ * and context, and is shown under its channel.
3648
+ */
3649
+ const SubConversationSchema = z.object({
3650
+ id: SubConversationIdSchema,
3651
+ channelId: ChannelIdSchema,
3652
+ episodeId: EpisodeIdSchema,
3653
+ agentId: AgentIdSchema,
3654
+ title: z.string().min(1).max(200),
3655
+ /** `agent`: the agent opened it with a tool; `host`: NekroNXT opened it, such as to check a candidate. */
3656
+ openedBy: z.enum(["agent", "host"]),
3657
+ /** `model`: the agent's model talks in it; `script`: the host plays fixed tool calls. */
3658
+ driver: z.enum(["model", "script"]),
3659
+ status: z.enum(["open", "closed"]),
3660
+ closeReason: z.enum([
3661
+ "completed",
3662
+ "closed-by-agent",
3663
+ "closed-by-admin",
3664
+ "failed",
3665
+ "conversation-ended"
3666
+ ]).optional(),
3667
+ /** What it handed back to the channel's conversation when it ended. */
3668
+ summary: z.string().max(4e3).optional(),
3669
+ authoringTaskId: AuthoringTaskIdSchema.optional(),
3670
+ createdAt: z.number().int().nonnegative(),
3671
+ closedAt: z.number().int().nonnegative().optional()
3672
+ }).strict();
3673
+ /** How long ended sub-conversations are kept before they are cleaned up. */
3674
+ const SubConversationRetentionSchema = z.enum([
3675
+ "1d",
3676
+ "3d",
3677
+ "7d",
3678
+ "30d",
3679
+ "never"
3680
+ ]);
3681
+ const DEFAULT_SUB_CONVERSATION_RETENTION = "7d";
3682
+ const SubConversationSettingsSchema = z.object({ retention: SubConversationRetentionSchema }).strict();
3683
+ /** `keyword`: SQLite keyword search only; `builtin`: keywords fused with the built-in semantic model. */
3684
+ const RetrievalModeSchema = z.enum(["keyword", "builtin"]);
3685
+ /** Search used by extension indexes (表情包与扩展素材能力 §6.4). */
3686
+ const RetrievalStatusSchema = z.object({
3687
+ mode: RetrievalModeSchema,
3688
+ builtin: z.object({
3689
+ model: z.string(),
3690
+ /** False where no inference runtime is published for this system and processor. */
3691
+ supported: z.boolean(),
3692
+ downloadBytes: z.number().int().nonnegative(),
3693
+ install: z.discriminatedUnion("state", [
3694
+ z.object({ state: z.literal("not-installed") }).strict(),
3695
+ z.object({
3696
+ state: z.literal("downloading"),
3697
+ receivedBytes: z.number().int().nonnegative(),
3698
+ totalBytes: z.number().int().nonnegative()
3699
+ }).strict(),
3700
+ z.object({ state: z.literal("installed") }).strict(),
3701
+ z.object({
3702
+ state: z.literal("failed"),
3703
+ error: z.string()
3704
+ }).strict()
3705
+ ])
3706
+ }).strict(),
3707
+ vectors: z.object({
3708
+ documents: z.number().int().nonnegative(),
3709
+ embedded: z.number().int().nonnegative(),
3710
+ state: z.enum([
3711
+ "idle",
3712
+ "running",
3713
+ "ready"
3714
+ ]),
3715
+ error: z.string().optional()
3716
+ }).strict()
3717
+ }).strict();
3718
+ /** Where the Host keeps restore points it takes before an upgrade, or none. */
3719
+ const UpgradeBackupModeSchema = z.enum([
3720
+ "data",
3721
+ "directory",
3722
+ "off"
3723
+ ]);
3724
+ const UpgradeBackupSettingsSchema = z.object({
3725
+ mode: UpgradeBackupModeSchema,
3726
+ /** The chosen directory when `mode` is `directory`. */
3727
+ directory: z.string().nullable(),
3728
+ /** Set through the server's environment; the settings page cannot change it. */
3729
+ locked: z.boolean(),
3730
+ /** Restore points kept; older ones are removed after an upgrade succeeds. */
3731
+ keep: z.number().int().positive(),
3732
+ /** Restore points currently in the chosen place. */
3733
+ usage: z.object({
3734
+ count: z.number().int().nonnegative(),
3735
+ bytes: z.number().int().nonnegative()
3736
+ }).strict()
3737
+ }).strict();
3738
+ /** What the agent keeps about individual members of one channel; each note comes with that member's messages. */
3739
+ const ChannelMemberNotesViewSchema = z.object({
3740
+ notes: z.array(z.object({
3741
+ memberId: ChannelMemberIdSchema,
3742
+ displayName: z.string().optional(),
3743
+ text: z.string(),
3744
+ updatedBy: z.enum(["admin", "agent"]),
3745
+ updatedAt: z.number().int().nonnegative()
3746
+ }).strict()),
3747
+ maxChars: z.number().int().positive()
3748
+ }).strict();
2430
3749
  const AdapterConnectionCreationSchema = z.object({
2431
3750
  mode: z.enum(["schema-form", "qr-login"]),
2432
3751
  actionLabel: z.string().trim().min(1).optional(),
@@ -2455,7 +3774,8 @@ const AdapterConnectionDescriptorSchema = z.object({
2455
3774
  "internal",
2456
3775
  "direct",
2457
3776
  "group"
2458
- ])).optional()
3777
+ ])).optional(),
3778
+ directedAt: z.enum(["member", "message"]).optional()
2459
3779
  }).strict()),
2460
3780
  features: z.object({ processingFeedback: z.object({ channelKinds: z.array(z.enum(["direct", "group"])).min(1) }).strict().optional() }).strict(),
2461
3781
  diagnostics: z.object({
@@ -2526,7 +3846,9 @@ const AttentionItemSchema = z.object({
2526
3846
  "authoring-approval",
2527
3847
  "connection-unhealthy",
2528
3848
  "agent-model-unavailable",
2529
- "agent-vision-unavailable"
3849
+ "agent-vision-unavailable",
3850
+ "logs-unavailable",
3851
+ "community-feedback"
2530
3852
  ]),
2531
3853
  severity: z.enum([
2532
3854
  "critical",
@@ -2539,7 +3861,9 @@ const AttentionItemSchema = z.object({
2539
3861
  "channel",
2540
3862
  "authoring-task",
2541
3863
  "connection",
2542
- "agent"
3864
+ "agent",
3865
+ "logs",
3866
+ "community-feedback"
2543
3867
  ]),
2544
3868
  id: NonEmptyStringSchema
2545
3869
  }).strict(),
@@ -2558,7 +3882,9 @@ const AttentionItemSchema = z.object({
2558
3882
  "resolve-delivery",
2559
3883
  "open-authoring-task",
2560
3884
  "open-connection",
2561
- "open-agent"
3885
+ "open-agent",
3886
+ "open-logs",
3887
+ "open-community-feedback"
2562
3888
  ]),
2563
3889
  label: z.string().min(1).max(40)
2564
3890
  }).strict(),
@@ -2665,7 +3991,90 @@ const ScheduledTaskSchema = z.object({
2665
3991
  lastFiredAt: z.number().int().safe().optional(),
2666
3992
  createdAt: z.number().int().safe()
2667
3993
  }).strict();
3994
+ /** The Node that runs `run_code` programs, and the download the desktop app offers when there is none. */
3995
+ const CodeRunAvailabilitySchema = z.object({
3996
+ available: z.boolean(),
3997
+ source: z.enum([
3998
+ "host",
3999
+ "system",
4000
+ "downloaded"
4001
+ ]).optional(),
4002
+ version: z.string().optional(),
4003
+ download: z.object({
4004
+ version: z.string(),
4005
+ state: z.enum([
4006
+ "idle",
4007
+ "downloading",
4008
+ "failed"
4009
+ ]),
4010
+ receivedBytes: z.number().int().nonnegative().optional(),
4011
+ totalBytes: z.number().int().nonnegative().optional(),
4012
+ error: z.string().optional()
4013
+ }).strict().optional()
4014
+ }).strict();
4015
+ /** The GitHub CLI commands call: found on this machine, or downloaded by NekroNXT where it can. */
4016
+ const GithubCliAvailabilitySchema = CodeRunAvailabilitySchema;
4017
+ /** The optional headless Chromium that loads and checks creation candidates when no page is open. */
4018
+ const VerificationBrowserAvailabilitySchema = CodeRunAvailabilitySchema;
4019
+ /**
4020
+ * One account in the host's library. The library only keeps accounts; an account takes effect only for the agents
4021
+ * whose capabilities grant it, which `usedBy` lists.
4022
+ */
4023
+ const CommandAccountSchema = z.object({
4024
+ id: NonEmptyStringSchema.max(64),
4025
+ service: CommandAccountServiceSchema,
4026
+ /** The account name on the service. */
4027
+ login: NonEmptyStringSchema,
4028
+ source: z.enum(["token", "gh-login"]),
4029
+ /** Token scopes where the service reports them (classic tokens); absent for fine-grained tokens. */
4030
+ scopes: z.array(z.string()).optional(),
4031
+ createdAt: z.number().int().nonnegative(),
4032
+ usedBy: z.array(AgentIdSchema)
4033
+ }).strict();
4034
+ /** A login the local `gh` holds, offered as a quick way to add an account. */
4035
+ const LocalGithubLoginSchema = z.object({
4036
+ login: NonEmptyStringSchema,
4037
+ active: z.boolean()
4038
+ }).strict();
4039
+ const CommandAccountsViewSchema = z.object({
4040
+ accounts: z.array(CommandAccountSchema),
4041
+ /** Logins found in the local GitHub CLI; empty when it is missing or not logged in. */
4042
+ localLogins: z.array(LocalGithubLoginSchema)
4043
+ }).strict();
4044
+ const AddCommandAccountRequestSchema = z.discriminatedUnion("source", [z.object({
4045
+ source: z.literal("token"),
4046
+ service: CommandAccountServiceSchema,
4047
+ token: NonEmptyStringSchema.max(512)
4048
+ }).strict(), z.object({
4049
+ source: z.literal("gh-login"),
4050
+ service: CommandAccountServiceSchema,
4051
+ login: NonEmptyStringSchema.max(128)
4052
+ }).strict()]);
4053
+ /** An extension action an agent asked an administrator to confirm, or one it took on its own. */
4054
+ const ExtensionRequestSchema = z.object({
4055
+ number: z.number().int().positive(),
4056
+ kind: z.string(),
4057
+ agentId: AgentIdSchema,
4058
+ channelId: ChannelIdSchema.nullable(),
4059
+ extensionId: ExtensionIdSchema.nullable(),
4060
+ summary: z.string(),
4061
+ status: z.enum([
4062
+ "pending",
4063
+ "approved",
4064
+ "rejected",
4065
+ "expired",
4066
+ "completed",
4067
+ "failed"
4068
+ ]),
4069
+ autonomous: z.boolean(),
4070
+ resultMessage: z.string().nullable(),
4071
+ decidedBy: z.string().nullable(),
4072
+ createdAt: z.number().int().nonnegative(),
4073
+ expiresAt: z.number().int().nonnegative(),
4074
+ decidedAt: z.number().int().nonnegative().nullable()
4075
+ }).strict();
2668
4076
  const HostSnapshotSchema = z.object({
4077
+ communityFeedback: CommunityFeedbackSnapshotSchema.optional(),
2669
4078
  upgrade: HostUpgradeSummarySchema.optional(),
2670
4079
  cursor: HostSyncCursorSchema,
2671
4080
  diagnosticsSampledAt: z.number().int().nonnegative(),
@@ -2688,7 +4097,19 @@ const HostSnapshotSchema = z.object({
2688
4097
  }).strict()),
2689
4098
  capabilityAvailability: z.object({
2690
4099
  subagents: z.object({ available: z.boolean() }).strict(),
4100
+ /** Optional in older hosts, which never offer `run_code`. */
4101
+ codeRun: CodeRunAvailabilitySchema.optional(),
4102
+ /** Optional in older hosts, which never offer command accounts. */
4103
+ githubCli: GithubCliAvailabilitySchema.optional(),
4104
+ /** Optional in older hosts, which check candidates only in an open page. */
4105
+ verificationBrowser: VerificationBrowserAvailabilitySchema.optional(),
4106
+ /** What this host can confine for commands beyond file writes; optional in older hosts. */
4107
+ commandConfinement: z.object({
4108
+ readScope: z.boolean(),
4109
+ networkControl: z.boolean()
4110
+ }).strict().optional(),
2691
4111
  webSearch: z.object({
4112
+ unavailableReason: z.string().optional(),
2692
4113
  provider: z.literal("deepseek-official"),
2693
4114
  available: z.boolean(),
2694
4115
  credentialConfigured: z.boolean(),
@@ -2700,6 +4121,8 @@ const HostSnapshotSchema = z.object({
2700
4121
  }).strict(),
2701
4122
  connectionAdapters: z.array(AdapterConnectionDescriptorSchema),
2702
4123
  notificationSettings: NotificationSettingsViewSchema,
4124
+ /** Optional in older hosts, which have no account library. */
4125
+ commandAccounts: z.array(CommandAccountSchema).optional(),
2703
4126
  agents: z.array(z.object({
2704
4127
  id: AgentIdSchema,
2705
4128
  displayName: z.string(),
@@ -2757,6 +4180,8 @@ const HostSnapshotSchema = z.object({
2757
4180
  "direct"
2758
4181
  ]),
2759
4182
  displayName: z.string().optional(),
4183
+ localDisplayName: z.string().optional(),
4184
+ platformDisplayName: z.string().optional(),
2760
4185
  boundAgentId: AgentIdSchema.optional(),
2761
4186
  runtimePhase: ChannelRuntimePhaseSchema.default("idle"),
2762
4187
  activity: ChannelActivitySummarySchema.default({
@@ -2769,6 +4194,8 @@ const HostSnapshotSchema = z.object({
2769
4194
  channelId: ChannelIdSchema,
2770
4195
  agentId: AgentIdSchema,
2771
4196
  triggerPolicy: TriggerPolicySchema,
4197
+ /** Channel pause, independent of the response rule. */
4198
+ paused: z.boolean().default(false),
2772
4199
  processingFeedback: z.enum(["auto", "off"]).default("auto"),
2773
4200
  /** Absent means `observe`. */
2774
4201
  localAgentMessages: z.enum(["observe", "trigger"]).optional(),
@@ -2787,6 +4214,7 @@ const HostSnapshotSchema = z.object({
2787
4214
  adapterKey: NonEmptyStringSchema,
2788
4215
  alias: ConnectionAliasOutputSchema.optional(),
2789
4216
  activityTriggerDefaults: z.array(AdapterActivityKeySchema).default([]),
4217
+ configuredSecrets: z.array(z.string()).optional(),
2790
4218
  status: z.object({
2791
4219
  state: z.enum([
2792
4220
  "stopped",
@@ -2856,9 +4284,45 @@ const HostSnapshotSchema = z.object({
2856
4284
  displayName: z.string(),
2857
4285
  description: z.string(),
2858
4286
  createdByAgentId: AgentIdSchema.optional(),
4287
+ /** The Revision of another extension this one was branched from. */
4288
+ branchOf: z.object({
4289
+ extensionId: ExtensionIdSchema,
4290
+ revisionId: ExtensionRevisionIdSchema,
4291
+ /** Present while the original is on this machine. */
4292
+ displayName: z.string().optional()
4293
+ }).strict().optional(),
4294
+ /** Shape version of the data stored on this machine. */
4295
+ dataVersion: z.number().int().positive().default(1),
4296
+ /** The unfinished revise task of this extension, if any. */
4297
+ openRevisionTaskId: AuthoringTaskIdSchema.optional(),
4298
+ /** Whether this machine publishes (`owner`) or follows the line on each community. */
4299
+ communityLinks: z.array(z.object({
4300
+ communityUrl: z.string(),
4301
+ role: z.enum(["owner", "subscriber"])
4302
+ }).strict()).default([]),
2859
4303
  revisions: z.array(z.object({
2860
4304
  id: ExtensionRevisionIdSchema,
2861
4305
  revisionNumber: z.number().int().positive(),
4306
+ /** Version number from the lineage, `v3` (or `v3·2` for a second Revision of the same generation). */
4307
+ versionLabel: z.string(),
4308
+ parentRevisionId: ExtensionRevisionIdSchema.optional(),
4309
+ origin: z.enum([
4310
+ "authored",
4311
+ "file",
4312
+ "community",
4313
+ "branch"
4314
+ ]),
4315
+ authoringTaskId: AuthoringTaskIdSchema.optional(),
4316
+ dataVersion: z.number().int().positive(),
4317
+ /** Community releases this Revision is; installs and publishes from here both record one. */
4318
+ releases: z.array(z.object({
4319
+ communityUrl: z.string(),
4320
+ releaseId: CommunityReleaseIdSchema,
4321
+ number: z.number().int().positive().nullable(),
4322
+ publisherHandle: z.string(),
4323
+ via: z.enum(["install", "publish"]),
4324
+ recordedAt: z.number().int().nonnegative()
4325
+ }).strict()).default([]),
2862
4326
  format: z.enum(["current", "unavailable"]).optional(),
2863
4327
  ui: ExtensionUiContributionsSchema.default(EMPTY_EXTENSION_UI_CONTRIBUTIONS),
2864
4328
  /** The host instance's configuration form (`config.host`). */
@@ -2868,8 +4332,6 @@ const HostSnapshotSchema = z.object({
2868
4332
  /** 扩展包自带图标的读取路径(同源、按摘要寻址、可长期缓存);没有图标时缺省。 */
2869
4333
  iconUrl: z.string().regex(/^\/api\/extensions\/[^/]+\/revisions\/[^/]+\/icon\/[a-f0-9]{64}\.(?:svg|png|webp)$/u).optional(),
2870
4334
  createdAt: z.number().int().safe().nonnegative(),
2871
- /** 从社区安装的保存记录的来源;本机保存与文件导入没有来源。 */
2872
- source: CommunitySourceSchema.optional(),
2873
4335
  provides: z.array(ExtensionProvideSchema),
2874
4336
  /** Whether this Revision can be enabled for agents (agent-layer contributions or capabilities). */
2875
4337
  agentLayer: z.boolean(),
@@ -3013,17 +4475,36 @@ const HostSnapshotSchema = z.object({
3013
4475
  }).strict()
3014
4476
  }).strict()),
3015
4477
  authoringTasks: z.array(AuthoringTaskSummarySchema).default([]),
3016
- scheduledTasks: z.array(ScheduledTaskSchema).default([])
4478
+ /** Open sub-conversations, and the most recently ended ones of each channel. */
4479
+ subConversations: z.array(SubConversationSchema).default([]),
4480
+ scheduledTasks: z.array(ScheduledTaskSchema).default([]),
4481
+ /** Extension requests waiting for an administrator. */
4482
+ extensionRequests: z.array(ExtensionRequestSchema).default([])
3017
4483
  }).strict();
3018
- const MessageInputPartSchema = z.discriminatedUnion("type", [z.object({
3019
- type: z.literal("text"),
3020
- text: z.string().trim().min(1)
3021
- }).strict(), z.object({
3022
- type: z.literal("mention"),
3023
- memberId: ChannelMemberIdSchema
3024
- }).strict()]);
4484
+ const CHANNEL_COMPOSER_MAX_ATTACHMENTS = 20;
4485
+ const CHANNEL_COMPOSER_MAX_BYTES = 64 * 1024 * 1024;
4486
+ const MessageInputPartSchema = z.discriminatedUnion("type", [
4487
+ z.object({
4488
+ type: z.literal("text"),
4489
+ text: z.string().trim().min(1)
4490
+ }).strict(),
4491
+ z.object({
4492
+ type: z.literal("mention"),
4493
+ memberId: ChannelMemberIdSchema
4494
+ }).strict(),
4495
+ z.object({
4496
+ type: z.literal("image"),
4497
+ assetId: AssetIdSchema,
4498
+ alt: z.string().trim().max(500).optional()
4499
+ }).strict(),
4500
+ z.object({
4501
+ type: z.literal("file"),
4502
+ assetId: AssetIdSchema,
4503
+ name: z.string().trim().max(255).optional()
4504
+ }).strict()
4505
+ ]);
3025
4506
  const SendChannelMessageRequestSchema = z.object({
3026
- parts: z.array(MessageInputPartSchema).min(1),
4507
+ parts: z.array(MessageInputPartSchema).min(1).max(256).refine((parts) => parts.filter((part) => part.type === "image" || part.type === "file").length <= 20, "每条消息最多添加 20 个附件。"),
3027
4508
  clientEventId: NonEmptyStringSchema.optional(),
3028
4509
  senderMemberId: ChannelMemberIdSchema.optional()
3029
4510
  }).strict().refine((body) => body.parts.every((part) => part.type !== "text" || [...part.text].length <= 64 * 1024), "Message text must not exceed 64 KiB.");
@@ -3438,6 +4919,125 @@ const agentExtensionParam = z.object({
3438
4919
  extensionId: ExtensionIdSchema
3439
4920
  }).strict();
3440
4921
  const PermissionApprovalSchema = z.object({ permissionDigest: z.string().regex(/^[a-f0-9]{64}$/u) }).strict();
4922
+ /** One version of one line in the lineage view of an extension family. */
4923
+ const ExtensionLineageNodeSchema = z.object({
4924
+ revisionId: ExtensionRevisionIdSchema,
4925
+ extensionId: ExtensionIdSchema,
4926
+ label: z.string(),
4927
+ parentRevisionId: ExtensionRevisionIdSchema.optional(),
4928
+ origin: z.enum([
4929
+ "authored",
4930
+ "file",
4931
+ "community",
4932
+ "branch"
4933
+ ]),
4934
+ createdAt: z.number().int().nonnegative(),
4935
+ current: z.boolean(),
4936
+ releaseNumbers: z.array(z.number().int().positive())
4937
+ }).strict();
4938
+ /** Every line of the family an extension belongs to: the original and every branch of a branch on this machine. */
4939
+ const ExtensionLineageSchema = z.object({ lines: z.array(z.object({
4940
+ extensionId: ExtensionIdSchema,
4941
+ displayName: z.string(),
4942
+ branchOf: z.object({
4943
+ extensionId: ExtensionIdSchema,
4944
+ revisionId: ExtensionRevisionIdSchema
4945
+ }).strict().optional(),
4946
+ nodes: z.array(ExtensionLineageNodeSchema)
4947
+ }).strict()) }).strict();
4948
+ const DataChangeCountSchema = z.object({
4949
+ added: z.number().int().nonnegative(),
4950
+ overwritten: z.number().int().nonnegative(),
4951
+ removed: z.number().int().nonnegative(),
4952
+ unchanged: z.number().int().nonnegative()
4953
+ }).strict();
4954
+ /** Where a data migration takes data from. */
4955
+ const ExtensionDataSourceSchema = z.discriminatedUnion("kind", [
4956
+ z.object({
4957
+ kind: z.literal("extension"),
4958
+ extensionId: ExtensionIdSchema
4959
+ }).strict(),
4960
+ z.object({
4961
+ kind: z.literal("snapshot"),
4962
+ snapshotId: z.string().min(1).max(80)
4963
+ }).strict(),
4964
+ z.object({
4965
+ kind: z.literal("package"),
4966
+ token: z.string().min(1).max(80)
4967
+ }).strict()
4968
+ ]);
4969
+ const ExtensionDataMigrationInputSchema = z.object({
4970
+ source: ExtensionDataSourceSchema,
4971
+ mode: z.enum(["overwrite", "replace"]),
4972
+ /** Storage of a source agent goes to the mapped agent here; unmapped agents are skipped. */
4973
+ agentMap: z.record(z.string(), AgentIdSchema).optional(),
4974
+ /** Also move the host and agent configuration (never credentials) the same way. */
4975
+ includeConfig: z.boolean().optional()
4976
+ }).strict();
4977
+ const ExtensionDataPreviewSchema = z.object({
4978
+ diff: z.object({
4979
+ storage: DataChangeCountSchema,
4980
+ index: DataChangeCountSchema,
4981
+ library: DataChangeCountSchema
4982
+ }).strict(),
4983
+ destructive: z.boolean(),
4984
+ sourceDataVersion: z.number().int().positive(),
4985
+ targetDataVersion: z.number().int().positive(),
4986
+ needsMigration: z.boolean(),
4987
+ /** Configuration fields that would change, when configuration moves too. */
4988
+ config: z.object({
4989
+ hostFields: z.array(z.string()),
4990
+ agents: z.array(z.object({
4991
+ agentId: AgentIdSchema,
4992
+ fields: z.array(z.string())
4993
+ }).strict())
4994
+ }).strict().optional()
4995
+ }).strict();
4996
+ const ExtensionDataStateSchema = z.object({
4997
+ dataVersion: z.number().int().positive(),
4998
+ counts: z.object({
4999
+ storage: z.number().int().nonnegative(),
5000
+ index: z.number().int().nonnegative(),
5001
+ library: z.number().int().nonnegative()
5002
+ }).strict(),
5003
+ snapshots: z.array(z.object({
5004
+ id: z.string(),
5005
+ reason: z.enum([
5006
+ "switch",
5007
+ "migration",
5008
+ "manual"
5009
+ ]),
5010
+ label: z.string(),
5011
+ dataVersion: z.number().int().positive(),
5012
+ byteSize: z.number().int().nonnegative(),
5013
+ createdAt: z.number().int().nonnegative()
5014
+ }).strict())
5015
+ }).strict();
5016
+ const ExtensionDataPackageInspectionSchema = z.object({
5017
+ token: z.string(),
5018
+ extensionId: z.string(),
5019
+ displayName: z.string(),
5020
+ dataVersion: z.number().int().positive(),
5021
+ exportedAt: z.number().int().nonnegative(),
5022
+ agents: z.array(z.object({
5023
+ id: z.string(),
5024
+ name: z.string()
5025
+ }).strict()),
5026
+ counts: z.object({
5027
+ storage: z.number().int().nonnegative(),
5028
+ index: z.number().int().nonnegative(),
5029
+ library: z.number().int().nonnegative()
5030
+ }).strict()
5031
+ }).strict();
5032
+ const AdministratorSchema = z.object({
5033
+ connectionId: ConnectionIdSchema,
5034
+ connectionName: z.string(),
5035
+ platformUserId: z.string(),
5036
+ identityId: PlatformIdentityIdSchema.optional(),
5037
+ displayName: z.string(),
5038
+ addedVia: z.enum(["console", "claim"]),
5039
+ addedAt: z.number().int().nonnegative()
5040
+ }).strict();
3441
5041
  const extensionParam = z.object({ extensionId: ExtensionIdSchema }).strict();
3442
5042
  const dshPluginPackageParam = z.object({ packageId: DshPluginPackageIdSchema }).strict();
3443
5043
  const dshPluginEntryParam = z.object({ entryId: DshPluginEntryIdSchema }).strict();
@@ -3449,6 +5049,7 @@ const dshSettingsParam = z.object({ namespace: NonEmptyStringSchema }).strict();
3449
5049
  const dshCredentialParam = z.object({ ref: DshCredentialRefSchema }).strict();
3450
5050
  const llmProviderParam = z.object({ provider: NonEmptyStringSchema }).strict();
3451
5051
  const authoringTaskParam = z.object({ taskId: AuthoringTaskIdSchema }).strict();
5052
+ const subConversationParam = z.object({ conversationId: SubConversationIdSchema }).strict();
3452
5053
  const scheduledTaskParam = z.object({ taskId: ScheduledTaskIdSchema }).strict();
3453
5054
  const authoringAttemptParam = z.object({
3454
5055
  taskId: AuthoringTaskIdSchema,
@@ -3484,6 +5085,174 @@ const encodeBinaryUpload = (input) => ({
3484
5085
  }
3485
5086
  });
3486
5087
  const HostApiContracts = {
5088
+ listCommands: defineContract({
5089
+ method: "GET",
5090
+ path: "/api/commands",
5091
+ params: z.object({ channelId: ChannelIdSchema.optional() }).strict(),
5092
+ request: NoRequestBodySchema,
5093
+ response: z.object({
5094
+ commands: z.array(CommandCatalogEntrySchema),
5095
+ problems: z.array(z.string()),
5096
+ /** Host-wide behavior: whether platform members without a grant are told so. */
5097
+ settings: z.object({ unauthorizedFeedback: z.boolean() }).strict(),
5098
+ /** Present when a channel was requested. */
5099
+ channel: z.object({
5100
+ kind: z.enum([
5101
+ "internal",
5102
+ "direct",
5103
+ "group"
5104
+ ]),
5105
+ /** The channel is an external group where commands must address the account. */
5106
+ requiresMention: z.boolean(),
5107
+ bareCommands: z.boolean()
5108
+ }).strict().optional()
5109
+ }).strict(),
5110
+ error: HostApiErrorSchema
5111
+ }),
5112
+ executeCommand: defineContract({
5113
+ method: "POST",
5114
+ path: "/api/commands/execute",
5115
+ params: EmptyParamsSchema,
5116
+ request: z.object({
5117
+ channelId: ChannelIdSchema,
5118
+ text: z.string().min(1).max(16e3),
5119
+ requestId: z.string().min(1).max(200)
5120
+ }).strict(),
5121
+ response: CommandExecutionRecordSchema,
5122
+ error: HostApiErrorSchema,
5123
+ invalidatesSnapshot: true
5124
+ }),
5125
+ getCommandExecution: defineContract({
5126
+ method: "GET",
5127
+ path: "/api/commands/executions/:executionId",
5128
+ params: z.object({ executionId: z.string().min(1) }).strict(),
5129
+ request: NoRequestBodySchema,
5130
+ response: CommandExecutionRecordSchema,
5131
+ error: HostApiErrorSchema
5132
+ }),
5133
+ setCommandPolicy: defineContract({
5134
+ method: "PUT",
5135
+ path: "/api/commands/policy",
5136
+ params: EmptyParamsSchema,
5137
+ request: z.object({
5138
+ scope: z.union([z.literal("global"), ChannelIdSchema]),
5139
+ name: z.string().min(1),
5140
+ policy: CommandPolicySchema
5141
+ }).strict(),
5142
+ response: z.object({ saved: z.literal(true) }).strict(),
5143
+ error: HostApiErrorSchema,
5144
+ invalidatesSnapshot: true
5145
+ }),
5146
+ listCommandMembers: defineContract({
5147
+ method: "GET",
5148
+ path: "/api/commands/members/:channelId",
5149
+ params: z.object({ channelId: ChannelIdSchema }).strict(),
5150
+ request: NoRequestBodySchema,
5151
+ response: z.object({ members: z.array(z.object({
5152
+ identityId: PlatformIdentityIdSchema,
5153
+ displayName: z.string(),
5154
+ platformUserId: z.string(),
5155
+ authorized: z.boolean()
5156
+ }).strict()) }).strict(),
5157
+ error: HostApiErrorSchema
5158
+ }),
5159
+ setCommandSettings: defineContract({
5160
+ method: "PUT",
5161
+ path: "/api/commands/settings",
5162
+ params: EmptyParamsSchema,
5163
+ request: z.object({ unauthorizedFeedback: z.boolean() }).strict(),
5164
+ response: z.object({ saved: z.literal(true) }).strict(),
5165
+ error: HostApiErrorSchema
5166
+ }),
5167
+ setCommandChannelSettings: defineContract({
5168
+ method: "PUT",
5169
+ path: "/api/commands/channel-settings",
5170
+ params: EmptyParamsSchema,
5171
+ request: z.object({
5172
+ channelId: ChannelIdSchema,
5173
+ bareCommands: z.boolean()
5174
+ }).strict(),
5175
+ response: z.object({ saved: z.literal(true) }).strict(),
5176
+ error: HostApiErrorSchema,
5177
+ invalidatesSnapshot: true
5178
+ }),
5179
+ setCommandGrant: defineContract({
5180
+ method: "PUT",
5181
+ path: "/api/commands/grants",
5182
+ params: EmptyParamsSchema,
5183
+ request: z.object({
5184
+ channelId: ChannelIdSchema,
5185
+ identityId: PlatformIdentityIdSchema,
5186
+ enabled: z.boolean()
5187
+ }).strict(),
5188
+ response: z.object({ saved: z.literal(true) }).strict(),
5189
+ error: HostApiErrorSchema,
5190
+ invalidatesSnapshot: true
5191
+ }),
5192
+ queryLogs: defineContract({
5193
+ method: "GET",
5194
+ path: "/api/logs",
5195
+ params: z.object({ query: z.string().max(32768).optional() }).strict(),
5196
+ request: NoRequestBodySchema,
5197
+ response: hostLogPageSchema,
5198
+ error: HostApiErrorSchema
5199
+ }),
5200
+ getLog: defineContract({
5201
+ method: "GET",
5202
+ path: "/api/logs/:id",
5203
+ params: z.object({ id: z.string().min(1).max(256) }).strict(),
5204
+ request: NoRequestBodySchema,
5205
+ response: z.object({ entry: hostLogEntrySchema }).strict(),
5206
+ error: HostApiErrorSchema
5207
+ }),
5208
+ logSources: defineContract({
5209
+ method: "GET",
5210
+ path: "/api/logs/sources",
5211
+ params: EmptyParamsSchema,
5212
+ request: NoRequestBodySchema,
5213
+ response: z.object({ sources: z.array(hostLogSourceSchema) }).strict(),
5214
+ error: HostApiErrorSchema
5215
+ }),
5216
+ logStatus: defineContract({
5217
+ method: "GET",
5218
+ path: "/api/logs/status",
5219
+ params: EmptyParamsSchema,
5220
+ request: NoRequestBodySchema,
5221
+ response: hostLogStatusSchema,
5222
+ error: HostApiErrorSchema
5223
+ }),
5224
+ logSettings: defineContract({
5225
+ method: "GET",
5226
+ path: "/api/logs/settings",
5227
+ params: EmptyParamsSchema,
5228
+ request: NoRequestBodySchema,
5229
+ response: hostLogSettingsSchema,
5230
+ error: HostApiErrorSchema
5231
+ }),
5232
+ updateLogSettings: defineContract({
5233
+ method: "PUT",
5234
+ path: "/api/logs/settings",
5235
+ params: EmptyParamsSchema,
5236
+ request: hostLogSettingsSchema,
5237
+ response: hostLogSettingsSchema,
5238
+ error: HostApiErrorSchema
5239
+ }),
5240
+ startLogDebug: defineContract({
5241
+ method: "POST",
5242
+ path: "/api/logs/debug",
5243
+ params: EmptyParamsSchema,
5244
+ request: hostLogDebugRequestSchema,
5245
+ response: z.object({ lease: hostLogDebugLeaseSchema }).strict(),
5246
+ error: HostApiErrorSchema
5247
+ }),
5248
+ stopLogDebug: defineContract({
5249
+ method: "DELETE",
5250
+ path: "/api/logs/debug/:id",
5251
+ params: z.object({ id: z.string().min(1).max(256) }).strict(),
5252
+ request: NoRequestBodySchema,
5253
+ response: z.object({ stopped: z.literal(true) }).strict(),
5254
+ error: HostApiErrorSchema
5255
+ }),
3487
5256
  retryRuntimeCompatibility: defineContract({
3488
5257
  method: "POST",
3489
5258
  path: "/api/runtime/compatibility/retry",
@@ -3781,6 +5550,7 @@ const HostApiContracts = {
3781
5550
  channelId: ChannelIdSchema,
3782
5551
  agentId: AgentIdSchema,
3783
5552
  triggerPolicy: TriggerPolicySchema,
5553
+ paused: z.boolean().default(false),
3784
5554
  processingFeedback: z.enum(["auto", "off"]).default("auto"),
3785
5555
  localAgentMessages: z.enum(["observe", "trigger"]).optional(),
3786
5556
  activityTriggerOverrides: ActivityTriggerOverridesSchema.default({}),
@@ -3838,20 +5608,56 @@ const HostApiContracts = {
3838
5608
  }).strict(),
3839
5609
  error: HostApiErrorSchema
3840
5610
  }),
3841
- renameChannel: defineContract({
3842
- invalidatesSnapshot: true,
5611
+ uploadChannelAsset: defineContract({
3843
5612
  method: "POST",
3844
- path: "/api/channels/:channelId/display-name",
5613
+ path: "/api/channels/:channelId/assets",
3845
5614
  params: channelParam,
3846
- request: z.object({ displayName: z.string().trim().min(1).max(120) }).strict(),
5615
+ request: BinaryUploadRequestSchema,
5616
+ encodeRequest: (input) => ({
5617
+ body: input.bytes,
5618
+ headers: {
5619
+ "content-type": "application/octet-stream",
5620
+ "x-file-name": encodeURIComponent(input.fileName ?? "附件")
5621
+ }
5622
+ }),
3847
5623
  response: z.object({
3848
- channelId: ChannelIdSchema,
3849
- displayName: z.string().trim().min(1).max(120)
5624
+ assetId: AssetIdSchema,
5625
+ mediaType: z.string().min(1),
5626
+ byteSize: z.number().int().nonnegative(),
5627
+ fileName: z.string().min(1).max(255),
5628
+ partType: z.enum(["image", "file"])
3850
5629
  }).strict(),
3851
5630
  error: HostApiErrorSchema
3852
5631
  }),
3853
- getChannelRuntime: defineContract({
3854
- method: "GET",
5632
+ deleteChannelAsset: defineContract({
5633
+ method: "DELETE",
5634
+ path: "/api/channels/:channelId/assets/:assetId",
5635
+ params: z.object({
5636
+ channelId: ChannelIdSchema,
5637
+ assetId: AssetIdSchema
5638
+ }).strict(),
5639
+ request: NoRequestBodySchema,
5640
+ response: z.object({
5641
+ assetId: AssetIdSchema,
5642
+ revoked: z.literal(true)
5643
+ }).strict(),
5644
+ error: HostApiErrorSchema
5645
+ }),
5646
+ renameChannel: defineContract({
5647
+ invalidatesSnapshot: true,
5648
+ method: "POST",
5649
+ path: "/api/channels/:channelId/display-name",
5650
+ params: channelParam,
5651
+ /** Empty selects the known platform name for an external channel. */
5652
+ request: z.object({ displayName: z.string().trim().max(120) }).strict(),
5653
+ response: z.object({
5654
+ channelId: ChannelIdSchema,
5655
+ displayName: z.string().trim().min(1).max(120)
5656
+ }).strict(),
5657
+ error: HostApiErrorSchema
5658
+ }),
5659
+ getChannelRuntime: defineContract({
5660
+ method: "GET",
3855
5661
  path: "/api/channels/:channelId/runtime",
3856
5662
  params: channelParam,
3857
5663
  request: NoRequestBodySchema,
@@ -3885,6 +5691,59 @@ const HostApiContracts = {
3885
5691
  response: ChannelRuntimeContextSchema,
3886
5692
  error: HostApiErrorSchema
3887
5693
  }),
5694
+ listSubConversations: defineContract({
5695
+ method: "GET",
5696
+ path: "/api/sub-conversations/channels/:channelId",
5697
+ params: channelParam,
5698
+ request: NoRequestBodySchema,
5699
+ response: z.object({ items: z.array(SubConversationSchema) }).strict(),
5700
+ error: HostApiErrorSchema
5701
+ }),
5702
+ getSubConversationRuntime: defineContract({
5703
+ method: "GET",
5704
+ path: "/api/sub-conversations/:conversationId/runtime",
5705
+ params: subConversationParam,
5706
+ request: NoRequestBodySchema,
5707
+ response: z.object({
5708
+ conversation: SubConversationSchema,
5709
+ runtime: ChannelRuntimeProjectionSchema
5710
+ }).strict(),
5711
+ error: HostApiErrorSchema
5712
+ }),
5713
+ closeSubConversation: defineContract({
5714
+ invalidatesSnapshot: true,
5715
+ method: "POST",
5716
+ path: "/api/sub-conversations/:conversationId/close",
5717
+ params: subConversationParam,
5718
+ request: z.object({}).strict(),
5719
+ response: SubConversationSchema,
5720
+ error: HostApiErrorSchema
5721
+ }),
5722
+ deleteSubConversation: defineContract({
5723
+ invalidatesSnapshot: true,
5724
+ method: "DELETE",
5725
+ path: "/api/sub-conversations/:conversationId",
5726
+ params: subConversationParam,
5727
+ request: NoRequestBodySchema,
5728
+ response: z.object({ deleted: z.literal(true) }).strict(),
5729
+ error: HostApiErrorSchema
5730
+ }),
5731
+ getSubConversationSettings: defineContract({
5732
+ method: "GET",
5733
+ path: "/api/settings/sub-conversations",
5734
+ params: EmptyParamsSchema,
5735
+ request: NoRequestBodySchema,
5736
+ response: SubConversationSettingsSchema,
5737
+ error: HostApiErrorSchema
5738
+ }),
5739
+ updateSubConversationSettings: defineContract({
5740
+ method: "PUT",
5741
+ path: "/api/settings/sub-conversations",
5742
+ params: EmptyParamsSchema,
5743
+ request: SubConversationSettingsSchema,
5744
+ response: SubConversationSettingsSchema,
5745
+ error: HostApiErrorSchema
5746
+ }),
3888
5747
  getChannelRuntimeInput: defineContract({
3889
5748
  method: "GET",
3890
5749
  path: "/api/channels/:channelId/runtime/inputs/:messageId",
@@ -3915,7 +5774,9 @@ const HostApiContracts = {
3915
5774
  path: "/api/channels/:channelId/prompt",
3916
5775
  params: channelParam,
3917
5776
  request: z.object({
5777
+ kind: z.enum(["instructions", "notes"]),
3918
5778
  document: PromptDocumentV1Schema,
5779
+ /** Notes only; ignored for instructions. */
3919
5780
  locked: z.boolean(),
3920
5781
  /** The revision the edit started from; a newer stored revision rejects the save. */
3921
5782
  expectedRevision: z.number().int().nonnegative()
@@ -3923,6 +5784,223 @@ const HostApiContracts = {
3923
5784
  response: ChannelPromptViewSchema,
3924
5785
  error: HostApiErrorSchema
3925
5786
  }),
5787
+ getProductUpdates: defineContract({
5788
+ method: "GET",
5789
+ path: "/api/product/updates",
5790
+ params: EmptyParamsSchema,
5791
+ request: NoRequestBodySchema,
5792
+ response: ProductUpdateStatusSchema,
5793
+ error: HostApiErrorSchema
5794
+ }),
5795
+ checkProductUpdates: defineContract({
5796
+ method: "POST",
5797
+ path: "/api/product/updates/check",
5798
+ params: EmptyParamsSchema,
5799
+ request: NoRequestBodySchema,
5800
+ response: ProductUpdateStatusSchema,
5801
+ error: HostApiErrorSchema
5802
+ }),
5803
+ updateProductUpdateSettings: defineContract({
5804
+ method: "PUT",
5805
+ path: "/api/product/updates/settings",
5806
+ params: EmptyParamsSchema,
5807
+ request: z.object({ autoCheck: z.boolean() }).strict(),
5808
+ response: ProductUpdateStatusSchema,
5809
+ error: HostApiErrorSchema
5810
+ }),
5811
+ getMessagePacingSettings: defineContract({
5812
+ method: "GET",
5813
+ path: "/api/settings/message-pacing",
5814
+ params: EmptyParamsSchema,
5815
+ request: NoRequestBodySchema,
5816
+ response: MessagePacingSettingsSchema,
5817
+ error: HostApiErrorSchema
5818
+ }),
5819
+ updateMessagePacingSettings: defineContract({
5820
+ method: "PUT",
5821
+ path: "/api/settings/message-pacing",
5822
+ params: EmptyParamsSchema,
5823
+ request: MessagePacingSettingsSchema,
5824
+ response: MessagePacingSettingsSchema,
5825
+ error: HostApiErrorSchema
5826
+ }),
5827
+ getUpgradeBackupSettings: defineContract({
5828
+ method: "GET",
5829
+ path: "/api/settings/upgrade-backup",
5830
+ params: EmptyParamsSchema,
5831
+ request: NoRequestBodySchema,
5832
+ response: UpgradeBackupSettingsSchema,
5833
+ error: HostApiErrorSchema
5834
+ }),
5835
+ updateUpgradeBackupSettings: defineContract({
5836
+ method: "PUT",
5837
+ path: "/api/settings/upgrade-backup",
5838
+ params: EmptyParamsSchema,
5839
+ request: z.object({
5840
+ mode: UpgradeBackupModeSchema,
5841
+ directory: z.string().trim().min(1).max(1024).optional()
5842
+ }).strict(),
5843
+ response: UpgradeBackupSettingsSchema,
5844
+ error: HostApiErrorSchema
5845
+ }),
5846
+ getRetrievalStatus: defineContract({
5847
+ method: "GET",
5848
+ path: "/api/settings/retrieval",
5849
+ params: EmptyParamsSchema,
5850
+ request: NoRequestBodySchema,
5851
+ response: RetrievalStatusSchema,
5852
+ error: HostApiErrorSchema
5853
+ }),
5854
+ updateRetrievalMode: defineContract({
5855
+ method: "PUT",
5856
+ path: "/api/settings/retrieval",
5857
+ params: EmptyParamsSchema,
5858
+ request: z.object({ mode: RetrievalModeSchema }).strict(),
5859
+ response: RetrievalStatusSchema,
5860
+ error: HostApiErrorSchema
5861
+ }),
5862
+ downloadRetrievalModel: defineContract({
5863
+ method: "POST",
5864
+ path: "/api/settings/retrieval/model/download",
5865
+ params: EmptyParamsSchema,
5866
+ request: NoRequestBodySchema,
5867
+ response: RetrievalStatusSchema,
5868
+ error: HostApiErrorSchema
5869
+ }),
5870
+ removeRetrievalModel: defineContract({
5871
+ method: "DELETE",
5872
+ path: "/api/settings/retrieval/model",
5873
+ params: EmptyParamsSchema,
5874
+ request: NoRequestBodySchema,
5875
+ response: RetrievalStatusSchema,
5876
+ error: HostApiErrorSchema
5877
+ }),
5878
+ downloadCodeRunNode: defineContract({
5879
+ invalidatesSnapshot: true,
5880
+ method: "POST",
5881
+ path: "/api/runtimes/code-run-node/download",
5882
+ params: EmptyParamsSchema,
5883
+ request: NoRequestBodySchema,
5884
+ response: CodeRunAvailabilitySchema,
5885
+ error: HostApiErrorSchema
5886
+ }),
5887
+ removeCodeRunNode: defineContract({
5888
+ invalidatesSnapshot: true,
5889
+ method: "DELETE",
5890
+ path: "/api/runtimes/code-run-node",
5891
+ params: EmptyParamsSchema,
5892
+ request: NoRequestBodySchema,
5893
+ response: CodeRunAvailabilitySchema,
5894
+ error: HostApiErrorSchema
5895
+ }),
5896
+ downloadGithubCli: defineContract({
5897
+ invalidatesSnapshot: true,
5898
+ method: "POST",
5899
+ path: "/api/runtimes/github-cli/download",
5900
+ params: EmptyParamsSchema,
5901
+ request: NoRequestBodySchema,
5902
+ response: GithubCliAvailabilitySchema,
5903
+ error: HostApiErrorSchema
5904
+ }),
5905
+ removeGithubCli: defineContract({
5906
+ invalidatesSnapshot: true,
5907
+ method: "DELETE",
5908
+ path: "/api/runtimes/github-cli",
5909
+ params: EmptyParamsSchema,
5910
+ request: NoRequestBodySchema,
5911
+ response: GithubCliAvailabilitySchema,
5912
+ error: HostApiErrorSchema
5913
+ }),
5914
+ downloadVerificationBrowser: defineContract({
5915
+ invalidatesSnapshot: true,
5916
+ method: "POST",
5917
+ path: "/api/runtimes/verification-browser/download",
5918
+ params: EmptyParamsSchema,
5919
+ request: NoRequestBodySchema,
5920
+ response: VerificationBrowserAvailabilitySchema,
5921
+ error: HostApiErrorSchema
5922
+ }),
5923
+ removeVerificationBrowser: defineContract({
5924
+ invalidatesSnapshot: true,
5925
+ method: "DELETE",
5926
+ path: "/api/runtimes/verification-browser",
5927
+ params: EmptyParamsSchema,
5928
+ request: NoRequestBodySchema,
5929
+ response: VerificationBrowserAvailabilitySchema,
5930
+ error: HostApiErrorSchema
5931
+ }),
5932
+ getCommandAccounts: defineContract({
5933
+ method: "GET",
5934
+ path: "/api/settings/command-accounts",
5935
+ params: EmptyParamsSchema,
5936
+ request: NoRequestBodySchema,
5937
+ response: CommandAccountsViewSchema,
5938
+ error: HostApiErrorSchema
5939
+ }),
5940
+ addCommandAccount: defineContract({
5941
+ invalidatesSnapshot: true,
5942
+ method: "POST",
5943
+ path: "/api/settings/command-accounts",
5944
+ params: EmptyParamsSchema,
5945
+ request: AddCommandAccountRequestSchema,
5946
+ response: CommandAccountsViewSchema,
5947
+ error: HostApiErrorSchema
5948
+ }),
5949
+ replaceCommandAccountToken: defineContract({
5950
+ invalidatesSnapshot: true,
5951
+ method: "PUT",
5952
+ path: "/api/settings/command-accounts/:accountId",
5953
+ params: z.object({ accountId: NonEmptyStringSchema.max(64) }).strict(),
5954
+ request: AddCommandAccountRequestSchema,
5955
+ response: CommandAccountsViewSchema,
5956
+ error: HostApiErrorSchema
5957
+ }),
5958
+ removeCommandAccount: defineContract({
5959
+ invalidatesSnapshot: true,
5960
+ method: "DELETE",
5961
+ path: "/api/settings/command-accounts/:accountId",
5962
+ params: z.object({ accountId: NonEmptyStringSchema.max(64) }).strict(),
5963
+ request: NoRequestBodySchema,
5964
+ response: CommandAccountsViewSchema,
5965
+ error: HostApiErrorSchema
5966
+ }),
5967
+ getChannelMemberNotes: defineContract({
5968
+ method: "GET",
5969
+ path: "/api/channels/:channelId/member-notes",
5970
+ params: channelParam,
5971
+ request: NoRequestBodySchema,
5972
+ response: ChannelMemberNotesViewSchema,
5973
+ error: HostApiErrorSchema
5974
+ }),
5975
+ updateChannelMemberNote: defineContract({
5976
+ method: "PUT",
5977
+ path: "/api/channels/:channelId/member-notes/:memberId",
5978
+ params: z.object({
5979
+ channelId: ChannelIdSchema,
5980
+ memberId: ChannelMemberIdSchema
5981
+ }).strict(),
5982
+ /** An empty text forgets the member. */
5983
+ request: z.object({ text: z.string().max(2e3) }).strict(),
5984
+ response: ChannelMemberNotesViewSchema,
5985
+ error: HostApiErrorSchema
5986
+ }),
5987
+ getChannelContextPolicy: defineContract({
5988
+ method: "GET",
5989
+ path: "/api/channels/:channelId/context-policy",
5990
+ params: channelParam,
5991
+ request: NoRequestBodySchema,
5992
+ response: ChannelContextPolicyViewSchema,
5993
+ error: HostApiErrorSchema
5994
+ }),
5995
+ updateChannelContextPolicy: defineContract({
5996
+ method: "PUT",
5997
+ path: "/api/channels/:channelId/context-policy",
5998
+ params: channelParam,
5999
+ /** `null` returns the channel to the defaults. */
6000
+ request: z.object({ policy: ChannelContextPolicySchema.nullable() }).strict(),
6001
+ response: ChannelContextPolicyViewSchema,
6002
+ error: HostApiErrorSchema
6003
+ }),
3926
6004
  resetChannelContext: defineContract({
3927
6005
  invalidatesSnapshot: true,
3928
6006
  method: "POST",
@@ -4043,11 +6121,15 @@ const HostApiContracts = {
4043
6121
  method: "POST",
4044
6122
  path: "/api/connections/:connectionId/configuration",
4045
6123
  params: connectionParam,
4046
- request: z.object({ configuration: z.record(z.string(), z.union([
4047
- z.string(),
4048
- z.number(),
4049
- z.boolean()
4050
- ])) }).strict(),
6124
+ request: z.object({
6125
+ configuration: z.record(z.string(), z.union([
6126
+ z.string(),
6127
+ z.number(),
6128
+ z.boolean()
6129
+ ])),
6130
+ /** Omitted keys keep their value; null explicitly clears an optional credential. */
6131
+ credentials: z.record(z.string().min(1), z.string().min(1).max(16384).nullable()).optional()
6132
+ }).strict(),
4051
6133
  response: z.object({
4052
6134
  connectionId: ConnectionIdSchema,
4053
6135
  configuration: z.record(z.string(), z.union([
@@ -4233,6 +6315,142 @@ const HostApiContracts = {
4233
6315
  response: CommunityStatusSchema,
4234
6316
  error: HostApiErrorSchema
4235
6317
  }),
6318
+ getCommunityFeedbackSettings: defineContract({
6319
+ method: "GET",
6320
+ path: "/api/community/feedback/settings",
6321
+ params: EmptyParamsSchema,
6322
+ request: NoRequestBodySchema,
6323
+ response: CommunityFeedbackSettingsSchema,
6324
+ error: HostApiErrorSchema
6325
+ }),
6326
+ updateCommunityFeedbackSettings: defineContract({
6327
+ method: "PUT",
6328
+ path: "/api/community/feedback/settings",
6329
+ params: EmptyParamsSchema,
6330
+ request: CommunityFeedbackSettingsUpdateSchema,
6331
+ response: CommunityFeedbackSettingsSchema,
6332
+ error: HostApiErrorSchema,
6333
+ invalidatesSnapshot: true
6334
+ }),
6335
+ listCommunityFeedback: defineContract({
6336
+ timeoutMs: 6e4,
6337
+ method: "GET",
6338
+ path: "/api/community/feedback",
6339
+ params: z.object({ refresh: z.literal("1").optional() }).strict(),
6340
+ request: NoRequestBodySchema,
6341
+ response: CommunityFeedbackLocalListSchema,
6342
+ error: HostApiErrorSchema
6343
+ }),
6344
+ getCommunityFeedback: defineContract({
6345
+ timeoutMs: 6e4,
6346
+ method: "GET",
6347
+ path: "/api/community/feedback/items/:ref",
6348
+ params: z.object({ ref: CommunityFeedbackRefSchema }).strict(),
6349
+ request: NoRequestBodySchema,
6350
+ response: CommunityFeedbackSchema,
6351
+ error: HostApiErrorSchema
6352
+ }),
6353
+ createCommunityFeedbackDraft: defineContract({
6354
+ method: "POST",
6355
+ path: "/api/community/feedback/drafts",
6356
+ params: EmptyParamsSchema,
6357
+ request: CommunityFeedbackDraftInputSchema,
6358
+ response: CommunityFeedbackDraftSchema,
6359
+ error: HostApiErrorSchema,
6360
+ invalidatesSnapshot: true
6361
+ }),
6362
+ updateCommunityFeedbackDraft: defineContract({
6363
+ method: "PUT",
6364
+ path: "/api/community/feedback/drafts/:draftId",
6365
+ params: z.object({ draftId: CommunityFeedbackDraftIdSchema }).strict(),
6366
+ request: CommunityFeedbackDraftUpdateSchema,
6367
+ response: CommunityFeedbackDraftSchema,
6368
+ error: HostApiErrorSchema,
6369
+ invalidatesSnapshot: true
6370
+ }),
6371
+ sendCommunityFeedbackDraft: defineContract({
6372
+ timeoutMs: 6e4,
6373
+ method: "POST",
6374
+ path: "/api/community/feedback/drafts/:draftId/send",
6375
+ params: z.object({ draftId: CommunityFeedbackDraftIdSchema }).strict(),
6376
+ request: z.object({ consent: z.boolean().default(false) }).strict(),
6377
+ response: CommunityFeedbackDraftSchema,
6378
+ error: HostApiErrorSchema,
6379
+ invalidatesSnapshot: true
6380
+ }),
6381
+ discardCommunityFeedbackDraft: defineContract({
6382
+ method: "DELETE",
6383
+ path: "/api/community/feedback/drafts/:draftId",
6384
+ params: z.object({ draftId: CommunityFeedbackDraftIdSchema }).strict(),
6385
+ request: NoRequestBodySchema,
6386
+ response: CommunityFeedbackDraftSchema,
6387
+ error: HostApiErrorSchema,
6388
+ invalidatesSnapshot: true
6389
+ }),
6390
+ previewCommunityFeedbackPayload: defineContract({
6391
+ method: "GET",
6392
+ path: "/api/community/feedback/drafts/:draftId/preview",
6393
+ params: z.object({ draftId: CommunityFeedbackDraftIdSchema }).strict(),
6394
+ request: NoRequestBodySchema,
6395
+ response: CommunityFeedbackPayloadSchema,
6396
+ error: HostApiErrorSchema
6397
+ }),
6398
+ getLastSentCommunityFeedbackPayload: defineContract({
6399
+ method: "GET",
6400
+ path: "/api/community/feedback/last-sent",
6401
+ params: EmptyParamsSchema,
6402
+ request: NoRequestBodySchema,
6403
+ response: CommunityFeedbackLastPayloadSchema,
6404
+ error: HostApiErrorSchema
6405
+ }),
6406
+ replyCommunityFeedback: defineContract({
6407
+ method: "POST",
6408
+ path: "/api/community/feedback/items/:ref/messages",
6409
+ params: z.object({ ref: CommunityFeedbackRefSchema }).strict(),
6410
+ request: z.object({ body: z.string().trim().min(1).max(4e3) }).strict(),
6411
+ response: CommunityFeedbackSchema,
6412
+ error: HostApiErrorSchema,
6413
+ invalidatesSnapshot: true
6414
+ }),
6415
+ withdrawCommunityFeedback: defineContract({
6416
+ method: "POST",
6417
+ path: "/api/community/feedback/items/:ref/withdraw",
6418
+ params: z.object({ ref: CommunityFeedbackRefSchema }).strict(),
6419
+ request: CommunityFeedbackWithdrawSchema,
6420
+ response: CommunityFeedbackSchema,
6421
+ error: HostApiErrorSchema,
6422
+ invalidatesSnapshot: true
6423
+ }),
6424
+ reopenCommunityFeedback: defineContract({
6425
+ method: "POST",
6426
+ path: "/api/community/feedback/items/:ref/reopen",
6427
+ params: z.object({ ref: CommunityFeedbackRefSchema }).strict(),
6428
+ request: CommunityFeedbackReopenSchema,
6429
+ response: CommunityFeedbackSchema,
6430
+ error: HostApiErrorSchema,
6431
+ invalidatesSnapshot: true
6432
+ }),
6433
+ markCommunityFeedbackAffected: defineContract({
6434
+ method: "POST",
6435
+ path: "/api/community/feedback/items/:ref/affected",
6436
+ params: z.object({ ref: CommunityFeedbackRefSchema }).strict(),
6437
+ request: z.object({
6438
+ affected: z.boolean().default(true),
6439
+ consent: z.boolean().default(false)
6440
+ }).strict(),
6441
+ response: CommunityFeedbackSchema,
6442
+ error: HostApiErrorSchema,
6443
+ invalidatesSnapshot: true
6444
+ }),
6445
+ confirmCommunityFeedbackFixed: defineContract({
6446
+ method: "POST",
6447
+ path: "/api/community/feedback/items/:ref/confirm-fixed",
6448
+ params: z.object({ ref: CommunityFeedbackRefSchema }).strict(),
6449
+ request: z.object({}).strict(),
6450
+ response: CommunityFeedbackSchema,
6451
+ error: HostApiErrorSchema,
6452
+ invalidatesSnapshot: true
6453
+ }),
4236
6454
  startCommunityLogin: defineContract({
4237
6455
  method: "POST",
4238
6456
  path: "/api/community/login",
@@ -4321,13 +6539,13 @@ const HostApiContracts = {
4321
6539
  }).strict(),
4322
6540
  error: HostApiErrorSchema
4323
6541
  }),
4324
- listCommunityInstalled: defineContract({
4325
- timeoutMs: 3e4,
6542
+ listCommunitySync: defineContract({
6543
+ timeoutMs: 6e4,
4326
6544
  method: "GET",
4327
- path: "/api/community/installed",
6545
+ path: "/api/community/sync",
4328
6546
  params: z.object({ refresh: z.enum(["1"]).optional() }).strict(),
4329
6547
  request: NoRequestBodySchema,
4330
- response: CommunityInstalledSchema,
6548
+ response: CommunitySyncSchema,
4331
6549
  error: HostApiErrorSchema
4332
6550
  }),
4333
6551
  listCommunityMine: defineContract({
@@ -4389,6 +6607,7 @@ const HostApiContracts = {
4389
6607
  }).strict(),
4390
6608
  response: z.object({
4391
6609
  releaseId: CommunityReleaseIdSchema,
6610
+ releaseNumber: z.number().int().positive(),
4392
6611
  reviewStatus: CommunityReviewStatusSchema,
4393
6612
  pageUrl: z.string().url(),
4394
6613
  reportUrl: z.string().url(),
@@ -4732,7 +6951,19 @@ const HostApiContracts = {
4732
6951
  request: z.object({
4733
6952
  episodeId: EpisodeIdSchema,
4734
6953
  requestId: DynamicIdSchema,
4735
- pluginRunId: DynamicIdSchema.optional()
6954
+ pluginRunId: DynamicIdSchema.optional(),
6955
+ /**
6956
+ * Why the run did not go ahead: the user declined it, or the page could not start one of its halves. A failed
6957
+ * half is settled as a failed attempt (its Host is retracted and the agent hears about it), not as a decline.
6958
+ */
6959
+ reason: z.enum([
6960
+ "rejected",
6961
+ "host-half-failed",
6962
+ "client-half-failed"
6963
+ ]).optional(),
6964
+ startedHere: z.boolean().optional(),
6965
+ message: z.string().max(4e3).optional(),
6966
+ stack: z.string().max(16e3).optional()
4736
6967
  }).strict(),
4737
6968
  response: z.object({ accepted: z.boolean() }).strict(),
4738
6969
  error: HostApiErrorSchema
@@ -4867,23 +7098,15 @@ const HostApiContracts = {
4867
7098
  method: "POST",
4868
7099
  path: "/api/extensions/save-from-dynamic",
4869
7100
  params: EmptyParamsSchema,
4870
- request: z.union([z.object({
7101
+ request: z.object({
4871
7102
  taskId: AuthoringTaskIdSchema,
7103
+ /** The candidate the user saw; saving refuses when a newer one appeared since. */
4872
7104
  attemptId: AuthoringAttemptIdSchema,
4873
7105
  displayName: z.string().trim().min(1).max(80),
4874
7106
  slug: z.string().trim().regex(/^[a-z0-9][a-z0-9-]{1,62}[a-z0-9]$/u),
4875
7107
  description: z.string().max(500).default(""),
4876
7108
  targetExtensionId: ExtensionIdSchema.optional()
4877
- }).strict(), z.object({
4878
- agentId: AgentIdSchema,
4879
- episodeId: EpisodeIdSchema,
4880
- pluginId: DynamicIdSchema,
4881
- packageId: DynamicIdSchema,
4882
- displayName: z.string().trim().min(1).max(80),
4883
- slug: z.string().trim().regex(/^[a-z0-9][a-z0-9-]{1,62}[a-z0-9]$/u),
4884
- description: z.string().max(500).default(""),
4885
- targetExtensionId: ExtensionIdSchema.optional()
4886
- }).strict()]),
7109
+ }).strict(),
4887
7110
  response: z.object({
4888
7111
  extensionId: ExtensionIdSchema,
4889
7112
  revisionId: ExtensionRevisionIdSchema,
@@ -5023,7 +7246,9 @@ const HostApiContracts = {
5023
7246
  /** Approval of the host layer (browser permissions and `permissions.host`). */
5024
7247
  permissionApproval: PermissionApprovalSchema.optional(),
5025
7248
  /** Approval of expanded agent-layer capabilities for the agents that move to this Revision. */
5026
- agentPermissionApproval: PermissionApprovalSchema.optional()
7249
+ agentPermissionApproval: PermissionApprovalSchema.optional(),
7250
+ /** Data copy to put back first, when the target Revision only reads an older data version. */
7251
+ restoreDataSnapshotId: z.string().min(1).max(80).optional()
5027
7252
  }).strict(),
5028
7253
  response: z.object({ installation: z.object({
5029
7254
  extensionId: ExtensionIdSchema,
@@ -5141,6 +7366,19 @@ upTo: z.object({
5141
7366
  }).strict(),
5142
7367
  error: HostApiErrorSchema
5143
7368
  }),
7369
+ setChannelPaused: defineContract({
7370
+ method: "POST",
7371
+ path: "/api/channels/:channelId/pause",
7372
+ params: channelParam,
7373
+ request: z.object({ paused: z.boolean() }).strict(),
7374
+ response: z.object({
7375
+ paused: z.boolean(),
7376
+ changed: z.boolean(),
7377
+ stopped: z.boolean()
7378
+ }).strict(),
7379
+ error: HostApiErrorSchema,
7380
+ invalidatesSnapshot: true
7381
+ }),
5144
7382
  resolveOutbound: defineContract({
5145
7383
  method: "POST",
5146
7384
  path: "/api/outbound/:outboundId/resolve",
@@ -5223,6 +7461,202 @@ upTo: z.object({
5223
7461
  request: NoRequestBodySchema,
5224
7462
  response: z.object({ deleted: z.literal(true) }).strict(),
5225
7463
  error: HostApiErrorSchema
7464
+ }),
7465
+ getExtensionLineage: defineContract({
7466
+ method: "GET",
7467
+ path: "/api/extensions/:extensionId/lineage",
7468
+ params: extensionParam,
7469
+ request: NoRequestBodySchema,
7470
+ response: ExtensionLineageSchema,
7471
+ error: HostApiErrorSchema
7472
+ }),
7473
+ branchExtension: defineContract({
7474
+ invalidatesSnapshot: true,
7475
+ timeoutMs: 3e5,
7476
+ method: "POST",
7477
+ path: "/api/extensions/:extensionId/branch",
7478
+ params: extensionParam,
7479
+ request: z.object({
7480
+ revisionId: ExtensionRevisionIdSchema,
7481
+ name: z.string().trim().min(1).max(80),
7482
+ slug: z.string().trim().regex(/^[a-z0-9][a-z0-9-]{1,62}[a-z0-9]$/u).optional(),
7483
+ copyData: z.boolean()
7484
+ }).strict(),
7485
+ response: z.object({
7486
+ extensionId: ExtensionIdSchema,
7487
+ revisionId: ExtensionRevisionIdSchema
7488
+ }).strict(),
7489
+ error: HostApiErrorSchema
7490
+ }),
7491
+ rollbackExtension: defineContract({
7492
+ invalidatesSnapshot: true,
7493
+ timeoutMs: 3e5,
7494
+ method: "POST",
7495
+ path: "/api/extensions/:extensionId/revert",
7496
+ params: extensionParam,
7497
+ request: NoRequestBodySchema,
7498
+ response: z.object({ message: z.string() }).strict(),
7499
+ error: HostApiErrorSchema
7500
+ }),
7501
+ getExtensionData: defineContract({
7502
+ method: "GET",
7503
+ path: "/api/extensions/:extensionId/data",
7504
+ params: extensionParam,
7505
+ request: NoRequestBodySchema,
7506
+ response: ExtensionDataStateSchema,
7507
+ error: HostApiErrorSchema
7508
+ }),
7509
+ previewExtensionDataMigration: defineContract({
7510
+ timeoutMs: 6e4,
7511
+ method: "POST",
7512
+ path: "/api/extensions/:extensionId/data/preview",
7513
+ params: extensionParam,
7514
+ request: ExtensionDataMigrationInputSchema,
7515
+ response: ExtensionDataPreviewSchema,
7516
+ error: HostApiErrorSchema
7517
+ }),
7518
+ migrateExtensionData: defineContract({
7519
+ invalidatesSnapshot: true,
7520
+ timeoutMs: 3e5,
7521
+ method: "POST",
7522
+ path: "/api/extensions/:extensionId/data/migrate",
7523
+ params: extensionParam,
7524
+ request: ExtensionDataMigrationInputSchema,
7525
+ response: z.object({
7526
+ snapshotId: z.string(),
7527
+ preview: ExtensionDataPreviewSchema
7528
+ }).strict(),
7529
+ error: HostApiErrorSchema
7530
+ }),
7531
+ exportExtensionData: defineContract({
7532
+ method: "GET",
7533
+ timeoutMs: 3e5,
7534
+ path: "/api/extensions/:extensionId/data/export",
7535
+ params: extensionParam,
7536
+ request: NoRequestBodySchema,
7537
+ responseFormat: "bytes",
7538
+ response: z.instanceof(Uint8Array),
7539
+ error: HostApiErrorSchema
7540
+ }),
7541
+ /** The same package with the host and agent configuration; secrets are left out. */
7542
+ exportExtensionDataWithConfig: defineContract({
7543
+ method: "GET",
7544
+ timeoutMs: 3e5,
7545
+ path: "/api/extensions/:extensionId/data/export-config",
7546
+ params: extensionParam,
7547
+ request: NoRequestBodySchema,
7548
+ responseFormat: "bytes",
7549
+ response: z.instanceof(Uint8Array),
7550
+ error: HostApiErrorSchema
7551
+ }),
7552
+ createExtensionDataSnapshot: defineContract({
7553
+ method: "POST",
7554
+ path: "/api/extensions/:extensionId/data/snapshots",
7555
+ params: extensionParam,
7556
+ request: z.object({ label: z.string().trim().min(1).max(80) }).strict(),
7557
+ response: z.object({ snapshotId: z.string() }).strict(),
7558
+ error: HostApiErrorSchema
7559
+ }),
7560
+ inspectExtensionDataPackage: defineContract({
7561
+ timeoutMs: 3e5,
7562
+ method: "POST",
7563
+ path: "/api/extensions/data/inspect",
7564
+ params: EmptyParamsSchema,
7565
+ request: BinaryUploadRequestSchema,
7566
+ encodeRequest: encodeBinaryUpload,
7567
+ response: ExtensionDataPackageInspectionSchema,
7568
+ error: HostApiErrorSchema
7569
+ }),
7570
+ listExtensionRequests: defineContract({
7571
+ method: "GET",
7572
+ path: "/api/extension-requests",
7573
+ params: EmptyParamsSchema,
7574
+ request: NoRequestBodySchema,
7575
+ response: z.object({ requests: z.array(ExtensionRequestSchema) }).strict(),
7576
+ error: HostApiErrorSchema
7577
+ }),
7578
+ approveExtensionRequest: defineContract({
7579
+ invalidatesSnapshot: true,
7580
+ timeoutMs: 3e5,
7581
+ method: "POST",
7582
+ path: "/api/extension-requests/:number/approve",
7583
+ params: z.object({ number: z.coerce.number().int().positive() }).strict(),
7584
+ request: NoRequestBodySchema,
7585
+ response: z.object({ message: z.string() }).strict(),
7586
+ error: HostApiErrorSchema
7587
+ }),
7588
+ rejectExtensionRequest: defineContract({
7589
+ method: "POST",
7590
+ path: "/api/extension-requests/:number/reject",
7591
+ params: z.object({ number: z.coerce.number().int().positive() }).strict(),
7592
+ request: z.object({ reason: z.string().trim().max(500).optional() }).strict(),
7593
+ response: z.object({ ok: z.literal(true) }).strict(),
7594
+ error: HostApiErrorSchema
7595
+ }),
7596
+ listAdministrators: defineContract({
7597
+ method: "GET",
7598
+ path: "/api/administrators",
7599
+ params: EmptyParamsSchema,
7600
+ request: NoRequestBodySchema,
7601
+ response: z.object({ administrators: z.array(AdministratorSchema) }).strict(),
7602
+ error: HostApiErrorSchema
7603
+ }),
7604
+ addAdministrator: defineContract({
7605
+ method: "POST",
7606
+ path: "/api/administrators",
7607
+ params: EmptyParamsSchema,
7608
+ request: z.object({ identityId: PlatformIdentityIdSchema }).strict(),
7609
+ response: AdministratorSchema,
7610
+ error: HostApiErrorSchema
7611
+ }),
7612
+ removeAdministrator: defineContract({
7613
+ method: "POST",
7614
+ path: "/api/administrators/remove",
7615
+ params: EmptyParamsSchema,
7616
+ request: z.object({
7617
+ connectionId: ConnectionIdSchema,
7618
+ platformUserId: z.string().min(1)
7619
+ }).strict(),
7620
+ response: z.object({ ok: z.literal(true) }).strict(),
7621
+ error: HostApiErrorSchema
7622
+ }),
7623
+ createAdministratorClaimCode: defineContract({
7624
+ method: "POST",
7625
+ path: "/api/administrators/claim-code",
7626
+ params: EmptyParamsSchema,
7627
+ request: NoRequestBodySchema,
7628
+ response: z.object({
7629
+ code: z.string(),
7630
+ expiresAt: z.number().int().nonnegative()
7631
+ }).strict(),
7632
+ error: HostApiErrorSchema
7633
+ }),
7634
+ dismissCommunityRelease: defineContract({
7635
+ method: "POST",
7636
+ path: "/api/community/sync/:extensionId/dismiss",
7637
+ params: extensionParam,
7638
+ request: z.object({ releaseId: CommunityReleaseIdSchema.nullable() }).strict(),
7639
+ response: z.object({ ok: z.literal(true) }).strict(),
7640
+ error: HostApiErrorSchema
7641
+ }),
7642
+ updateFromCommunity: defineContract({
7643
+ invalidatesSnapshot: true,
7644
+ timeoutMs: 3e5,
7645
+ method: "POST",
7646
+ path: "/api/community/sync/:extensionId/update",
7647
+ params: extensionParam,
7648
+ request: NoRequestBodySchema,
7649
+ response: z.object({ message: z.string() }).strict(),
7650
+ error: HostApiErrorSchema
7651
+ }),
7652
+ archiveAuthoringTask: defineContract({
7653
+ invalidatesSnapshot: true,
7654
+ method: "POST",
7655
+ path: "/api/authoring/tasks/:taskId/archive",
7656
+ params: z.object({ taskId: AuthoringTaskIdSchema }).strict(),
7657
+ request: NoRequestBodySchema,
7658
+ response: z.object({ ok: z.literal(true) }).strict(),
7659
+ error: HostApiErrorSchema
5226
7660
  })
5227
7661
  };
5228
7662
  const pathParameterPattern = /:([A-Za-z][A-Za-z0-9]*)/gu;
@@ -5252,6 +7686,6 @@ function buildHostApiPath(name, input) {
5252
7686
  return buildValidatedHostApiPath(HostApiContracts[name], input);
5253
7687
  }
5254
7688
  //#endregion
5255
- export { ACTIVITY_MAX_BUCKETS, ACTIVITY_MAX_WINDOW_MS, ACTIVITY_MIN_BUCKET_MS, ActivityQuerySchema, AdapterActivityKeySchema, AdmissionIdSchema, AgentAppearanceSchema, AgentIdSchema, AgentRevisionChangedFieldSchema, AgentRevisionHistorySchema, AgentRevisionIdSchema, AssetIdSchema, AttentionItemSchema, AttentionListSchema, AuthoringAttemptIdSchema, AuthoringTaskIdSchema, CHANNEL_UNREAD_COUNT_CAP, COMMUNITY_EXTENSION_SORTS, COMMUNITY_LISTING_LIMITS, COMMUNITY_OFFICIAL_HANDLE, COMMUNITY_PERSONA_AVATAR_MAX_BYTES, COMMUNITY_PERSONA_AVATAR_TYPES, COMMUNITY_PERSONA_MAX_LENGTH, COMMUNITY_RATING_BADGES, COMMUNITY_RATING_BADGE_LIMIT, COMMUNITY_RATING_DIMENSIONS, COMMUNITY_RATING_DIMENSION_LABELS, COMMUNITY_REVIEWER_NAME, COMMUNITY_REVIEW_DIMENSION_LABELS, COMMUNITY_REVIEW_STATUSES, CONFIG_SCHEMA_MAX_BYTES, ChannelActivitySeriesSchema, ChannelActivitySummarySchema, ChannelEventIdSchema, ChannelFactSseDataSchema, ChannelFactSseItemSchema, ChannelIdSchema, ChannelMemberIdSchema, ChannelPendingContextSchema, ChannelPromptViewSchema, ChannelRuntimeCacheSampleSchema, ChannelRuntimeCacheSchema, ChannelRuntimeContextSchema, ChannelRuntimeInputSchema, ChannelRuntimeOccupancySchema, ChannelRuntimePerformanceSampleSchema, ChannelRuntimePerformanceSchema, ChannelRuntimePhaseSchema, ChannelRuntimeProjectionSchema, ChannelRuntimeSseDataSchema, ChannelRuntimeStepSchema, ChannelRuntimeToolSchema, ChannelRuntimeTurnSchema, ChannelRuntimeUsageSchema, ClientNotificationFeedResponseSchema, ClientNotificationSchema, CommunityAccountSchema, CommunityEndpointSchema, CommunityEnvironmentSchema, CommunityExtensionDetailSchema, CommunityExtensionSortSchema, CommunityExtensionSummarySchema, CommunityInstalledItemSchema, CommunityInstalledSchema, CommunityListingInputSchema, CommunityMyExtensionSchema, CommunityMyPersonaSchema, CommunityMyPersonasSchema, CommunityPermissionItemSchema, CommunityPersonaDetailSchema, CommunityPersonaIdSchema, CommunityPersonaReviewStatusSchema, CommunityPersonaRevisionIdSchema, CommunityPersonaSummarySchema, CommunityRatingSchema, CommunityReleaseIdSchema, CommunityReleaseSchema, CommunityReviewReportSchema, CommunityReviewStatusSchema, CommunitySourceSchema, CommunityStatusSchema, ConfigSchemaDocumentSchema, ConfigSchemaMetaSchema, ConfigSchemaNodeSchema, ConnectionEventIdSchema, ConnectionIdSchema, ConnectionPanelRoleSchema, ConnectionTestResultSchema, DshCredentialRefSchema, DshCredentialViewSchema, DshCredentialsChangedSseDataSchema, DshNxtHostUiSchema, DshPluginCatalogEntrySchema, DshPluginEntryIdSchema, DshPluginOperationSseDataSchema, DshPluginPackageIdSchema, DshSettingsChangedSseDataSchema, DshSettingsMutationRequestSchema, DshSettingsNamespaceSchema, DshSettingsPathOperationSchema, DshSettingsPathSchema, DynamicChangedSseDataSchema, DynamicClientApprovalPolicySchema, EMPTY_CONFIG_SCHEMA, EMPTY_EXTENSION_PERMISSIONS, EMPTY_EXTENSION_UI_CONTRIBUTIONS, EXTENSION_CONTEXT_DYNAMIC_MAX_CHARS, EXTENSION_CONTEXT_STATIC_MAX_CHARS, EXTENSION_DATA_HOOK_PERMISSIONS, EXTENSION_INBOUND_HOOK_MAX_TIMEOUT_MS, EXTENSION_JOB_MAX_RUNTIME, EXTENSION_LLM_MAX_CALLS_PER_TURN, EXTENSION_LLM_MAX_OUTPUT_TOKENS, EXTENSION_PROVIDES, EXTENSION_SDK_LEVEL, EXTENSION_STORAGE_DEFAULT_QUOTA_BYTES, EXTENSION_STORAGE_MAX_QUOTA_BYTES, EXTENSION_STORAGE_SCOPES, EpisodeHandoffIdSchema, EpisodeIdSchema, ExtensionActivationTransitionSchema, ExtensionCapabilitiesSchema, ExtensionConfigDeclarationSchema, ExtensionContextContributionSchema, ExtensionDeclaredJobSchema, ExtensionIdSchema, ExtensionImportInspectionSchema, ExtensionInboundHookCapabilitySchema, ExtensionJobsCapabilitySchema, ExtensionLayeredConfigSchema, ExtensionLlmCapabilitySchema, ExtensionMcpCapabilitySchema, ExtensionMcpServerNameSchema, ExtensionMcpServerSchema, ExtensionMcpValueSchema, ExtensionNetworkCapabilitySchema, ExtensionNetworkDomainSchema, ExtensionPanelAnchorSchema, ExtensionPanelDeclarationSchema, ExtensionPermissionRequirementSchema, ExtensionPermissionsSchema, ExtensionPlatformCapabilitySchema, ExtensionProvideSchema, ExtensionRequiresSchema, ExtensionRevisionIdSchema, ExtensionStorageCapabilitySchema, ExtensionStorageScopeSchema, ExtensionUiContributionsSchema, HOST_PAGE_DEFAULT_RAIL_ORDER, HOST_UI_KIT_COMPONENT_NAMES, HostApiContracts, HostApiErrorSchema, HostConnectionEventSchema, HostIconNameSchema, HostLayerCapabilitiesSchema, HostPageContributionSchema, HostPageIconSchema, HostSnapshotMessageSchema, HostSnapshotSchema, HostSseEventSchema, HostSseStatusDataSchema, HostSyncCursorSchema, HostUiKitComponentNameSchema, HostUiNavigationGroupSchema, HostUiNavigationItemSchema, HostUiNavigationModelSchema, HostUiNetworkOriginSchema, HostUiOwnerSchema, HostUiPageEntrySchema, HostUiPageGeometryEvidenceSchema, HostUiPageInstanceIdSchema, HostUiPagePreferencesSchema, HostUiPermissionDeclarationSchema, HostUiPermissionSchema, HostUpgradeSummarySchema, INSECURE_HTTP_MANAGEMENT_PAIR_PROOF_PREFIX, ImageUnderstandingPolicyApiSchema, InsecureHttpManagementChallengeResponseSchema, InstanceDescriptorSchema, InstanceDescriptorWireSchema, JsonValueSchema, LlmDiscoveredModelSchema, LlmModelInputModalitiesSchema, LlmProviderCredentialSchema, LlmProviderModelSchema, LlmProviderSettingsSchema, LlmProviderTestResultSchema, LlmProviderViewSchema, LogicalMessageIdSchema, MANAGEMENT_PAIR_PROOF_PREFIX, ManagementChallengeResponseSchema, ManagementDeviceEnrollmentRequestSchema, ManagementDeviceEnrollmentResponseSchema, ManagementDeviceIdSchema, ManagementDeviceViewSchema, ManagementSessionRequestSchema, ManagementSessionResponseSchema, McpServerFormSchema, MessagePartSchema, MessagePartsSchema, MessageRendererContributionSchema, NonEmptyMessagePartsSchema, NotificationEventKeySchema, NotificationSettingsViewSchema, OutboundIntentIdSchema, PANEL_ANCHOR_LAYER, PROMPT_DOCUMENT_MAX_PLAIN_TEXT_LENGTH, PROMPT_DOCUMENT_MAX_REFERENCES, PanelContributionSchema, PanelDensitySchema, PhysicalDeliveryIdSchema, PlatformIdentityIdSchema, PlatformUserListResponseSchema, PromptDocumentV1Schema, PromptSegmentSchema, RICH_EXTENSION_MAX_BYTES, RichExtensionSchema, RichKindSchema, RichTargetUrlSchema, RuntimeCompatibilityDiagnosticSchema, ScheduledTaskIdSchema, ScheduledTaskSchema, ServerInstanceIdSchema, TestBarkNotificationRequestSchema, ToolViewContributionSchema, ToolViewDensitySchema, UpdateNotificationSettingsRequestSchema, WorkTreeOrderSchema, activityDurationMs, agentPermissionDeclaration, buildHostApiContractPath, buildHostApiPath, communityPersonaReviewLabel, communityPublisherLabel, communityReviewLabel, configDescription, configFieldKind, configFields, configSchema, configSecretKeys, extensionCapabilitiesExpand, hostLayerAsCapabilities, hostPageRailOrder, hostPermissionDeclaration, insecureHttpManagementPairProofMessage, managementPairProofMessage, mcpSecretFields, messagePartAssetId, messagePartAssetIds, messagePartsSearchText, normalizePromptDocument, parseConfigValue, parseJsonValue, parseMessageParts, promptDocumentFromText, promptDocumentPlainText, richPartContextText, summarizeExtensionCapabilities, validateConfigValue };
7689
+ export { ACTIVITY_MAX_BUCKETS, ACTIVITY_MAX_WINDOW_MS, ACTIVITY_MIN_BUCKET_MS, ActivityQuerySchema, AdapterActivityKeySchema, AddCommandAccountRequestSchema, AdministratorSchema, AdmissionIdSchema, AgentAppearanceSchema, AgentIdSchema, AgentRevisionChangedFieldSchema, AgentRevisionHistorySchema, AgentRevisionIdSchema, AssetIdSchema, AttentionItemSchema, AttentionListSchema, AuthoringAttemptIdSchema, AuthoringTaskIdSchema, CHANNEL_COMPOSER_MAX_ATTACHMENTS, CHANNEL_COMPOSER_MAX_BYTES, CHANNEL_UNREAD_COUNT_CAP, COMMAND_DEFAULT_TIMEOUT_SECONDS, COMMAND_MAX_PROGRESS_REPLIES, COMMAND_MAX_TIMEOUT_SECONDS, COMMUNITY_EXTENSION_SORTS, COMMUNITY_FEEDBACK_STATUSES, COMMUNITY_FEEDBACK_STATUS_LABELS, 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, CommandAccountSchema, CommandAccountServiceSchema, CommandAccountUsageSchema, CommandAccountsViewSchema, CommandCatalogEntrySchema, CommandDefinitionSchema, CommandExecutionIdentitySchema, CommandExecutionRecordSchema, CommandParameterSchema, CommandPermissionSchema, CommandPolicySchema, CommandReplySchema, CommandResultSchema, CommunityAccountSchema, CommunityEndpointSchema, CommunityEnvironmentSchema, CommunityExtensionDetailSchema, CommunityExtensionSortSchema, CommunityExtensionSummarySchema, CommunityFeedbackAffectedSchema, CommunityFeedbackChangesSchema, CommunityFeedbackConfirmSchema, CommunityFeedbackCreateSchema, CommunityFeedbackDiagnosticEntrySchema, CommunityFeedbackDiagnosticsSchema, CommunityFeedbackDigestSchema, CommunityFeedbackDraftIdSchema, CommunityFeedbackDraftInputSchema, CommunityFeedbackDraftSchema, CommunityFeedbackDraftStateSchema, CommunityFeedbackDraftUpdateSchema, CommunityFeedbackEventDataSchema, CommunityFeedbackEventSchema, CommunityFeedbackExcerptSchema, CommunityFeedbackExtensionDiagnosticSchema, CommunityFeedbackIdSchema, CommunityFeedbackItemSchema, CommunityFeedbackKindSchema, CommunityFeedbackLabelsSchema, CommunityFeedbackLastPayloadSchema, CommunityFeedbackLinkSchema, CommunityFeedbackListSchema, CommunityFeedbackLocalListSchema, CommunityFeedbackMessageInputSchema, CommunityFeedbackMessageSchema, CommunityFeedbackPayloadSchema, CommunityFeedbackRefSchema, CommunityFeedbackReopenSchema, CommunityFeedbackSchema, CommunityFeedbackSettingsSchema, CommunityFeedbackSettingsUpdateSchema, CommunityFeedbackSnapshotSchema, CommunityFeedbackStatusSchema, CommunityFeedbackSummarySchema, CommunityFeedbackSupplementSchema, CommunityFeedbackTargetSchema, CommunityFeedbackTransitionSchema, CommunityFeedbackVisibilitySchema, CommunityFeedbackWithdrawSchema, CommunityInstalledItemSchema, CommunityInstalledSchema, CommunityListingInputSchema, CommunityMyExtensionSchema, CommunityMyPersonaSchema, CommunityMyPersonasSchema, CommunityPermissionItemSchema, CommunityPersonaDetailSchema, CommunityPersonaIdSchema, CommunityPersonaReviewStatusSchema, CommunityPersonaRevisionIdSchema, CommunityPersonaSummarySchema, CommunityRatingSchema, CommunityReleaseIdSchema, CommunityReleaseSchema, CommunityReviewReportSchema, CommunityReviewStatusSchema, CommunitySourceSchema, CommunityStatusSchema, CommunitySyncItemSchema, CommunitySyncSchema, ConfigSchemaDocumentSchema, ConfigSchemaMetaSchema, ConfigSchemaNodeSchema, ConnectionEventIdSchema, ConnectionIdSchema, ConnectionPanelRoleSchema, ConnectionTestResultSchema, DEFAULT_CHANNEL_CONTEXT_POLICY, DEFAULT_MESSAGE_PACING, DEFAULT_SUB_CONVERSATION_RETENTION, 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_GOVERNANCE_SDK_LEVEL, 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, ExtensionDataMigrationInputSchema, ExtensionDataPackageInspectionSchema, ExtensionDataPreviewSchema, ExtensionDataSourceSchema, ExtensionDataStateSchema, ExtensionDeclaredJobSchema, ExtensionIdSchema, ExtensionImportInspectionSchema, ExtensionInboundHookCapabilitySchema, ExtensionIndexCapabilitySchema, ExtensionIndexCollectionSchema, ExtensionJobsCapabilitySchema, ExtensionLayeredConfigSchema, ExtensionLineageNodeSchema, ExtensionLineageSchema, ExtensionLlmCapabilitySchema, ExtensionMcpCapabilitySchema, ExtensionMcpServerNameSchema, ExtensionMcpServerSchema, ExtensionMcpValueSchema, ExtensionModelsCapabilitySchema, ExtensionNetworkCapabilitySchema, ExtensionNetworkDomainSchema, ExtensionPanelAnchorSchema, ExtensionPanelDeclarationSchema, ExtensionPermissionRequirementSchema, ExtensionPermissionsSchema, ExtensionPlatformCapabilitySchema, ExtensionProvideSchema, ExtensionRequestSchema, ExtensionRequiresSchema, ExtensionRevisionIdSchema, ExtensionStorageCapabilitySchema, ExtensionStorageScopeSchema, ExtensionUiContributionsSchema, GithubCliAvailabilitySchema, 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, LocalGithubLoginSchema, LogicalMessageIdSchema, MANAGEMENT_PAIR_PROOF_PREFIX, ManagementChallengeResponseSchema, ManagementDeviceEnrollmentRequestSchema, ManagementDeviceEnrollmentResponseSchema, ManagementDeviceIdSchema, ManagementDeviceViewSchema, ManagementSessionRequestSchema, ManagementSessionResponseSchema, McpServerFormSchema, MessageDeliverySummarySchema, 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, SubConversationIdSchema, SubConversationRetentionSchema, SubConversationSchema, SubConversationSettingsSchema, TestBarkNotificationRequestSchema, ToolViewContributionSchema, ToolViewDensitySchema, UpdateNotificationSettingsRequestSchema, UpgradeBackupModeSchema, UpgradeBackupSettingsSchema, VerificationBrowserAvailabilitySchema, WorkTreeOrderSchema, activityDurationMs, agentPermissionDeclaration, buildHostApiContractPath, buildHostApiPath, commandNameOf, commandUsage, communityPersonaReviewLabel, communityPublisherLabel, communityReviewLabel, configDescription, configFieldKind, configFields, configSchema, configSecretKeys, extensionCapabilitiesExpand, extensionSdkVersion, formatLogMessage, hostLayerAsCapabilities, hostLogDebugLeaseSchema, hostLogDebugRequestSchema, hostLogEntrySchema, hostLogLevelSchema, hostLogPageSchema, hostLogQuerySchema, hostLogScopeSchema, hostLogSettingsSchema, hostLogSettingsUpdateSchema, hostLogSourceKindSchema, hostLogSourceSchema, hostLogStatusSchema, hostLogStreamEventSchema, hostPageRailOrder, hostPermissionDeclaration, insecureHttpManagementPairProofMessage, managementPairProofMessage, mcpSecretFields, messagePartAssetId, messagePartAssetIds, messagePartImageAssetIds, messagePartsSearchText, normalizePromptDocument, parseCommandArguments, parseConfigValue, parseJsonValue, parseMessageParts, promptDocumentFromText, promptDocumentPlainText, recognizeCommand, requiredExtensionSdkLevel, richPartContextText, summarizeExtensionCapabilities, tokenizeCommand, undeliveredCommandReplies, validateConfigValue };
5256
7690
 
5257
7691
  //# sourceMappingURL=index.mjs.map