@nekro-nxt/contracts 0.4.0 → 0.6.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 (50) hide show
  1. package/README.md +2 -0
  2. package/dist/index.mjs +3092 -164
  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 +260 -13
  13. package/lib/types/community.d.ts.map +1 -1
  14. package/lib/types/config-schema.d.ts +16 -2
  15. package/lib/types/config-schema.d.ts.map +1 -1
  16. package/lib/types/credentials.d.ts +328 -0
  17. package/lib/types/credentials.d.ts.map +1 -0
  18. package/lib/types/domain.d.ts +44 -2
  19. package/lib/types/domain.d.ts.map +1 -1
  20. package/lib/types/extension-capabilities.d.ts +58 -3
  21. package/lib/types/extension-capabilities.d.ts.map +1 -1
  22. package/lib/types/extension-ui.d.ts +46 -4
  23. package/lib/types/extension-ui.d.ts.map +1 -1
  24. package/lib/types/host-api.d.ts +10805 -2887
  25. package/lib/types/host-api.d.ts.map +1 -1
  26. package/lib/types/index.d.ts +7 -0
  27. package/lib/types/index.d.ts.map +1 -1
  28. package/lib/types/linked-accounts.d.ts +100 -0
  29. package/lib/types/linked-accounts.d.ts.map +1 -0
  30. package/lib/types/logs.d.ts +355 -0
  31. package/lib/types/logs.d.ts.map +1 -0
  32. package/lib/types/response-timing.d.ts +60 -0
  33. package/lib/types/response-timing.d.ts.map +1 -0
  34. package/lib/types/runtime-compatibility.d.ts +2 -2
  35. package/package.json +1 -1
  36. package/src/commands.ts +366 -0
  37. package/src/community-feedback-host.ts +121 -0
  38. package/src/community-feedback.ts +289 -0
  39. package/src/community.ts +63 -1
  40. package/src/config-schema.ts +33 -2
  41. package/src/credentials.ts +260 -0
  42. package/src/domain.ts +74 -8
  43. package/src/extension-capabilities.ts +78 -4
  44. package/src/extension-ui.ts +3 -0
  45. package/src/host-api.ts +1873 -163
  46. package/src/index.ts +8 -0
  47. package/src/linked-accounts.ts +77 -0
  48. package/src/logs.ts +138 -0
  49. package/src/management-api.ts +1 -1
  50. package/src/response-timing.ts +77 -0
package/dist/index.mjs CHANGED
@@ -1,5 +1,34 @@
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
+ /** Extensions that changed the message before it was sent, the content they produced and what they appended. */
26
+ processing: z.object({
27
+ processedBy: z.array(z.string()),
28
+ parts: z.array(z.unknown()).optional(),
29
+ followUps: z.array(z.string()).optional()
30
+ }).strict().optional()
31
+ }).strict();
3
32
  const brandedId = (prefix, brand) => z.string().regex(new RegExp(`^${prefix}_[0-9A-Za-z]+$`), `${brand} has an invalid format.`).brand(brand);
4
33
  const AgentIdSchema = brandedId("agt", "AgentId");
5
34
  const AgentRevisionIdSchema = brandedId("arev", "AgentRevisionId");
@@ -23,6 +52,9 @@ const DshPluginEntryIdSchema = brandedId("dse", "DshPluginEntryId");
23
52
  const HostUiPageInstanceIdSchema = brandedId("hup", "HostUiPageInstanceId");
24
53
  const AuthoringTaskIdSchema = brandedId("aut", "AuthoringTaskId");
25
54
  const AuthoringAttemptIdSchema = brandedId("aua", "AuthoringAttemptId");
55
+ const SubConversationIdSchema = brandedId("cnv", "SubConversationId");
56
+ const CredentialIdSchema = brandedId("crd", "CredentialId");
57
+ const LinkedAccountIdSchema = brandedId("acc", "LinkedAccountId");
26
58
  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
59
  const PromptTextSegmentSchema = z.object({
28
60
  type: z.literal("text"),
@@ -119,7 +151,12 @@ const MessagePartSchema = z.discriminatedUnion("type", [
119
151
  z.object({
120
152
  type: z.literal("image"),
121
153
  assetId: AssetIdSchema,
122
- alt: z.string().optional()
154
+ alt: z.string().optional(),
155
+ /**
156
+ * The platform reported the picture as a sticker. A hint only: a sticker dragged in from a desktop client and
157
+ * pictures from platforms without this signal arrive unmarked.
158
+ */
159
+ sticker: z.literal(true).optional()
123
160
  }).strict(),
124
161
  z.object({
125
162
  type: z.literal("file"),
@@ -151,17 +188,17 @@ const NonEmptyMessagePartsSchema = MessagePartsSchema.min(1);
151
188
  function parseMessageParts(input) {
152
189
  return MessagePartsSchema.parse(input);
153
190
  }
154
- const collectRichAssetIds = (value, into) => {
191
+ const collectRichAssetIds = (value, into, imagesOnly = false) => {
155
192
  if (value === null || value === void 0 || typeof value === "boolean" || typeof value === "number") return;
156
193
  if (typeof value === "string") return;
157
194
  if (Array.isArray(value)) {
158
- for (const item of value) collectRichAssetIds(item, into);
195
+ for (const item of value) collectRichAssetIds(item, into, imagesOnly);
159
196
  return;
160
197
  }
161
- for (const [key, child] of Object.entries(value)) if ((key === "imageAssetId" || key === "previewAssetId") && typeof child === "string") {
198
+ for (const [key, child] of Object.entries(value)) if ((key === "imageAssetId" || key === "previewAssetId" || !imagesOnly && (key === "audioAssetId" || key === "fileAssetId")) && typeof child === "string") {
162
199
  const parsed = AssetIdSchema.safeParse(child);
163
200
  if (parsed.success) into.push(parsed.data);
164
- } else collectRichAssetIds(child, into);
201
+ } else collectRichAssetIds(child, into, imagesOnly);
165
202
  };
166
203
  const messagePartAssetIds = (part) => {
167
204
  if (part.type === "image" || part.type === "file" || part.type === "audio") return [part.assetId];
@@ -172,6 +209,14 @@ const messagePartAssetIds = (part) => {
172
209
  return ids;
173
210
  };
174
211
  const messagePartAssetId = (part) => messagePartAssetIds(part)[0];
212
+ /** Only actual pictures enter visual context; forwarded files and recordings retain their own media kind. */
213
+ const messagePartImageAssetIds = (part) => {
214
+ if (part.type === "image") return [part.assetId];
215
+ if (part.type !== "rich") return [];
216
+ const ids = part.previewAssetId ? [part.previewAssetId] : [];
217
+ collectRichAssetIds(part.extension, ids, true);
218
+ return ids;
219
+ };
175
220
  const asJsonRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
176
221
  const richItemLine = (value) => {
177
222
  const item = asJsonRecord(value);
@@ -182,10 +227,14 @@ const richItemLine = (value) => {
182
227
  const cardSummary = typeof card?.["summary"] === "string" ? card["summary"] : typeof card?.["title"] === "string" ? card["title"] : void 0;
183
228
  const imageName = typeof item["imageName"] === "string" ? item["imageName"] : void 0;
184
229
  const imageText = typeof item["imageAssetId"] === "string" ? `[图片${imageName ? ` ${imageName}` : ""}]` : void 0;
230
+ const audioText = typeof item["audioAssetId"] === "string" ? `[语音 ${item["audioAssetId"]}]` : void 0;
231
+ 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
232
  const body = [
186
233
  text,
187
234
  cardSummary ? `[卡片] ${cardSummary}` : void 0,
188
- imageText
235
+ imageText,
236
+ audioText,
237
+ fileText
189
238
  ].filter((part) => Boolean(part && part.length > 0)).join(" ");
190
239
  if (!sender && !body) return void 0;
191
240
  return sender ? `${sender}:${body}` : body;
@@ -216,8 +265,9 @@ const messagePartsSearchText = (parts) => parts.flatMap((part) => {
216
265
  * product form can render and the Host can validate without executing Schema callbacks.
217
266
  *
218
267
  * Supported nodes: object (dict), string, number, natural, percent, boolean, const, union of consts (enum) and
219
- * array of primitives. `meta.role: 'secret'` marks a write-only credential. NekroNXT reads three extra meta keys:
220
- * `hint` (help text), `advanced` (collapsed by default) and `visibleWhen` (show only when a sibling equals a value).
268
+ * array of primitives. `meta.role: 'secret'` marks a write-only credential. NekroNXT reads four extra meta keys:
269
+ * `hint` (help text), `advanced` (collapsed by default), `visibleWhen` (show only when a sibling equals a value) and
270
+ * `agentWritable: false` (only an administrator may change the field, in the console).
221
271
  */
222
272
  const CONFIG_SCHEMA_MAX_BYTES = 64 * 1024;
223
273
  const DescriptionSchema = z.union([z.string(), z.record(z.string(), z.string())]);
@@ -237,6 +287,8 @@ const ConfigSchemaMetaSchema = z.object({
237
287
  }).optional(),
238
288
  advanced: z.boolean().optional(),
239
289
  group: z.string().max(40).optional(),
290
+ /** `false` keeps the field out of the agent's reach: only an administrator changes it, in the console. */
291
+ agentWritable: z.boolean().optional(),
240
292
  visibleWhen: z.object({
241
293
  key: z.string().min(1).max(64),
242
294
  equals: JsonValueSchema
@@ -281,6 +333,11 @@ const EMPTY_CONFIG_SCHEMA = {
281
333
  type: "object",
282
334
  dict: {}
283
335
  };
336
+ const configFieldLevel = (field, networkFields) => {
337
+ if (field.adminOnly) return "admin";
338
+ if (field.kind === "secret") return "secret";
339
+ return (networkFields instanceof Set ? networkFields : new Set(networkFields)).has(field.key) ? "network" : "normal";
340
+ };
284
341
  const configDescription = (meta) => {
285
342
  const description = meta?.description;
286
343
  if (typeof description === "string") return description;
@@ -319,9 +376,12 @@ const configFields = (document) => Object.entries(document.dict).map(([key, node
319
376
  advanced: node.meta?.advanced === true,
320
377
  ...node.meta?.group === void 0 ? {} : { group: node.meta.group },
321
378
  ...options === void 0 ? {} : { options },
379
+ adminOnly: node.meta?.agentWritable === false,
322
380
  node
323
381
  };
324
382
  });
383
+ /** Fields declared `meta.agentWritable: false`. */
384
+ const adminOnlyConfigKeys = (document) => configFields(document).filter((field) => field.adminOnly).map((field) => field.key);
325
385
  const configSecretKeys = (document) => configFields(document).filter((field) => field.kind === "secret").map((field) => field.key);
326
386
  const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
327
387
  const sameJson = (left, right) => JSON.stringify(left) === JSON.stringify(right);
@@ -475,7 +535,8 @@ const fieldMeta = (title, options = {}) => ({
475
535
  ...options.default === void 0 ? {} : { default: options.default },
476
536
  ...options.required === void 0 ? {} : { required: options.required },
477
537
  ...options.advanced === void 0 ? {} : { advanced: options.advanced },
478
- ...options.group === void 0 ? {} : { group: options.group }
538
+ ...options.group === void 0 ? {} : { group: options.group },
539
+ ...options.agentWritable === void 0 ? {} : { agentWritable: options.agentWritable }
479
540
  });
480
541
  /** Builds serialized Schemastery documents without depending on the Schemastery runtime. */
481
542
  const configSchema = {
@@ -525,9 +586,16 @@ const configSchema = {
525
586
  * Host capability level this build implements. A Revision that declares `requires.sdk` above it is rejected at
526
587
  * import with an "upgrade NekroNXT" message instead of an opaque schema error. Bump when a Manifest capability
527
588
  * ships; never reuse a level for a different meaning. Level 7 is Manifest V7 (host instance + agent attachments); level 8 adds the asset library, image info, tool result
528
- * images, the search index and host-layer model calls.
589
+ * 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
590
+ * migration hook and administrator-only commands. Level 11 lists the pictures of an inbound message to inbound hooks.
591
+ * Level 12 adds credential placeholders (`secrets.placeholder`) that `http.fetch` fills for the credential's domains.
592
+ * Level 13 adds outbound processing (`harness.onOutbound`, `permissions.agent.outbound`).
529
593
  */
530
- const EXTENSION_SDK_LEVEL = 8;
594
+ const EXTENSION_SDK_LEVEL = 13;
595
+ /** Outbound processing needs this level; packages that declare `permissions.agent.outbound` declare it. */
596
+ const EXTENSION_OUTBOUND_SDK_LEVEL = 13;
597
+ /** Lineage, `dataVersion` and administrator-only commands need this level; packages that carry them declare it. */
598
+ const EXTENSION_GOVERNANCE_SDK_LEVEL = 10;
531
599
  /**
532
600
  * The first NekroNXT version of each capability level, so users read "needs NekroNXT 0.5.0" rather than a level
533
601
  * number. Add the row for a new level in the change that raises EXTENSION_SDK_LEVEL; a test keeps the two in step.
@@ -544,6 +612,26 @@ const EXTENSION_SDK_RELEASES = [
544
612
  {
545
613
  level: 8,
546
614
  version: "0.5.0"
615
+ },
616
+ {
617
+ level: 9,
618
+ version: "0.6.0"
619
+ },
620
+ {
621
+ level: 10,
622
+ version: "0.6.0"
623
+ },
624
+ {
625
+ level: 11,
626
+ version: "0.6.0"
627
+ },
628
+ {
629
+ level: 12,
630
+ version: "0.7.0"
631
+ },
632
+ {
633
+ level: 13,
634
+ version: "0.7.0"
547
635
  }
548
636
  ];
549
637
  /** The oldest NekroNXT version that supports `level`; undefined for a level no release supports yet. */
@@ -603,6 +691,21 @@ const ExtensionInboundHookCapabilitySchema = z.object({
603
691
  mayForceTrigger: z.boolean(),
604
692
  timeoutMs: z.number().int().min(100).max(EXTENSION_INBOUND_HOOK_MAX_TIMEOUT_MS)
605
693
  }).strict();
694
+ const EXTENSION_OUTBOUND_MAX_TIMEOUT_MS = 15e3;
695
+ /**
696
+ * Outbound processing of the agent's own messages. `read` sees each message after it was delivered; `transform` may
697
+ * replace its content or append messages before it is sent; `cancel` may stop it. `onTimeout` decides what happens
698
+ * when the handler times out or throws before sending: `send` (default) sends the message as it is.
699
+ */
700
+ const ExtensionOutboundCapabilitySchema = z.object({
701
+ read: z.literal(true).optional(),
702
+ transform: z.literal(true).optional(),
703
+ cancel: z.literal(true).optional(),
704
+ timeoutMs: z.number().int().min(100).max(EXTENSION_OUTBOUND_MAX_TIMEOUT_MS),
705
+ onTimeout: z.enum(["send", "cancel"]).optional()
706
+ }).strict().refine((value) => value.read === true || value.transform === true || value.cancel === true, "outbound 至少声明 read、transform 或 cancel 中的一项。");
707
+ /** Whether the extension takes part before sending (and so in the agent's processing order). */
708
+ const outboundProcessesBeforeSend = (outbound) => outbound?.transform === true || outbound?.cancel === true;
606
709
  const EXTENSION_JOB_MAX_RUNTIME = 50;
607
710
  const ExtensionDeclaredJobSchema = z.object({
608
711
  id: z.string().trim().regex(/^[a-z0-9][a-z0-9-]{0,39}$/u, "定时任务 id 只能使用小写字母、数字和连字符。"),
@@ -665,8 +768,15 @@ const ExtensionModelsCapabilitySchema = z.object({
665
768
  maxCallsPerMinute: z.number().int().min(1).max(120),
666
769
  maxOutputTokens: z.number().int().min(64).max(EXTENSION_LLM_MAX_OUTPUT_TOKENS)
667
770
  }).strict();
668
- /** A header or environment value: literal text, or the current value of a `meta.role: 'secret'` config field. */
669
- const ExtensionMcpValueSchema = z.union([z.string().max(4096), z.object({ secret: z.string().trim().min(1).max(64) }).strict()]);
771
+ /**
772
+ * A header or environment value: literal text, the current value of a `meta.role: 'secret'` config field, or a named
773
+ * credential (by id or name) that the agent may use.
774
+ */
775
+ const ExtensionMcpValueSchema = z.union([
776
+ z.string().max(4096),
777
+ z.object({ secret: z.string().trim().min(1).max(64) }).strict(),
778
+ z.object({ credential: z.string().trim().min(1).max(64) }).strict()
779
+ ]);
670
780
  /** Becomes the model-facing tool prefix `mcp__<name>__`. */
671
781
  const ExtensionMcpServerNameSchema = z.string().regex(/^[A-Za-z0-9_-]{1,32}$/u);
672
782
  const McpValueMapSchema = z.record(z.string().regex(/^[A-Za-z_][A-Za-z0-9_-]{0,127}$/u), ExtensionMcpValueSchema).refine((value) => Object.keys(value).length <= 32, "最多 32 项。").default({});
@@ -691,7 +801,9 @@ const ExtensionMcpCapabilitySchema = z.object({ servers: z.array(ExtensionMcpSer
691
801
  const McpFormValueSchema = z.object({
692
802
  name: z.string().regex(/^[A-Za-z_][A-Za-z0-9_-]{0,127}$/u, "名称只能包含字母、数字、下划线和连字符。"),
693
803
  value: z.string().max(4096),
694
- secret: z.boolean().default(false)
804
+ secret: z.boolean().default(false),
805
+ /** Takes the value from this named credential instead; `value` and `secret` are then ignored. */
806
+ credential: z.string().trim().min(1).max(64).optional()
695
807
  }).strict();
696
808
  const McpServerFormSchema = z.discriminatedUnion("transport", [z.object({
697
809
  transport: z.literal("streamable-http"),
@@ -706,7 +818,7 @@ const McpServerFormSchema = z.discriminatedUnion("transport", [z.object({
706
818
  env: z.array(McpFormValueSchema).max(32).default([])
707
819
  }).strict()]);
708
820
  /** Secret config fields an MCP declaration reads. */
709
- const mcpSecretFields = (mcp) => [...new Set((mcp?.servers ?? []).flatMap((server) => Object.values(server.transport === "stdio" ? server.env : server.headers).flatMap((value) => typeof value === "string" ? [] : [value.secret])))];
821
+ const mcpSecretFields = (mcp) => [...new Set((mcp?.servers ?? []).flatMap((server) => Object.values(server.transport === "stdio" ? server.env : server.headers).flatMap((value) => typeof value === "string" || !("secret" in value) ? [] : [value.secret])))];
710
822
  /** What a server connects to; changing it needs a new approval, unlike its credentials. */
711
823
  const mcpTarget = (server) => server.transport === "stdio" ? JSON.stringify([
712
824
  "stdio",
@@ -731,6 +843,7 @@ const ExtensionCapabilitiesSchema = z.object({
731
843
  models: ExtensionModelsCapabilitySchema.optional(),
732
844
  history: z.object({ read: z.literal(true) }).strict().optional(),
733
845
  inboundHook: ExtensionInboundHookCapabilitySchema.optional(),
846
+ outbound: ExtensionOutboundCapabilitySchema.optional(),
734
847
  jobs: ExtensionJobsCapabilitySchema.optional(),
735
848
  platform: ExtensionPlatformCapabilitySchema.optional(),
736
849
  llm: ExtensionLlmCapabilitySchema.optional(),
@@ -794,6 +907,9 @@ const extensionCapabilitiesExpand = (previous, next) => {
794
907
  const hook = next.inboundHook;
795
908
  const previousHook = previous?.inboundHook;
796
909
  if (hook !== void 0 && (previousHook === void 0 || hook.reads === "all" && previousHook.reads === "triggered" || hook.mayHide && !previousHook.mayHide || hook.mayForceTrigger && !previousHook.mayForceTrigger)) return true;
910
+ const outbound = next.outbound;
911
+ const previousOutbound = previous?.outbound;
912
+ if (outbound !== void 0 && (previousOutbound === void 0 || outbound.read === true && previousOutbound.read !== true || outbound.transform === true && previousOutbound.transform !== true || outbound.cancel === true && previousOutbound.cancel !== true || outbound.onTimeout === "cancel" && previousOutbound.onTimeout !== "cancel")) return true;
797
913
  if (next.jobs?.runtime !== void 0 && (previous?.jobs?.runtime === void 0 || next.jobs.runtime.maxActive > previous.jobs.runtime.maxActive)) return true;
798
914
  const previousMcp = new Set((previous?.mcp?.servers ?? []).map(mcpTarget));
799
915
  if ((next.mcp?.servers ?? []).some((server) => !previousMcp.has(mcpTarget(server)))) return true;
@@ -878,6 +994,29 @@ const summarizeExtensionCapabilities = (capabilities, options = {}) => {
878
994
  ...effects === "" ? {} : { detail: `可以${effects}` }
879
995
  });
880
996
  }
997
+ const outbound = capabilities.outbound;
998
+ if (outbound !== void 0) {
999
+ if (outbound.transform === true) items.push({
1000
+ key: "outbound.transform",
1001
+ risk: "high",
1002
+ label: "在智能体的消息发出前修改内容或追加消息"
1003
+ });
1004
+ if (outbound.cancel === true) items.push({
1005
+ key: "outbound.cancel",
1006
+ risk: "high",
1007
+ label: "取消智能体要发出的消息"
1008
+ });
1009
+ if (outbound.read === true) items.push({
1010
+ key: "outbound.read",
1011
+ risk: "sensitive",
1012
+ label: "查看智能体发出的每条消息"
1013
+ });
1014
+ if (outbound.onTimeout === "cancel" && (outbound.transform === true || outbound.cancel === true)) items.push({
1015
+ key: "outbound.onTimeout",
1016
+ risk: "high",
1017
+ label: "这个扩展出错时,智能体的消息会发不出去"
1018
+ });
1019
+ }
881
1020
  const jobs = capabilities.jobs;
882
1021
  if (jobs?.declared !== void 0 && jobs.declared.length > 0) items.push({
883
1022
  key: "jobs.declared",
@@ -1326,6 +1465,10 @@ const requiredExtensionSdkLevel = (permissions) => {
1326
1465
  permissions?.host?.index === void 0 && permissions?.agent?.index === void 0 ? void 0 : "检索索引",
1327
1466
  permissions?.host?.models === void 0 ? void 0 : "本机层模型调用"
1328
1467
  ].filter((name) => name !== void 0);
1468
+ if (permissions?.agent?.outbound !== void 0) return {
1469
+ level: 13,
1470
+ capabilities: ["出站处理"]
1471
+ };
1329
1472
  return level8.length > 0 ? {
1330
1473
  level: 8,
1331
1474
  capabilities: [...new Set(level8)]
@@ -1335,6 +1478,683 @@ const requiredExtensionSdkLevel = (permissions) => {
1335
1478
  };
1336
1479
  };
1337
1480
  //#endregion
1481
+ //#region src/commands.ts
1482
+ const COMMAND_DEFAULT_TIMEOUT_SECONDS = 60;
1483
+ const COMMAND_MAX_TIMEOUT_SECONDS = 600;
1484
+ /**
1485
+ * Who may run a command. `channel-admin` is granted per channel; `admin` is an instance administrator (the signed-in
1486
+ * console or a platform account listed in Settings → Administrators) and also holds every channel's `channel-admin`.
1487
+ */
1488
+ const CommandPermissionSchema = z.enum([
1489
+ "public",
1490
+ "channel-admin",
1491
+ "admin"
1492
+ ]);
1493
+ const nameSchema = z.string().min(1).max(64).regex(/^[\p{L}\p{N}_-]+$/u);
1494
+ const scalarSchema = z.union([
1495
+ z.string(),
1496
+ z.number().finite(),
1497
+ z.boolean()
1498
+ ]);
1499
+ const CommandParameterSchema = z.object({
1500
+ name: nameSchema,
1501
+ description: z.string().max(500).optional(),
1502
+ kind: z.enum(["positional", "option"]),
1503
+ type: z.enum([
1504
+ "string",
1505
+ "number",
1506
+ "integer",
1507
+ "boolean"
1508
+ ]),
1509
+ required: z.boolean().optional(),
1510
+ default: scalarSchema.optional(),
1511
+ choices: z.array(scalarSchema).min(1).max(100).optional(),
1512
+ min: z.number().finite().optional(),
1513
+ max: z.number().finite().optional()
1514
+ }).strict();
1515
+ const CommandDefinitionSchema = z.object({
1516
+ name: nameSchema,
1517
+ aliases: z.array(nameSchema).max(16).default([]),
1518
+ description: z.string().min(1).max(1e3),
1519
+ parameters: z.array(CommandParameterSchema).max(32).default([]),
1520
+ examples: z.array(z.string().max(2e3)).max(16).default([]),
1521
+ minimumPermission: CommandPermissionSchema.default("public"),
1522
+ enabledByDefault: z.boolean().default(true),
1523
+ /**
1524
+ * Where the result goes when an administrator runs the command from the console (Web or Desktop) in an external
1525
+ * channel. `local` (default) shows it in the console only; `channel` also sends it through the bot account, and
1526
+ * the console labels the command accordingly. Platform-originated commands always reply in their conversation.
1527
+ */
1528
+ consoleReply: z.enum(["local", "channel"]).default("local"),
1529
+ /**
1530
+ * How long an extension handler may run before it is cancelled and recorded as timed out, so a stuck handler
1531
+ * cannot hold the channel's command queue. Built-in commands ignore it.
1532
+ */
1533
+ timeoutSeconds: z.number().int().min(1).max(600).default(60)
1534
+ }).strict().superRefine((definition, ctx) => {
1535
+ const names = [definition.name, ...definition.aliases];
1536
+ if (new Set(names).size !== names.length) ctx.addIssue({
1537
+ code: "custom",
1538
+ message: "命令名称和别名不能重复。"
1539
+ });
1540
+ if (new Set(definition.parameters.map((p) => p.name)).size !== definition.parameters.length) ctx.addIssue({
1541
+ code: "custom",
1542
+ message: "参数名称不能重复。"
1543
+ });
1544
+ let optional = false;
1545
+ for (const p of definition.parameters) {
1546
+ if (p.min !== void 0 && p.max !== void 0 && p.min > p.max) ctx.addIssue({
1547
+ code: "custom",
1548
+ message: `参数 ${p.name} 的范围无效。`
1549
+ });
1550
+ if (p.kind === "positional") {
1551
+ if (optional && p.required) ctx.addIssue({
1552
+ code: "custom",
1553
+ message: "必填位置参数必须在可选参数之前。"
1554
+ });
1555
+ if (!p.required || p.default !== void 0) optional = true;
1556
+ }
1557
+ if (p.default !== void 0) try {
1558
+ if (validateValue(p, String(p.default)) !== p.default) throw new Error("默认值类型不匹配。");
1559
+ } catch {
1560
+ ctx.addIssue({
1561
+ code: "custom",
1562
+ message: `参数 ${p.name} 的默认值无效。`
1563
+ });
1564
+ }
1565
+ }
1566
+ });
1567
+ const CommandPolicySchema = z.object({
1568
+ enabled: z.boolean().optional(),
1569
+ permission: CommandPermissionSchema.optional()
1570
+ }).strict();
1571
+ const CommandExecutionIdentitySchema = z.object({
1572
+ source: z.enum(["web", "platform"]),
1573
+ connectionId: ConnectionIdSchema.optional(),
1574
+ platformUserId: z.string().optional(),
1575
+ displayName: z.string(),
1576
+ viewerId: z.string().optional()
1577
+ }).strict();
1578
+ const CommandResultSchema = z.object({
1579
+ parts: z.array(MessagePartSchema).min(1).max(32).refine((parts) => parts.every((p) => [
1580
+ "text",
1581
+ "image",
1582
+ "file"
1583
+ ].includes(p.type)), "命令结果仅支持文本、图片和文件。"),
1584
+ summary: z.string().max(2e3).optional()
1585
+ }).strict();
1586
+ /** An execution may send a few progress replies before its final result. */
1587
+ const COMMAND_MAX_PROGRESS_REPLIES = 5;
1588
+ const CommandReplySchema = z.object({
1589
+ /** Position within the execution; the final result always has the highest ordinal. */
1590
+ ordinal: z.number().int().nonnegative(),
1591
+ kind: z.enum(["progress", "final"]),
1592
+ parts: CommandResultSchema.shape.parts,
1593
+ /** Set once the reply has an Outbound; absent with `error` means planning failed. */
1594
+ intentId: OutboundIntentIdSchema.optional(),
1595
+ error: z.string().optional()
1596
+ }).strict();
1597
+ const CommandExecutionRecordSchema = z.object({
1598
+ id: z.string().min(1),
1599
+ channelId: ChannelIdSchema,
1600
+ source: z.enum(["web", "platform"]),
1601
+ requestId: z.string().min(1).max(200),
1602
+ eventId: ChannelEventIdSchema.optional(),
1603
+ rawText: z.string(),
1604
+ identity: CommandExecutionIdentitySchema,
1605
+ commandName: z.string().optional(),
1606
+ commandVersion: z.string().optional(),
1607
+ extensionRevisionId: ExtensionRevisionIdSchema.optional(),
1608
+ agentId: AgentIdSchema.optional(),
1609
+ agentRevisionId: AgentRevisionIdSchema.optional(),
1610
+ status: z.enum([
1611
+ "pending",
1612
+ "running",
1613
+ "succeeded",
1614
+ "failed",
1615
+ "uncertain"
1616
+ ]),
1617
+ result: CommandResultSchema.optional(),
1618
+ error: z.string().optional(),
1619
+ /** Replies in send order. A platform command's replies go to its conversation; see `replyLocal`. */
1620
+ replies: z.array(CommandReplySchema).max(6).default([]),
1621
+ /** No reply is sent on purpose (unauthorized or unknown platform command, or console-local result). */
1622
+ replySuppressed: z.boolean().optional(),
1623
+ /** The result was kept in the console on purpose and never sent to the platform. */
1624
+ replyLocal: z.boolean().optional(),
1625
+ createdAt: z.number().int().nonnegative(),
1626
+ completedAt: z.number().int().nonnegative().optional()
1627
+ }).strict();
1628
+ /** Replies that still need an Outbound or a recorded failure. */
1629
+ const undeliveredCommandReplies = (record) => record.replySuppressed === true ? [] : record.replies.filter((reply) => reply.intentId === void 0 && reply.error === void 0);
1630
+ const CommandCatalogEntrySchema = z.object({
1631
+ definition: CommandDefinitionSchema,
1632
+ fullName: z.string(),
1633
+ source: z.string(),
1634
+ extensionRevisionId: ExtensionRevisionIdSchema.optional(),
1635
+ enabled: z.boolean(),
1636
+ permission: CommandPermissionSchema,
1637
+ usage: z.string(),
1638
+ available: z.boolean(),
1639
+ unavailableReason: z.string().optional(),
1640
+ globalPolicy: CommandPolicySchema.optional(),
1641
+ channelPolicy: CommandPolicySchema.optional()
1642
+ }).strict();
1643
+ /** Shell-like quoting without evaluation or interpolation. */
1644
+ function tokenizeCommand(text) {
1645
+ const tokens = [];
1646
+ let value = "", quote = "", escaped = false, started = false;
1647
+ for (const char of text) {
1648
+ if (escaped) {
1649
+ value += char;
1650
+ escaped = false;
1651
+ started = true;
1652
+ continue;
1653
+ }
1654
+ if (char === "\\") {
1655
+ escaped = true;
1656
+ started = true;
1657
+ continue;
1658
+ }
1659
+ if (quote) {
1660
+ if (char === quote) quote = "";
1661
+ else value += char;
1662
+ continue;
1663
+ }
1664
+ if (char === "\"" || char === "'") {
1665
+ quote = char;
1666
+ started = true;
1667
+ continue;
1668
+ }
1669
+ if (/\s/u.test(char)) {
1670
+ if (started) tokens.push(value);
1671
+ value = "";
1672
+ started = false;
1673
+ continue;
1674
+ }
1675
+ value += char;
1676
+ started = true;
1677
+ }
1678
+ if (escaped || quote) throw new Error("引号或转义未闭合。");
1679
+ if (started) tokens.push(value);
1680
+ return tokens;
1681
+ }
1682
+ function validateValue(p, raw) {
1683
+ let value = raw;
1684
+ if (p.type === "boolean") {
1685
+ if (!["true", "false"].includes(raw)) throw new Error(`参数 ${p.name} 必须为 true 或 false。`);
1686
+ value = raw === "true";
1687
+ } else if (p.type !== "string") {
1688
+ value = Number(raw);
1689
+ if (raw.trim() === "" || !Number.isFinite(value) || p.type === "integer" && !Number.isSafeInteger(value)) throw new Error(`参数 ${p.name} 必须为${p.type === "integer" ? "整数" : "数字"}。`);
1690
+ }
1691
+ const size = typeof value === "string" ? [...value].length : typeof value === "number" ? value : void 0;
1692
+ if (size !== void 0 && (p.min !== void 0 && size < p.min || p.max !== void 0 && size > p.max)) throw new Error(`参数 ${p.name} 超出允许范围。`);
1693
+ if (p.choices !== void 0 && !p.choices.includes(value)) throw new Error(`参数 ${p.name} 必须为:${p.choices.join("、")}。`);
1694
+ return value;
1695
+ }
1696
+ function parseCommandArguments(definition, tokens) {
1697
+ const args = /* @__PURE__ */ new Map();
1698
+ const positions = definition.parameters.filter((p) => p.kind === "positional");
1699
+ let index = 0, options = true;
1700
+ for (let i = 0; i < tokens.length; i++) {
1701
+ const token = tokens[i];
1702
+ if (options && token === "--") {
1703
+ options = false;
1704
+ continue;
1705
+ }
1706
+ let p, raw = token;
1707
+ if (options && token.startsWith("--")) {
1708
+ const equal = token.indexOf("=");
1709
+ const key = token.slice(2, equal < 0 ? void 0 : equal);
1710
+ p = definition.parameters.find((p) => p.kind === "option" && p.name === key);
1711
+ if (!p) throw new Error(`未知选项:--${key}`);
1712
+ if (equal >= 0) raw = token.slice(equal + 1);
1713
+ else if (p.type === "boolean" && (tokens[i + 1] === void 0 || !["true", "false"].includes(tokens[i + 1]))) raw = "true";
1714
+ else {
1715
+ const next = tokens[++i];
1716
+ if (next === void 0 || next.startsWith("--")) throw new Error(`选项 --${key} 缺少值。`);
1717
+ raw = next;
1718
+ }
1719
+ } else {
1720
+ p = positions[index++];
1721
+ if (!p) throw new Error(`多余参数:${token}`);
1722
+ }
1723
+ if (args.has(p.name)) throw new Error(`重复参数:${p.name}`);
1724
+ args.set(p.name, validateValue(p, raw));
1725
+ }
1726
+ for (const p of definition.parameters) {
1727
+ if (args.has(p.name)) continue;
1728
+ if (p.default !== void 0) args.set(p.name, p.default);
1729
+ else if (p.required) throw new Error(`缺少参数:${p.kind === "option" ? "--" : ""}${p.name}`);
1730
+ }
1731
+ return Object.fromEntries(args);
1732
+ }
1733
+ function commandUsage(definition, name = definition.name) {
1734
+ return "/" + name + definition.parameters.map((p) => {
1735
+ const value = p.kind === "option" ? `--${p.name} ${p.type === "boolean" ? "[true|false]" : `<${p.name}>`}` : `<${p.name}>`;
1736
+ return " " + (p.required ? value : `[${value}]`);
1737
+ }).join("");
1738
+ }
1739
+ function recognizeCommand(parts, botMemberId, options = {}) {
1740
+ let input = parts;
1741
+ while (input.length > 1 && input[0]?.type === "text" && input[0].text.trim() === "") input = input.slice(1);
1742
+ let addressed = options.addressed === true;
1743
+ let mentionPart = false;
1744
+ if (input[0]?.type === "mention") {
1745
+ if (botMemberId === void 0 || input[0].memberId !== botMemberId) return { kind: "chat" };
1746
+ input = input.slice(1);
1747
+ addressed = true;
1748
+ mentionPart = true;
1749
+ }
1750
+ if (options.requireMention === true && !addressed) return { kind: "chat" };
1751
+ if (input.length === 0 || input.some((p) => p.type !== "text")) return { kind: "chat" };
1752
+ let text = input.map((p) => p.type === "text" ? p.text : "").join("").trimStart();
1753
+ if (options.addressed === true && !mentionPart) text = text.replace(/^@\S+\s+/u, "");
1754
+ if (text.startsWith("//")) return {
1755
+ kind: "escaped",
1756
+ parts: [{
1757
+ type: "text",
1758
+ text: text.slice(1)
1759
+ }]
1760
+ };
1761
+ if (!text.startsWith("/")) return { kind: "chat" };
1762
+ return {
1763
+ kind: "command",
1764
+ text
1765
+ };
1766
+ }
1767
+ /** The command name a recognized text invokes (`/name args` → `name`). */
1768
+ const commandNameOf = (text) => /^\/(\S*)/u.exec(text.trimStart())?.[1] ?? "";
1769
+ //#endregion
1770
+ //#region src/logs.ts
1771
+ /** Log summaries are labels; leave structured diagnostics and stacks untouched. */
1772
+ function formatLogMessage(message) {
1773
+ return message.trimEnd().replace(/[。.]$/u, "");
1774
+ }
1775
+ const hostLogLevelSchema = z.enum([
1776
+ "debug",
1777
+ "info",
1778
+ "warn",
1779
+ "error"
1780
+ ]);
1781
+ const hostLogSourceKindSchema = z.enum([
1782
+ "system",
1783
+ "dsh-plugin",
1784
+ "extension",
1785
+ "connection",
1786
+ "unknown"
1787
+ ]);
1788
+ const hostLogSourceSchema = z.object({
1789
+ kind: hostLogSourceKindSchema,
1790
+ id: z.string().min(1).max(512),
1791
+ name: z.string().min(1).max(512),
1792
+ version: z.string().max(512).optional(),
1793
+ component: z.string().max(512).optional()
1794
+ }).strict();
1795
+ const hostLogScopeSchema = z.object({
1796
+ extensionId: z.string().max(512).optional(),
1797
+ revisionId: z.string().max(512).optional(),
1798
+ connectionId: z.string().max(512).optional(),
1799
+ agentId: z.string().max(512).optional(),
1800
+ channelId: z.string().max(512).optional(),
1801
+ sessionId: z.string().max(512).optional(),
1802
+ episodeId: z.string().max(512).optional(),
1803
+ operationId: z.string().max(512).optional()
1804
+ }).strict();
1805
+ const hostLogEntrySchema = z.object({
1806
+ id: z.string(),
1807
+ sequence: z.number().int().nonnegative(),
1808
+ timestamp: z.iso.datetime(),
1809
+ runId: z.string(),
1810
+ level: hostLogLevelSchema,
1811
+ message: z.string(),
1812
+ source: hostLogSourceSchema,
1813
+ scope: hostLogScopeSchema.optional(),
1814
+ details: z.json().optional(),
1815
+ code: z.string().optional(),
1816
+ redacted: z.boolean(),
1817
+ truncated: z.boolean()
1818
+ }).strict();
1819
+ const hostLogQuerySchema = z.object({
1820
+ levels: z.array(hostLogLevelSchema).max(4).optional(),
1821
+ sourceKinds: z.array(hostLogSourceKindSchema).max(5).optional(),
1822
+ sourceIds: z.array(z.string().max(512)).max(100).optional(),
1823
+ sources: z.array(hostLogSourceSchema.pick({
1824
+ kind: true,
1825
+ id: true
1826
+ })).max(100).optional(),
1827
+ scope: hostLogScopeSchema.optional(),
1828
+ keyword: z.string().max(1e3).optional(),
1829
+ from: z.iso.datetime().optional(),
1830
+ to: z.iso.datetime().optional(),
1831
+ olderCursor: z.string().max(128).optional(),
1832
+ afterCursor: z.string().max(128).optional(),
1833
+ headCursor: z.string().max(128).optional(),
1834
+ limit: z.number().int().min(1).max(500).optional()
1835
+ }).strict();
1836
+ const hostLogPageSchema = z.object({
1837
+ entries: z.array(hostLogEntrySchema),
1838
+ olderCursor: z.string().nullable(),
1839
+ headCursor: z.string(),
1840
+ hasMore: z.boolean(),
1841
+ gap: z.enum(["expired", "reset"]).optional()
1842
+ }).strict();
1843
+ const hostLogSettingsSchema = z.object({
1844
+ retentionDays: z.number().int().min(1).max(30),
1845
+ maxSizeMiB: z.number().int().min(64).max(2048),
1846
+ revision: z.number().int().nonnegative()
1847
+ }).strict();
1848
+ const hostLogSettingsUpdateSchema = hostLogSettingsSchema;
1849
+ const hostLogDebugRequestSchema = z.object({
1850
+ source: hostLogSourceSchema.pick({
1851
+ kind: true,
1852
+ id: true
1853
+ }).optional(),
1854
+ durationMinutes: z.union([
1855
+ z.literal(5),
1856
+ z.literal(15),
1857
+ z.literal(30)
1858
+ ]).default(15)
1859
+ }).strict();
1860
+ const hostLogDebugLeaseSchema = hostLogDebugRequestSchema.extend({
1861
+ id: z.string(),
1862
+ expiresAt: z.iso.datetime()
1863
+ });
1864
+ const hostLogStatusSchema = z.object({
1865
+ state: z.enum([
1866
+ "ready",
1867
+ "degraded",
1868
+ "closed"
1869
+ ]),
1870
+ runId: z.string(),
1871
+ headCursor: z.string(),
1872
+ bytes: z.number().nonnegative(),
1873
+ count: z.number().int().nonnegative(),
1874
+ oldestTimestamp: z.iso.datetime().nullable(),
1875
+ newestTimestamp: z.iso.datetime().nullable(),
1876
+ queuedBytes: z.number().nonnegative(),
1877
+ droppedCount: z.number().int().nonnegative(),
1878
+ debugLeases: z.array(hostLogDebugLeaseSchema),
1879
+ error: z.string().optional()
1880
+ }).strict();
1881
+ const hostLogStreamEventSchema = z.discriminatedUnion("type", [
1882
+ z.object({
1883
+ type: z.literal("entries"),
1884
+ entries: z.array(hostLogEntrySchema),
1885
+ cursor: z.string()
1886
+ }),
1887
+ z.object({
1888
+ type: z.literal("gap"),
1889
+ reason: z.enum([
1890
+ "expired",
1891
+ "reset",
1892
+ "overflow"
1893
+ ]),
1894
+ cursor: z.string()
1895
+ }),
1896
+ z.object({
1897
+ type: z.literal("status"),
1898
+ status: hostLogStatusSchema
1899
+ })
1900
+ ]);
1901
+ //#endregion
1902
+ //#region src/credentials.ts
1903
+ /**
1904
+ * Named credentials (智能体扩展配置与凭据 C1–C5): one entry is added once and reused by extensions, MCP servers and
1905
+ * commands. The value is write-only; every view below carries metadata only. Accounts on platforms such as GitHub are
1906
+ * linked accounts (`linked-accounts.ts`), granted per agent, not credentials.
1907
+ */
1908
+ const CREDENTIAL_NAME_MAX_CHARS = 64;
1909
+ const CREDENTIAL_DESCRIPTION_MAX_CHARS = 500;
1910
+ const CREDENTIAL_VALUE_MAX_CHARS = 16384;
1911
+ /** Values shorter than this are not hidden from tool results; the form warns when one is saved. */
1912
+ const CREDENTIAL_REDACTABLE_MIN_CHARS = 8;
1913
+ /** How a credential reaches code: `request` only as a placeholder filled by `nxt.http.fetch`; `program` as the value. */
1914
+ const CredentialUsageSchema = z.enum(["request", "program"]);
1915
+ /** Agents that may use a credential: every agent, or the listed ones. */
1916
+ const CredentialAgentScopeSchema = z.union([z.object({ all: z.literal(true) }).strict(), z.object({ agentIds: z.array(AgentIdSchema).max(256) }).strict()]);
1917
+ /** Shown in redaction markers (`[凭据:名称]`), so brackets and control characters are not allowed. */
1918
+ const CredentialNameSchema = z.string().trim().min(1, "名称不能为空。").max(64, `名称最多 64 个字符。`).regex(/^[^\u0000-\u001f\u007f[\]]+$/u, "名称不能包含方括号或控制字符。");
1919
+ const CredentialDescriptionSchema = z.string().trim().max(500, `说明最多 500 个字符。`);
1920
+ const CredentialDomainsSchema = z.array(ExtensionNetworkDomainSchema).max(32);
1921
+ /**
1922
+ * Names a credential's environment variable cannot take: the shell, the tools' own configuration, and the variables
1923
+ * linked accounts give commands (`GH_TOKEN` and the `gh` settings).
1924
+ */
1925
+ const RESERVED_COMMAND_ENV = /* @__PURE__ */ new Set([
1926
+ "PATH",
1927
+ "HOME",
1928
+ "USER",
1929
+ "LOGNAME",
1930
+ "SHELL",
1931
+ "PWD",
1932
+ "OLDPWD",
1933
+ "TMPDIR",
1934
+ "TEMP",
1935
+ "TMP",
1936
+ "LANG",
1937
+ "TERM",
1938
+ "NODE_OPTIONS",
1939
+ "NODE_PATH",
1940
+ "GH_TOKEN",
1941
+ "GH_CONFIG_DIR",
1942
+ "GH_PROMPT_DISABLED",
1943
+ "GH_NO_UPDATE_NOTIFIER",
1944
+ "GH_NO_EXTENSION_UPDATE_NOTIFIER",
1945
+ "GIT_TERMINAL_PROMPT",
1946
+ "GIT_CONFIG_COUNT"
1947
+ ]);
1948
+ const RESERVED_COMMAND_ENV_PREFIXES = [
1949
+ "LC_",
1950
+ "LD_",
1951
+ "DYLD_",
1952
+ "GIT_CONFIG_",
1953
+ "NEKRO_",
1954
+ "DSH_"
1955
+ ];
1956
+ /** The environment variable a program credential reaches commands under. */
1957
+ const CredentialEnvNameSchema = z.string().trim().max(64).regex(/^[A-Z_][A-Z0-9_]*$/u, "环境变量名只能使用大写字母、数字和下划线,且不能以数字开头。").refine((name) => !RESERVED_COMMAND_ENV.has(name) && !RESERVED_COMMAND_ENV_PREFIXES.some((prefix) => name.startsWith(prefix)), "这个环境变量名由系统使用,请换一个。");
1958
+ const CredentialValueSchema = z.string().min(1).max(CREDENTIAL_VALUE_MAX_CHARS);
1959
+ /** What uses one credential right now: extension secret fields bound to it and agents whose commands receive it. */
1960
+ const CredentialUsersSchema = z.object({
1961
+ extensions: z.array(z.object({
1962
+ extensionId: ExtensionIdSchema,
1963
+ name: z.string(),
1964
+ /** Agents whose own configuration binds it; empty when only the host configuration does. */
1965
+ agentIds: z.array(AgentIdSchema),
1966
+ host: z.boolean()
1967
+ }).strict()),
1968
+ /** Agents with commands enabled whose commands receive it. */
1969
+ commandAgents: z.array(AgentIdSchema)
1970
+ }).strict();
1971
+ const CredentialViewSchema = z.object({
1972
+ id: CredentialIdSchema,
1973
+ name: CredentialNameSchema,
1974
+ description: z.string(),
1975
+ usage: CredentialUsageSchema,
1976
+ domains: z.array(z.string()),
1977
+ agentScope: CredentialAgentScopeSchema,
1978
+ autoUse: z.boolean(),
1979
+ /** Program credentials: the environment variable agents' commands receive it under, or `null` when they do not. */
1980
+ envName: z.string().nullable(),
1981
+ /** Agents an administrator let use it while automatic use is off. */
1982
+ approvedAgentIds: z.array(AgentIdSchema),
1983
+ /** False when the stored value is too short to hide from tool results, or cannot be read. */
1984
+ redactable: z.boolean(),
1985
+ /** False when the stored value cannot be read any more; the entry stays so it can be replaced. */
1986
+ available: z.boolean(),
1987
+ usedBy: CredentialUsersSchema,
1988
+ createdAt: z.number().int().nonnegative(),
1989
+ updatedAt: z.number().int().nonnegative(),
1990
+ lastUsedAt: z.number().int().nonnegative().nullable()
1991
+ }).strict();
1992
+ /** A model provider listed with the credentials; `open` lets agents and extensions call it through the host. */
1993
+ const ModelProviderAccessSchema = z.object({
1994
+ provider: z.string().min(1),
1995
+ name: z.string(),
1996
+ open: z.boolean()
1997
+ }).strict();
1998
+ /**
1999
+ * An agent asked for a credential that does not exist yet. The settings link pre-fills the add form; saving a
2000
+ * credential with this name wakes the agent in the channel it asked from.
2001
+ */
2002
+ const CredentialRequestViewSchema = z.object({
2003
+ id: z.string().min(1).max(64),
2004
+ name: CredentialNameSchema,
2005
+ purpose: z.string(),
2006
+ domains: z.array(z.string()),
2007
+ usage: CredentialUsageSchema,
2008
+ agentId: AgentIdSchema,
2009
+ channelId: ChannelIdSchema.nullable(),
2010
+ createdAt: z.number().int().nonnegative(),
2011
+ /** Settings route that opens the add form pre-filled, see {@link credentialRequestRoute}. */
2012
+ route: z.string()
2013
+ }).strict();
2014
+ const CredentialsViewSchema = z.object({
2015
+ credentials: z.array(CredentialViewSchema),
2016
+ modelProviders: z.array(ModelProviderAccessSchema),
2017
+ requests: z.array(CredentialRequestViewSchema)
2018
+ }).strict();
2019
+ const CreateCredentialRequestSchema = z.object({
2020
+ name: CredentialNameSchema,
2021
+ description: CredentialDescriptionSchema.default(""),
2022
+ agentScope: CredentialAgentScopeSchema.default({ all: true }),
2023
+ autoUse: z.boolean().default(true),
2024
+ usage: CredentialUsageSchema.default("request"),
2025
+ domains: CredentialDomainsSchema.default([]),
2026
+ /** Program credentials only. */
2027
+ envName: CredentialEnvNameSchema.optional(),
2028
+ value: CredentialValueSchema,
2029
+ /** The agent request this form was opened from, if any. */
2030
+ requestId: z.string().min(1).max(64).optional()
2031
+ }).strict();
2032
+ /** Metadata changes; omitted fields keep their value. */
2033
+ const UpdateCredentialRequestSchema = z.object({
2034
+ name: CredentialNameSchema.optional(),
2035
+ description: CredentialDescriptionSchema.optional(),
2036
+ usage: CredentialUsageSchema.optional(),
2037
+ domains: CredentialDomainsSchema.optional(),
2038
+ agentScope: CredentialAgentScopeSchema.optional(),
2039
+ autoUse: z.boolean().optional(),
2040
+ /** `null` stops giving it to commands; only program credentials take one. */
2041
+ envName: CredentialEnvNameSchema.nullable().optional(),
2042
+ /** Replaces the agents allowed to use it while automatic use is off, for example to withdraw an approval. */
2043
+ approvedAgentIds: z.array(AgentIdSchema).max(256).optional()
2044
+ }).strict();
2045
+ const ReplaceCredentialValueRequestSchema = z.object({ value: CredentialValueSchema }).strict();
2046
+ /** Removing a credential that is in use needs `confirm`; without it the result lists who uses it. */
2047
+ const RemoveCredentialRequestSchema = z.object({ confirm: z.boolean().default(false) }).strict();
2048
+ const RemoveCredentialResultSchema = z.discriminatedUnion("removed", [z.object({
2049
+ removed: z.literal(true),
2050
+ view: CredentialsViewSchema
2051
+ }).strict(), z.object({
2052
+ removed: z.literal(false),
2053
+ usedBy: CredentialUsersSchema
2054
+ }).strict()]);
2055
+ const CredentialConsumerKindSchema = z.enum([
2056
+ "extension",
2057
+ "command",
2058
+ "mcp",
2059
+ "model"
2060
+ ]);
2061
+ /** One recorded use. The newest 500 per credential are kept, none older than 90 days. */
2062
+ const CredentialUseSchema = z.object({
2063
+ at: z.number().int().nonnegative(),
2064
+ agentId: AgentIdSchema.nullable(),
2065
+ channelId: ChannelIdSchema.nullable(),
2066
+ requesterMemberId: z.string().nullable(),
2067
+ consumerKind: CredentialConsumerKindSchema,
2068
+ consumerId: z.string(),
2069
+ /** Extension display name or MCP server name, when it is still known. */
2070
+ consumerName: z.string().nullable(),
2071
+ targetHost: z.string().nullable()
2072
+ }).strict();
2073
+ const CredentialUsesViewSchema = z.object({ uses: z.array(CredentialUseSchema) }).strict();
2074
+ const SetModelProviderAccessRequestSchema = z.object({ open: z.boolean() }).strict();
2075
+ /**
2076
+ * The settings route that opens the add form pre-filled from an agent's request: the credential section with `add=1`
2077
+ * plus `name`, `purpose`, `domains` (comma separated), `usage` and `request` (the request id) as query parameters.
2078
+ */
2079
+ const credentialRequestRoute = (request) => {
2080
+ const query = new URLSearchParams({
2081
+ add: "1",
2082
+ name: request.name,
2083
+ request: request.id,
2084
+ usage: request.usage
2085
+ });
2086
+ if (request.purpose !== "") query.set("purpose", request.purpose);
2087
+ if (request.domains.length > 0) query.set("domains", request.domains.join(","));
2088
+ return `/settings/credentials?${query.toString()}`;
2089
+ };
2090
+ /** Secret fields of an extension configuration layer bound to a named credential, by field. */
2091
+ const BoundCredentialsSchema = z.record(z.string(), CredentialIdSchema);
2092
+ /** Binds secret fields to named credentials; `null` removes the binding and leaves the field unset. */
2093
+ const CredentialBindingsRequestSchema = z.record(z.string(), CredentialIdSchema.nullable());
2094
+ //#endregion
2095
+ //#region src/linked-accounts.ts
2096
+ /**
2097
+ * Linked accounts (设置 → 关联账号): third-party accounts that agents' commands act as. The library only keeps them;
2098
+ * an agent's commands receive an account only through its `commandAccounts` grant (命令账号授权 A1、A2). Tokens are
2099
+ * write-only; every view below carries metadata only.
2100
+ */
2101
+ /** Platforms the host can link accounts of; each grant names one account per platform. */
2102
+ const LinkedAccountPlatformIdSchema = z.enum(["github"]);
2103
+ /** How an account is added: a typed token, or the token of a login the platform's local CLI holds (read once). */
2104
+ const LinkedAccountMethodSchema = z.enum(["token", "gh-login"]);
2105
+ /** A login the local `gh` holds, offered as a quick way to link a GitHub account. */
2106
+ const LocalGithubLoginSchema = z.object({
2107
+ login: z.string().trim().min(1),
2108
+ active: z.boolean()
2109
+ }).strict();
2110
+ const tokenFields = {
2111
+ method: z.literal("token"),
2112
+ token: z.string().trim().min(1).max(512)
2113
+ };
2114
+ const ghLoginFields = {
2115
+ method: z.literal("gh-login"),
2116
+ login: z.string().trim().min(1).max(128)
2117
+ };
2118
+ /** Where a token comes from: typed, or read once from a login of the platform's local CLI. */
2119
+ const LinkedAccountTokenSourceSchema = z.discriminatedUnion("method", [z.object(tokenFields).strict(), z.object(ghLoginFields).strict()]);
2120
+ const LinkedAccountViewSchema = z.object({
2121
+ id: LinkedAccountIdSchema,
2122
+ platform: LinkedAccountPlatformIdSchema,
2123
+ /** The account name on the platform, as the platform reported it when the token was verified. */
2124
+ login: z.string(),
2125
+ /** Token scopes where the platform reports them (GitHub classic tokens); `null` otherwise. */
2126
+ scopes: z.array(z.string()).nullable(),
2127
+ source: LinkedAccountMethodSchema,
2128
+ /** False when the stored token cannot be read any more; the account stays so it can be replaced or removed. */
2129
+ available: z.boolean(),
2130
+ /** Agents whose capabilities grant this account. */
2131
+ grantedAgentIds: z.array(AgentIdSchema),
2132
+ createdAt: z.number().int().nonnegative(),
2133
+ updatedAt: z.number().int().nonnegative(),
2134
+ lastUsedAt: z.number().int().nonnegative().nullable()
2135
+ }).strict();
2136
+ /** Links an account: the platform plus how its token is given. */
2137
+ const AddLinkedAccountRequestSchema = z.discriminatedUnion("method", [z.object({
2138
+ platform: LinkedAccountPlatformIdSchema,
2139
+ ...tokenFields
2140
+ }).strict(), z.object({
2141
+ platform: LinkedAccountPlatformIdSchema,
2142
+ ...ghLoginFields
2143
+ }).strict()]);
2144
+ /** A new token for an account; it must belong to the same account on the platform. */
2145
+ const ReplaceLinkedAccountTokenRequestSchema = LinkedAccountTokenSourceSchema;
2146
+ /** Removing a granted account needs `confirm`; without it the result lists the agents it is granted to. */
2147
+ const RemoveLinkedAccountRequestSchema = z.object({ confirm: z.boolean().default(false) }).strict();
2148
+ /** One recorded use: an agent's command environment carried the account. Newest 500 per account, none over 90 days. */
2149
+ const LinkedAccountUseSchema = z.object({
2150
+ at: z.number().int().nonnegative(),
2151
+ agentId: AgentIdSchema.nullable(),
2152
+ channelId: ChannelIdSchema.nullable(),
2153
+ consumerKind: z.enum(["command"]),
2154
+ consumerId: z.string()
2155
+ }).strict();
2156
+ const LinkedAccountUsesViewSchema = z.object({ uses: z.array(LinkedAccountUseSchema) }).strict();
2157
+ //#endregion
1338
2158
  //#region src/runtime-compatibility.ts
1339
2159
  const RuntimeCompatibilityDiagnosticSchema = z.object({
1340
2160
  objectKind: z.enum([
@@ -1375,6 +2195,86 @@ const HostUpgradeSummarySchema = z.object({
1375
2195
  diagnostics: z.array(RuntimeCompatibilityDiagnosticSchema)
1376
2196
  }).strict();
1377
2197
  //#endregion
2198
+ //#region src/response-timing.ts
2199
+ /** Bounds of the numeric response timing settings; the host rejects values outside them. */
2200
+ const RESPONSE_TIMING_LIMITS = {
2201
+ waitMaxQuietSeconds: {
2202
+ min: 5,
2203
+ max: 300
2204
+ },
2205
+ waitMaxTotalSeconds: {
2206
+ min: 10,
2207
+ max: 900
2208
+ },
2209
+ debounceSeconds: {
2210
+ min: 0,
2211
+ max: 30
2212
+ },
2213
+ debounceMaxSeconds: {
2214
+ min: 1,
2215
+ max: 120
2216
+ },
2217
+ debounceMaxMessages: {
2218
+ min: 1,
2219
+ max: 20
2220
+ },
2221
+ attentionSeconds: {
2222
+ min: 5,
2223
+ max: 600
2224
+ },
2225
+ midWakesPerMinute: {
2226
+ min: 1,
2227
+ max: 30
2228
+ }
2229
+ };
2230
+ const bounded = (key) => z.number().int().min(RESPONSE_TIMING_LIMITS[key].min).max(RESPONSE_TIMING_LIMITS[key].max).optional();
2231
+ /**
2232
+ * Per-binding timing of when the agent speaks (Decision 2026-10-31 响应时机与智能响应). Every field is optional: an
2233
+ * omitted one uses {@link RESPONSE_TIMING_DEFAULTS}. Waiting applies to every policy that answers messages; the rest
2234
+ * only to `smart`.
2235
+ */
2236
+ const ResponseTimingSettingsSchema = z.object({
2237
+ /** The agent may end a turn with `waiting-for-more` and be woken when the speaker goes quiet. */
2238
+ waitEnabled: z.boolean().optional(),
2239
+ /** Longest quiet period one wait may ask for. */
2240
+ waitMaxQuietSeconds: bounded("waitMaxQuietSeconds"),
2241
+ /** Longest the agent may keep waiting for one person, counted from the first wait. */
2242
+ waitMaxTotalSeconds: bounded("waitMaxTotalSeconds"),
2243
+ /** Smart: wait for the speaker to stay quiet this long before a turn starts; 0 starts at once. */
2244
+ debounceSeconds: bounded("debounceSeconds"),
2245
+ /** Smart: start anyway once this long has passed since the first message. */
2246
+ debounceMaxSeconds: bounded("debounceMaxSeconds"),
2247
+ /** Smart: start anyway once this many messages from the speaker are collected. */
2248
+ debounceMaxMessages: bounded("debounceMaxMessages"),
2249
+ /** Smart: a message that contains the agent's name or an alias wakes it. */
2250
+ nameWake: z.boolean().optional(),
2251
+ /** Smart: after someone talks with the agent, their next messages wake it for a while. */
2252
+ attentionWake: z.boolean().optional(),
2253
+ attentionSeconds: bounded("attentionSeconds"),
2254
+ /** Smart: name and attention wakes per channel per minute; strong signals are never limited. */
2255
+ midWakesPerMinute: bounded("midWakesPerMinute")
2256
+ }).strict();
2257
+ const RESPONSE_TIMING_DEFAULTS = {
2258
+ waitEnabled: true,
2259
+ waitMaxQuietSeconds: 60,
2260
+ waitMaxTotalSeconds: 120,
2261
+ debounceSeconds: 3,
2262
+ debounceMaxSeconds: 30,
2263
+ debounceMaxMessages: 5,
2264
+ nameWake: true,
2265
+ attentionWake: true,
2266
+ attentionSeconds: 60,
2267
+ midWakesPerMinute: 3
2268
+ };
2269
+ /** Shortest quiet period a wait may ask for, whatever the channel allows. */
2270
+ const RESPONSE_WAIT_MIN_QUIET_SECONDS = 5;
2271
+ const resolveResponseTiming = (settings) => ({
2272
+ ...RESPONSE_TIMING_DEFAULTS,
2273
+ ...Object.fromEntries(Object.entries(settings ?? {}).filter(([, value]) => value !== void 0))
2274
+ });
2275
+ /** Extra names that wake the agent in smart mode; the display name always counts too. */
2276
+ const AgentAliasesSchema = z.array(z.string().trim().min(1).max(32)).max(16).transform((aliases) => [...new Set(aliases)]);
2277
+ //#endregion
1378
2278
  //#region src/management-api.ts
1379
2279
  const NonEmptyStringSchema$1 = z.string().trim().min(1);
1380
2280
  const Base64UrlSchema = z.string().regex(/^[A-Za-z0-9_-]+$/u);
@@ -1458,7 +2358,7 @@ const ClientNotificationSchema = z.object({
1458
2358
  title: z.string().trim().min(1).max(80),
1459
2359
  body: z.string().trim().min(1).max(240),
1460
2360
  occurredAt: z.number().int().nonnegative(),
1461
- route: z.string().regex(/^\/(?:(?:live|channels|agents|workshop|wiring|settings|apps|work|connections|users|extensions)(?:\/[^?#]*)?)?$/u).optional()
2361
+ route: z.string().regex(/^\/(?:(?:live|channels|agents|workshop|wiring|settings|community|apps|work|connections|users|extensions)(?:\/[^?#]*)?)?(?:\?[^#]*)?$/u).optional()
1462
2362
  }).strict();
1463
2363
  const MANAGEMENT_PAIR_PROOF_PREFIX = "nxt-management-pair-v1";
1464
2364
  const managementPairProofMessage = (input) => [
@@ -1598,6 +2498,8 @@ const CommunityExtensionSortSchema = z.enum([
1598
2498
  ]);
1599
2499
  const CommunityReleaseIdSchema = z.string().regex(/^rel_[0-9A-Za-z]+$/u);
1600
2500
  const CommunityAccountSchema = z.object({
2501
+ /** Immutable community identity; absent when connected to a community predating feedback support. */
2502
+ id: z.string().min(1).max(100).optional(),
1601
2503
  handle: z.string().min(1).max(80),
1602
2504
  displayName: z.string().max(200),
1603
2505
  avatarUrl: z.string().url().nullable()
@@ -1608,6 +2510,7 @@ const CommunityEnvironmentSchema = z.enum([
1608
2510
  "development"
1609
2511
  ]);
1610
2512
  const CommunityStatusSchema = z.object({
2513
+ features: z.array(z.string()).optional(),
1611
2514
  communityUrl: z.string().url(),
1612
2515
  /** 社区自我声明的环境;连不上或旧版社区时为 null。 */
1613
2516
  environment: CommunityEnvironmentSchema.nullable(),
@@ -1637,7 +2540,13 @@ const CommunityReleaseSchema = z.object({
1637
2540
  packageSize: z.number().int().nonnegative(),
1638
2541
  requiresSdk: z.number().int().positive().nullable(),
1639
2542
  notes: z.string().max(2e3),
1640
- createdAt: z.number().int()
2543
+ createdAt: z.number().int(),
2544
+ /** Release number on the community line; absent from older communities. */
2545
+ number: z.number().int().positive().optional(),
2546
+ /** Revision the release contains and its lineage, so NekroNXT can tell fast-forward from divergence. */
2547
+ revisionId: ExtensionRevisionIdSchema.optional(),
2548
+ parentRevisionId: ExtensionRevisionIdSchema.nullable().optional(),
2549
+ ancestry: z.array(ExtensionRevisionIdSchema).max(256).optional()
1641
2550
  });
1642
2551
  /** 社区为官方扩展保留的发布者标识:官方扩展由多位官方成员维护,对外不显示个人账号。 */
1643
2552
  const COMMUNITY_OFFICIAL_HANDLE = "nekro-nxt";
@@ -1658,7 +2567,18 @@ const CommunityExtensionSummarySchema = z.object({
1658
2567
  latest: CommunityReleaseSchema.nullable(),
1659
2568
  downloads: z.number().int().nonnegative(),
1660
2569
  updatedAt: z.number().int(),
1661
- pageUrl: z.string().url()
2570
+ pageUrl: z.string().url(),
2571
+ /**
2572
+ * The extension and version this one is a branch of; null for an original line or an older community. Without a
2573
+ * displayName the origin is not public on the community.
2574
+ */
2575
+ branchOf: z.object({
2576
+ extensionId: ExtensionIdSchema,
2577
+ revisionId: ExtensionRevisionIdSchema.nullable(),
2578
+ displayName: z.string().max(200).nullable()
2579
+ }).nullable().optional(),
2580
+ /** Public branches made from this extension. */
2581
+ branchCount: z.number().int().nonnegative().optional()
1662
2582
  });
1663
2583
  const CommunityExtensionDetailSchema = CommunityExtensionSummarySchema.extend({
1664
2584
  description: z.string().max(2e4),
@@ -1685,6 +2605,14 @@ const CommunityExtensionDetailSchema = CommunityExtensionSummarySchema.extend({
1685
2605
  }).nullable()
1686
2606
  });
1687
2607
  /**
2608
+ * 本机缓存的社区目录读取附带的时间:`fetchedAt` 是这份内容从社区取回的时间;`stale` 表示社区这次没能读取,
2609
+ * 返回的是较早的一份。
2610
+ */
2611
+ const CommunityFreshnessSchema = z.object({
2612
+ fetchedAt: z.number().int().nonnegative(),
2613
+ stale: z.boolean()
2614
+ });
2615
+ /**
1688
2616
  * 发布时随包提交的条目信息(作者自己写的介绍)。首次发布用于建条目;之后提供了哪项就覆盖哪项,未提供的保持不变。
1689
2617
  */
1690
2618
  const COMMUNITY_LISTING_LIMITS = {
@@ -1718,6 +2646,45 @@ const CommunitySourceSchema = z.object({
1718
2646
  publisherHandle: z.string().min(1).max(80),
1719
2647
  installedAt: z.number().int().nonnegative()
1720
2648
  });
2649
+ /**
2650
+ * How this machine's current version of one extension relates to the community's newest public release, with the
2651
+ * action that relation calls for. `role` says whether this machine may publish the line or only follows it.
2652
+ */
2653
+ const CommunitySyncItemSchema = z.object({
2654
+ extensionId: ExtensionIdSchema,
2655
+ displayName: z.string(),
2656
+ communityUrl: z.string().url(),
2657
+ role: z.enum(["owner", "subscriber"]),
2658
+ currentRevisionId: ExtensionRevisionIdSchema,
2659
+ currentVersionLabel: z.string(),
2660
+ /** Release the current version is, when it is one. */
2661
+ currentRelease: z.object({
2662
+ id: CommunityReleaseIdSchema,
2663
+ number: z.number().int().positive().nullable()
2664
+ }).nullable(),
2665
+ /** `remote-ahead`: update; `local-ahead`: publish (owner) or local changes (subscriber); `diverged`: merge first. */
2666
+ status: z.enum([
2667
+ "same",
2668
+ "remote-ahead",
2669
+ "local-ahead",
2670
+ "diverged",
2671
+ "unrelated",
2672
+ "unknown"
2673
+ ]),
2674
+ found: z.boolean(),
2675
+ delisted: z.boolean(),
2676
+ delistedReason: z.string().nullable(),
2677
+ /** The release the current version came from was withdrawn by its author. */
2678
+ releaseWithdrawn: z.boolean(),
2679
+ latest: CommunityReleaseSchema.nullable(),
2680
+ /** The user chose to keep local changes over `latest`; it is not offered again. */
2681
+ dismissed: z.boolean(),
2682
+ addedPermissions: z.array(CommunityPermissionItemSchema)
2683
+ });
2684
+ const CommunitySyncSchema = z.object({
2685
+ checkedAt: z.number().int().nullable(),
2686
+ items: z.array(CommunitySyncItemSchema)
2687
+ });
1721
2688
  const CommunityInstalledItemSchema = z.object({
1722
2689
  extensionId: ExtensionIdSchema,
1723
2690
  displayName: z.string(),
@@ -1929,31 +2896,396 @@ const communityPersonaReviewLabel = (status) => {
1929
2896
  }
1930
2897
  };
1931
2898
  //#endregion
1932
- //#region src/host-api.ts
1933
- const EmptyParamsSchema = z.object({}).strict();
1934
- const NoRequestBodySchema = z.undefined();
1935
- const NonEmptyStringSchema = z.string().trim().min(1);
1936
- const DynamicIdSchema = NonEmptyStringSchema;
1937
- const DynamicAttemptStatusSchema = z.enum([
1938
- "awaiting-approval",
1939
- "starting-host",
1940
- "client-pending",
1941
- "running",
1942
- "waiting",
1943
- "rejected",
1944
- "failed",
1945
- "cancelled",
1946
- "stopped"
2899
+ //#region src/community-feedback.ts
2900
+ const COMMUNITY_FEEDBACK_STATUSES = [
2901
+ "new",
2902
+ "needs_info",
2903
+ "triaged",
2904
+ "planned",
2905
+ "fixed",
2906
+ "duplicate",
2907
+ "wontfix",
2908
+ "withdrawn"
2909
+ ];
2910
+ const CommunityFeedbackStatusSchema = z.enum(COMMUNITY_FEEDBACK_STATUSES);
2911
+ const COMMUNITY_FEEDBACK_STATUS_LABELS = {
2912
+ new: "新反馈",
2913
+ needs_info: "需要补充",
2914
+ triaged: "已确认",
2915
+ planned: "已计划",
2916
+ fixed: "已修复",
2917
+ duplicate: "重复",
2918
+ wontfix: "不处理",
2919
+ withdrawn: "已撤回"
2920
+ };
2921
+ const CommunityFeedbackKindSchema = z.enum([
2922
+ "bug",
2923
+ "suggestion",
2924
+ "question"
1947
2925
  ]);
1948
- const DynamicHalfStateSchema = z.object({
1949
- status: z.enum([
1950
- "absent",
1951
- "pending",
1952
- "stopped",
1953
- "running",
1954
- "waiting",
1955
- "failed"
1956
- ]),
2926
+ const CommunityFeedbackIdSchema = z.string().regex(/^fbk_[0-9a-z]{26}$/u).brand();
2927
+ const CommunityFeedbackRefSchema = z.string().regex(/^FB-[1-9][0-9]*$/u);
2928
+ const CommunityFeedbackTargetSchema = z.union([z.literal("nxt"), z.object({
2929
+ extensionId: z.string().regex(/^ext_[0-9A-Za-z]+$/u),
2930
+ version: z.string().max(120).optional()
2931
+ }).strict()]);
2932
+ const version = z.string().trim().min(1).max(120);
2933
+ const timestamp = z.number().int().nonnegative();
2934
+ const CommunityFeedbackExtensionDiagnosticSchema = z.object({
2935
+ extensionId: z.string().max(100),
2936
+ version,
2937
+ accessLevel: z.string().max(80).optional(),
2938
+ activation: z.enum(["host", "agent"]).optional()
2939
+ }).strict();
2940
+ const CommunityFeedbackDiagnosticEntrySchema = z.object({
2941
+ kind: z.enum([
2942
+ "compatibility",
2943
+ "extension",
2944
+ "connection"
2945
+ ]),
2946
+ summary: z.string().max(2e3),
2947
+ extensionId: z.string().max(100).optional()
2948
+ }).strict();
2949
+ /** An explicit allowlist: credentials, account grants and arbitrary host configuration never cross this boundary. */
2950
+ const CommunityFeedbackDiagnosticsSchema = z.object({
2951
+ nxtVersion: version.optional(),
2952
+ releaseChannel: z.enum([
2953
+ "stable",
2954
+ "preview",
2955
+ "development"
2956
+ ]).optional(),
2957
+ hostKind: z.enum(["desktop", "server"]).optional(),
2958
+ platform: z.string().max(80).optional(),
2959
+ arch: z.string().max(40).optional(),
2960
+ dshVersion: version.optional(),
2961
+ adapters: z.array(z.string().max(100)).max(64).optional(),
2962
+ agent: z.object({
2963
+ accessLevel: z.string().max(80),
2964
+ subagents: z.boolean(),
2965
+ fileTools: z.boolean(),
2966
+ webSearch: z.boolean(),
2967
+ dynamicCreation: z.boolean(),
2968
+ developmentShell: z.boolean(),
2969
+ unrestrictedFileAccess: z.boolean(),
2970
+ scheduledTasks: z.boolean(),
2971
+ codeRun: z.boolean(),
2972
+ commandNetwork: z.boolean(),
2973
+ communityFeedbackAuto: z.boolean()
2974
+ }).strict().optional(),
2975
+ extensions: z.array(CommunityFeedbackExtensionDiagnosticSchema).max(256).optional(),
2976
+ entries: z.array(CommunityFeedbackDiagnosticEntrySchema).max(32).optional(),
2977
+ instanceId: z.string().min(1).max(100).optional()
2978
+ }).strict();
2979
+ const CommunityFeedbackExcerptSchema = z.array(z.object({
2980
+ speaker: z.string().max(80),
2981
+ text: z.string().max(6e3)
2982
+ }).strict()).max(8);
2983
+ const CommunityFeedbackCreateSchema = z.object({
2984
+ clientRequestId: z.string().min(1).max(160),
2985
+ kind: CommunityFeedbackKindSchema,
2986
+ target: CommunityFeedbackTargetSchema,
2987
+ title: z.string().trim().min(1).max(120),
2988
+ body: z.string().trim().min(1).max(8e3),
2989
+ diagnostics: CommunityFeedbackDiagnosticsSchema.default({}),
2990
+ excerpt: CommunityFeedbackExcerptSchema.optional(),
2991
+ excerptSharedWithAuthor: z.boolean().default(false),
2992
+ source: z.enum([
2993
+ "assistant",
2994
+ "assistant_auto",
2995
+ "form",
2996
+ "web"
2997
+ ]),
2998
+ instanceId: z.string().min(1).max(100).optional()
2999
+ }).strict();
3000
+ const CommunityFeedbackMessageInputSchema = z.object({
3001
+ body: z.string().trim().min(1).max(4e3),
3002
+ audience: z.enum(["everyone", "staff"]).default("everyone")
3003
+ }).strict();
3004
+ const CommunityFeedbackSupplementSchema = z.object({
3005
+ diagnostics: CommunityFeedbackDiagnosticsSchema.optional(),
3006
+ excerpt: CommunityFeedbackExcerptSchema.optional(),
3007
+ excerptSharedWithAuthor: z.boolean().optional()
3008
+ }).strict();
3009
+ const CommunityFeedbackWithdrawSchema = z.object({ deleteText: z.boolean().default(false) }).strict();
3010
+ const CommunityFeedbackConfirmSchema = z.object({ clientVersion: version }).strict();
3011
+ const CommunityFeedbackReopenSchema = z.object({ note: z.string().trim().min(1).max(2e3) }).strict();
3012
+ const CommunityFeedbackAffectedSchema = z.object({
3013
+ diagnostics: CommunityFeedbackDiagnosticsSchema.optional(),
3014
+ nxtVersion: version.optional()
3015
+ }).strict();
3016
+ const CommunityFeedbackTransitionSchema = z.object({
3017
+ status: CommunityFeedbackStatusSchema,
3018
+ fixedIn: version.optional(),
3019
+ duplicateOf: CommunityFeedbackRefSchema.optional(),
3020
+ note: z.string().trim().max(2e3).optional()
3021
+ }).strict();
3022
+ const CommunityFeedbackLabelsSchema = z.object({
3023
+ labels: z.array(z.string().trim().min(1).max(40)).max(20),
3024
+ priority: z.enum([
3025
+ "low",
3026
+ "normal",
3027
+ "high"
3028
+ ]).nullable()
3029
+ }).strict();
3030
+ 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();
3031
+ const CommunityFeedbackVisibilitySchema = z.object({ visibility: z.enum(["private", "public"]) }).strict();
3032
+ const CommunityFeedbackEventDataSchema = z.object({
3033
+ from: CommunityFeedbackStatusSchema.optional(),
3034
+ to: CommunityFeedbackStatusSchema.optional(),
3035
+ fixedIn: version.nullable().optional(),
3036
+ duplicateOf: CommunityFeedbackRefSchema.nullable().optional(),
3037
+ note: z.string().max(2e3).optional(),
3038
+ labels: z.array(z.string()).optional(),
3039
+ priority: z.enum([
3040
+ "low",
3041
+ "normal",
3042
+ "high"
3043
+ ]).nullable().optional(),
3044
+ visibility: z.enum(["private", "public"]).optional(),
3045
+ clientVersion: version.optional(),
3046
+ messageId: z.string().optional(),
3047
+ audience: z.enum(["everyone", "staff"]).optional(),
3048
+ deleteText: z.boolean().optional(),
3049
+ affected: z.boolean().optional()
3050
+ }).strict();
3051
+ const CommunityFeedbackEventSchema = z.object({
3052
+ seq: z.number().int().positive(),
3053
+ ref: CommunityFeedbackRefSchema,
3054
+ type: z.enum([
3055
+ "created",
3056
+ "message",
3057
+ "status_changed",
3058
+ "labeled",
3059
+ "priority_changed",
3060
+ "linked_issue",
3061
+ "duplicate_marked",
3062
+ "fixed_in_set",
3063
+ "visibility_changed",
3064
+ "affected_added",
3065
+ "withdrawn",
3066
+ "reopened",
3067
+ "supplemented",
3068
+ "fix_confirmed"
3069
+ ]),
3070
+ actorKind: z.enum([
3071
+ "user",
3072
+ "admin",
3073
+ "author",
3074
+ "token",
3075
+ "system"
3076
+ ]).optional(),
3077
+ actor: z.string().optional(),
3078
+ tokenId: z.string().optional(),
3079
+ data: CommunityFeedbackEventDataSchema,
3080
+ createdAt: timestamp,
3081
+ title: z.string().optional(),
3082
+ status: CommunityFeedbackStatusSchema.optional()
3083
+ });
3084
+ const CommunityFeedbackMessageSchema = z.object({
3085
+ id: z.string(),
3086
+ authorKind: z.enum([
3087
+ "user",
3088
+ "admin",
3089
+ "author",
3090
+ "system"
3091
+ ]),
3092
+ author: z.string().nullable(),
3093
+ audience: z.enum(["everyone", "staff"]),
3094
+ body: z.string(),
3095
+ createdAt: timestamp
3096
+ });
3097
+ const CommunityFeedbackSummarySchema = z.object({
3098
+ id: CommunityFeedbackIdSchema,
3099
+ ref: CommunityFeedbackRefSchema,
3100
+ title: z.string(),
3101
+ kind: CommunityFeedbackKindSchema.optional(),
3102
+ target: CommunityFeedbackTargetSchema.optional(),
3103
+ status: CommunityFeedbackStatusSchema,
3104
+ fixedIn: version.nullable(),
3105
+ affectedCount: z.number().int().nonnegative(),
3106
+ source: CommunityFeedbackCreateSchema.shape.source.optional(),
3107
+ confirmedCount: z.number().int().nonnegative().optional(),
3108
+ createdAt: timestamp.optional(),
3109
+ updatedAt: timestamp.optional()
3110
+ });
3111
+ /** Optional private fields are emitted only by the server's role-specific projection. */
3112
+ const CommunityFeedbackSchema = CommunityFeedbackSummarySchema.extend({
3113
+ access: z.enum([
3114
+ "owner",
3115
+ "admin",
3116
+ "author",
3117
+ "subscriber",
3118
+ "public"
3119
+ ]),
3120
+ body: z.string().optional(),
3121
+ diagnostics: CommunityFeedbackDiagnosticsSchema.optional(),
3122
+ excerpt: CommunityFeedbackExcerptSchema.nullable().optional(),
3123
+ excerptSharedWithAuthor: z.boolean().optional(),
3124
+ messages: z.array(CommunityFeedbackMessageSchema).optional(),
3125
+ events: z.array(CommunityFeedbackEventSchema).optional(),
3126
+ submitter: z.string().optional(),
3127
+ instanceId: z.string().nullable().optional(),
3128
+ priority: z.enum([
3129
+ "low",
3130
+ "normal",
3131
+ "high"
3132
+ ]).nullable().optional(),
3133
+ labels: z.array(z.string()).optional(),
3134
+ visibility: z.enum(["private", "public"]).optional(),
3135
+ duplicateOf: CommunityFeedbackRefSchema.nullable().optional(),
3136
+ githubUrl: z.string().nullable().optional(),
3137
+ closedAt: timestamp.nullable().optional(),
3138
+ purgedAt: timestamp.nullable().optional(),
3139
+ confirmed: z.boolean().default(false),
3140
+ affected: z.boolean().default(false),
3141
+ affectedDiagnostics: z.array(z.object({
3142
+ user: z.string(),
3143
+ diagnostics: CommunityFeedbackDiagnosticsSchema.nullable(),
3144
+ nxtVersion: version.nullable(),
3145
+ createdAt: timestamp
3146
+ })).optional()
3147
+ });
3148
+ const CommunityFeedbackListSchema = z.object({
3149
+ items: z.array(CommunityFeedbackSummarySchema),
3150
+ cursor: z.string().nullable()
3151
+ });
3152
+ const CommunityFeedbackChangesSchema = z.object({
3153
+ events: z.array(CommunityFeedbackEventSchema),
3154
+ cursor: z.number().int().nonnegative(),
3155
+ hasMore: z.boolean()
3156
+ });
3157
+ const CommunityFeedbackDigestSchema = z.object({
3158
+ since: timestamp,
3159
+ counts: z.object({
3160
+ status: z.record(CommunityFeedbackStatusSchema, z.number().int().nonnegative()),
3161
+ kind: z.record(CommunityFeedbackKindSchema, z.number().int().nonnegative()),
3162
+ target: z.record(z.enum(["nxt", "extension"]), z.number().int().nonnegative()),
3163
+ extensions: z.record(z.string(), z.number().int().nonnegative())
3164
+ }),
3165
+ newItems: z.array(CommunityFeedbackSummarySchema),
3166
+ awaitingReply: z.array(CommunityFeedbackSummarySchema),
3167
+ mostAffected: z.array(CommunityFeedbackSummarySchema),
3168
+ unconfirmedFixes: z.array(CommunityFeedbackSummarySchema),
3169
+ fixedCount: z.number().int().nonnegative()
3170
+ });
3171
+ //#endregion
3172
+ //#region src/community-feedback-host.ts
3173
+ const CommunityFeedbackDraftIdSchema = z.string().regex(/^fbd_[0-9A-Za-z]+$/u).brand();
3174
+ const CommunityFeedbackDraftStateSchema = z.enum([
3175
+ "awaiting",
3176
+ "sending",
3177
+ "sent",
3178
+ "failed",
3179
+ "discarded"
3180
+ ]);
3181
+ const CommunityFeedbackDraftSchema = z.object({
3182
+ id: CommunityFeedbackDraftIdSchema,
3183
+ communityUrl: z.string().url(),
3184
+ communityUserId: z.string().min(1).nullable(),
3185
+ agentId: AgentIdSchema.nullable(),
3186
+ channelId: ChannelIdSchema.nullable(),
3187
+ kind: CommunityFeedbackKindSchema,
3188
+ target: CommunityFeedbackTargetSchema,
3189
+ title: z.string().max(120),
3190
+ body: z.string().max(8e3),
3191
+ excerpt: CommunityFeedbackExcerptSchema.nullable(),
3192
+ excerptSharedWithAuthor: z.boolean(),
3193
+ diagnostics: CommunityFeedbackDiagnosticsSchema,
3194
+ state: CommunityFeedbackDraftStateSchema,
3195
+ requestedBy: z.string(),
3196
+ auto: z.boolean(),
3197
+ error: z.string().nullable(),
3198
+ createdAt: z.number().int().nonnegative(),
3199
+ updatedAt: z.number().int().nonnegative()
3200
+ }).strict();
3201
+ const CommunityFeedbackItemSchema = z.object({
3202
+ ref: CommunityFeedbackRefSchema,
3203
+ communityUrl: z.string().url(),
3204
+ communityUserId: z.string().min(1),
3205
+ channelId: ChannelIdSchema.nullable(),
3206
+ draftId: CommunityFeedbackDraftIdSchema.nullable(),
3207
+ title: z.string(),
3208
+ kind: CommunityFeedbackKindSchema.nullable(),
3209
+ target: CommunityFeedbackTargetSchema.nullable(),
3210
+ status: CommunityFeedbackStatusSchema,
3211
+ fixedIn: z.string().nullable(),
3212
+ unread: z.boolean(),
3213
+ lastEventSeq: z.number().int().nonnegative(),
3214
+ createdAt: z.number().int().nonnegative(),
3215
+ updatedAt: z.number().int().nonnegative()
3216
+ }).strict();
3217
+ const CommunityFeedbackDraftInputSchema = z.object({
3218
+ kind: CommunityFeedbackKindSchema,
3219
+ target: CommunityFeedbackTargetSchema,
3220
+ title: z.string().trim().min(1).max(120),
3221
+ body: z.string().trim().min(1).max(8e3),
3222
+ conversationRefs: z.array(LogicalMessageIdSchema).max(8).optional()
3223
+ }).strict();
3224
+ const CommunityFeedbackDraftUpdateSchema = z.object({
3225
+ title: z.string().trim().min(1).max(120),
3226
+ body: z.string().trim().min(1).max(8e3),
3227
+ includeExcerpt: z.boolean(),
3228
+ excerptSharedWithAuthor: z.boolean().default(false),
3229
+ expectedUpdatedAt: z.number().int().nonnegative()
3230
+ }).strict();
3231
+ const CommunityFeedbackSettingsSchema = z.object({
3232
+ enabled: z.boolean(),
3233
+ supported: z.boolean(),
3234
+ signedIn: z.boolean(),
3235
+ communityUrl: z.string().url(),
3236
+ communityUserId: z.string().nullable(),
3237
+ consentedAt: z.number().int().nonnegative().nullable()
3238
+ }).strict();
3239
+ const CommunityFeedbackSettingsUpdateSchema = z.object({
3240
+ enabled: z.boolean(),
3241
+ consent: z.boolean().default(false)
3242
+ }).strict();
3243
+ const CommunityFeedbackSnapshotSchema = z.object({
3244
+ enabled: z.boolean(),
3245
+ signedIn: z.boolean(),
3246
+ pendingDrafts: z.number().int().nonnegative(),
3247
+ unread: z.number().int().nonnegative()
3248
+ }).strict();
3249
+ const CommunityFeedbackLocalListSchema = z.object({
3250
+ drafts: z.array(CommunityFeedbackDraftSchema),
3251
+ items: z.array(CommunityFeedbackItemSchema),
3252
+ syncError: z.string().optional()
3253
+ }).strict();
3254
+ const CommunityFeedbackPayloadSchema = z.object({
3255
+ payload: CommunityFeedbackCreateSchema,
3256
+ redactions: z.array(z.string())
3257
+ }).strict();
3258
+ const CommunityFeedbackLastPayloadSchema = z.object({
3259
+ ref: CommunityFeedbackRefSchema,
3260
+ sentAt: z.number().int().nonnegative(),
3261
+ payload: CommunityFeedbackCreateSchema
3262
+ }).strict().nullable();
3263
+ //#endregion
3264
+ //#region src/host-api.ts
3265
+ const EmptyParamsSchema = z.object({}).strict();
3266
+ const NoRequestBodySchema = z.undefined();
3267
+ const NonEmptyStringSchema = z.string().trim().min(1);
3268
+ const DynamicIdSchema = NonEmptyStringSchema;
3269
+ const DynamicAttemptStatusSchema = z.enum([
3270
+ "awaiting-approval",
3271
+ "starting-host",
3272
+ "client-pending",
3273
+ "running",
3274
+ "waiting",
3275
+ "rejected",
3276
+ "failed",
3277
+ "cancelled",
3278
+ "stopped"
3279
+ ]);
3280
+ const DynamicHalfStateSchema = z.object({
3281
+ status: z.enum([
3282
+ "absent",
3283
+ "pending",
3284
+ "stopped",
3285
+ "running",
3286
+ "waiting",
3287
+ "failed"
3288
+ ]),
1957
3289
  waitingFor: z.array(z.string()),
1958
3290
  error: z.string().optional()
1959
3291
  }).strict();
@@ -1968,6 +3300,9 @@ const DynamicAttemptErrorSchema = z.object({
1968
3300
  ]),
1969
3301
  message: z.string(),
1970
3302
  stack: z.string().optional(),
3303
+ /** A render failure also names the contribution slot that failed and whether its frame gave up. */
3304
+ slot: NonEmptyStringSchema.optional(),
3305
+ abdicated: z.boolean().optional(),
1971
3306
  pluginId: DynamicIdSchema,
1972
3307
  packageId: DynamicIdSchema,
1973
3308
  pluginRunId: DynamicIdSchema
@@ -1992,7 +3327,8 @@ const AuthoringTaskStatusSchema = z.enum([
1992
3327
  "failed",
1993
3328
  "interrupted",
1994
3329
  "stopped",
1995
- "completed"
3330
+ "completed",
3331
+ "paused"
1996
3332
  ]);
1997
3333
  const AuthoringAttemptStateSchema = z.enum([
1998
3334
  "drafting",
@@ -2031,6 +3367,8 @@ const AuthoringAttemptSummarySchema = z.object({
2031
3367
  message: z.string(),
2032
3368
  repairable: z.boolean()
2033
3369
  }).strict().optional(),
3370
+ /** Verified without loading its interface, because no browser was available; the interface itself is unchecked. */
3371
+ uiUnverified: z.boolean().optional(),
2034
3372
  createdAt: z.number().int().nonnegative(),
2035
3373
  settledAt: z.number().int().nonnegative().optional()
2036
3374
  }).strict();
@@ -2042,6 +3380,15 @@ const AuthoringTaskSummarySchema = z.object({
2042
3380
  title: z.string(),
2043
3381
  requirementSummary: z.string(),
2044
3382
  status: AuthoringTaskStatusSchema,
3383
+ /** `create` builds a new extension; `revise` changes `targetExtensionId` starting from `baseRevisionId`. */
3384
+ kind: z.enum(["create", "revise"]).default("create"),
3385
+ targetExtensionId: ExtensionIdSchema.optional(),
3386
+ baseRevisionId: ExtensionRevisionIdSchema.optional(),
3387
+ referenceRevisionId: ExtensionRevisionIdSchema.optional(),
3388
+ /** Why the task is paused; it continues when the agent picks it up in a later conversation. */
3389
+ pausedReason: z.string().optional(),
3390
+ /** The conversation the task runs in is live, so its candidate can be previewed directly. */
3391
+ live: z.boolean().default(false),
2045
3392
  approvalPolicy: z.enum(["risk-stable", "fully-automatic"]),
2046
3393
  approvedRiskDigest: z.string().regex(/^[a-f0-9]{64}$/u).optional(),
2047
3394
  revision: z.number().int().positive(),
@@ -2100,6 +3447,22 @@ const ImageUnderstandingPolicyApiSchema = z.object({
2100
3447
  maxTokens: z.number().int().min(256).max(8192)
2101
3448
  }).strict()])
2102
3449
  }).strict();
3450
+ const CommandAccountUsageSchema = z.enum([
3451
+ "read",
3452
+ "issues",
3453
+ "pull-requests",
3454
+ "push"
3455
+ ]);
3456
+ /**
3457
+ * One linked account the agent's commands act as, at most one per platform (`service`). Grants saved before linked
3458
+ * accounts name the account without its `acc_` prefix; both forms resolve to the same account.
3459
+ */
3460
+ const CommandAccountGrantSchema = z.object({
3461
+ service: LinkedAccountPlatformIdSchema,
3462
+ accountId: NonEmptyStringSchema.max(72),
3463
+ /** Told to the agent as guidance, not enforced; empty gives no hint. */
3464
+ usage: z.array(CommandAccountUsageSchema).max(4).default([])
3465
+ }).strict();
2103
3466
  const AgentCapabilitiesSchema = z.object({
2104
3467
  subagents: z.boolean(),
2105
3468
  fileTools: z.boolean(),
@@ -2112,10 +3475,35 @@ const AgentCapabilitiesSchema = z.object({
2112
3475
  /** Tools are called from one TypeScript program (`run_code`); takes effect only with `developmentShell`. */
2113
3476
  codeRun: z.boolean().default(false),
2114
3477
  /** Network for commands; absent in older clients means on. */
2115
- commandNetwork: z.boolean().default(true)
3478
+ commandNetwork: z.boolean().default(true),
3479
+ communityFeedbackAuto: z.boolean().default(false),
3480
+ /** Linked accounts this agent's commands act as, one per platform; absent in older clients means none. */
3481
+ commandAccounts: z.array(CommandAccountGrantSchema).max(8).default([]),
3482
+ /**
3483
+ * What the agent may do with extensions without the console: `manual` only develops and test-runs, `confirm` asks
3484
+ * an administrator in the channel for every step, `autonomous` takes ordinary steps that only affect itself.
3485
+ */
3486
+ extensionAutonomy: z.enum([
3487
+ "manual",
3488
+ "confirm",
3489
+ "autonomous"
3490
+ ]).default("manual"),
3491
+ /** Whose requests make the agent develop or change extensions: anyone in the channel, or administrators only. */
3492
+ extensionRequesters: z.enum(["everyone", "admins"]).default("everyone"),
3493
+ /**
3494
+ * Whose requests make the agent change extension configuration. With `everyone`, members may only have it change
3495
+ * ordinary fields of its own configuration; network fields, the host layer and credentials still need an
3496
+ * administrator.
3497
+ */
3498
+ extensionConfigRequesters: z.enum(["everyone", "admins"]).default("admins")
2116
3499
  }).strict();
2117
3500
  const DynamicClientApprovalPolicySchema = z.enum(["manual", "automatic"]);
2118
- const NotificationEventKeySchema = z.enum(["dynamic-client-approval-requested"]);
3501
+ const NotificationEventKeySchema = z.enum([
3502
+ "dynamic-client-approval-requested",
3503
+ "community-feedback-update",
3504
+ "credential-requested",
3505
+ "extension-notification"
3506
+ ]);
2119
3507
  const NotificationSettingsViewSchema = z.object({
2120
3508
  revision: z.number().int().positive().optional(),
2121
3509
  system: z.object({ enabled: z.boolean() }).strict(),
@@ -2124,7 +3512,12 @@ const NotificationSettingsViewSchema = z.object({
2124
3512
  serverUrl: z.url(),
2125
3513
  deviceKeyConfigured: z.boolean()
2126
3514
  }).strict(),
2127
- events: z.record(NotificationEventKeySchema, z.boolean())
3515
+ events: z.object({
3516
+ "dynamic-client-approval-requested": z.boolean(),
3517
+ "community-feedback-update": z.boolean().default(true),
3518
+ "credential-requested": z.boolean().default(true),
3519
+ "extension-notification": z.boolean().default(true)
3520
+ }).strict()
2128
3521
  }).strict();
2129
3522
  const UpdateNotificationSettingsRequestSchema = z.object({
2130
3523
  expectedRevision: z.number().int().positive().optional(),
@@ -2135,7 +3528,12 @@ const UpdateNotificationSettingsRequestSchema = z.object({
2135
3528
  deviceKey: z.string().trim().min(1).max(2048).optional(),
2136
3529
  clearDeviceKey: z.boolean().optional()
2137
3530
  }).strict(),
2138
- events: z.record(NotificationEventKeySchema, z.boolean())
3531
+ events: z.object({
3532
+ "dynamic-client-approval-requested": z.boolean(),
3533
+ "community-feedback-update": z.boolean().optional(),
3534
+ "credential-requested": z.boolean().optional(),
3535
+ "extension-notification": z.boolean().optional()
3536
+ }).strict()
2139
3537
  }).strict().refine((value) => !(value.bark.deviceKey !== void 0 && value.bark.clearDeviceKey === true), {
2140
3538
  message: "不能同时更新并清除 Bark Device Key。",
2141
3539
  path: ["bark"]
@@ -2148,13 +3546,99 @@ const ClientNotificationFeedResponseSchema = z.object({
2148
3546
  cursor: z.number().int().nonnegative(),
2149
3547
  notifications: z.array(ClientNotificationSchema)
2150
3548
  }).strict();
3549
+ /** Which model writes one kind of compaction summary: that kind's default, or a model chosen for this agent. */
3550
+ const AgentCompactionModelChoiceSchema = z.discriminatedUnion("mode", [z.object({ mode: z.literal("follow") }).strict(), z.object({
3551
+ mode: z.literal("custom"),
3552
+ model: AgentModelSchema
3553
+ }).strict()]);
3554
+ /**
3555
+ * In-session compaction follows the main model by default, so the replayed conversation hits the provider's cache;
3556
+ * compaction into a new session follows the host's compaction model.
3557
+ */
3558
+ const AgentCompactionPolicySchema = z.object({
3559
+ inSession: AgentCompactionModelChoiceSchema,
3560
+ newSession: AgentCompactionModelChoiceSchema
3561
+ }).strict();
3562
+ /** The host's idle compaction threshold, summary model and wait limit. */
3563
+ const CompactionSettingsSchema = z.object({
3564
+ /** Minimum context occupancy for idle rollover; older settings inherit 50%. */
3565
+ idleThresholdPercent: z.number().int().min(1).max(100).default(50),
3566
+ newSessionModel: z.discriminatedUnion("mode", [z.object({ mode: z.literal("main") }).strict(), z.object({
3567
+ mode: z.literal("custom"),
3568
+ model: AgentModelSchema
3569
+ }).strict()]),
3570
+ /** Past this the new session starts with a fallback note instead of a summary. */
3571
+ timeoutSeconds: z.number().int().min(30).max(900)
3572
+ }).strict();
3573
+ const DEFAULT_COMPACTION_SETTINGS = {
3574
+ idleThresholdPercent: 50,
3575
+ newSessionModel: { mode: "main" },
3576
+ timeoutSeconds: 180
3577
+ };
3578
+ const FALLBACK_MODEL_LIMIT = 3;
3579
+ /**
3580
+ * Models an agent switches to, in order, when its main model has used up its quota or stays unavailable after the
3581
+ * usual retries. Empty leaves the main model alone, as before fallback models existed.
3582
+ */
3583
+ const AgentFallbackModelsSchema = z.array(AgentModelSchema).max(3).refine((models) => new Set(models.map((model) => `${model.provider}\0${model.model}`)).size === models.length, "备用模型不能重复。");
3584
+ /** Why a channel conversation left its main model. */
3585
+ const ModelFallbackReasonSchema = z.enum([
3586
+ "quota",
3587
+ "rate-limit",
3588
+ "unavailable"
3589
+ ]);
3590
+ /** How long a model that failed is passed over before conversations try it again. */
3591
+ const ModelFallbackSettingsSchema = z.object({
3592
+ /** After rate limits, server errors, timeouts or empty replies that outlasted the usual retries. */
3593
+ unavailableCooldownMinutes: z.number().int().min(1).max(240),
3594
+ /** After the quota or balance ran out. */
3595
+ quotaCooldownMinutes: z.number().int().min(5).max(1440)
3596
+ }).strict();
3597
+ const DEFAULT_MODEL_FALLBACK_SETTINGS = {
3598
+ unavailableCooldownMinutes: 10,
3599
+ quotaCooldownMinutes: 60
3600
+ };
3601
+ /** The name an agent passes to open a sub-conversation on its main model; no candidate may take it. */
3602
+ const SUB_CONVERSATION_MAIN_MODEL = "主模型";
3603
+ const SUB_CONVERSATION_MODEL_LIMITS = {
3604
+ candidates: 8,
3605
+ name: 20,
3606
+ guidance: 200
3607
+ };
3608
+ /**
3609
+ * Models an agent may open sub-conversations with, each named so the agent can pick it and described so it knows
3610
+ * when to. Without a `default`, a sub-conversation opened without naming a model follows the main model.
3611
+ */
3612
+ const AgentSubConversationModelsSchema = z.object({
3613
+ candidates: z.array(z.object({
3614
+ name: z.string().trim().min(1, "请填写子对话模型的名称。").max(SUB_CONVERSATION_MODEL_LIMITS.name).regex(/^[^\s,,、]+(?: [^\s,,、]+)*$/u, "子对话模型的名称不能含换行、逗号或顿号。").refine((name) => name !== SUB_CONVERSATION_MAIN_MODEL, `「${SUB_CONVERSATION_MAIN_MODEL}」是保留名称。`),
3615
+ model: AgentModelSchema,
3616
+ guidance: z.string().trim().max(SUB_CONVERSATION_MODEL_LIMITS.guidance)
3617
+ }).strict()).max(SUB_CONVERSATION_MODEL_LIMITS.candidates),
3618
+ default: z.string().trim().min(1).optional()
3619
+ }).strict().superRefine((policy, context) => {
3620
+ const names = policy.candidates.map((candidate) => candidate.name);
3621
+ if (new Set(names).size !== names.length) context.addIssue({
3622
+ code: "custom",
3623
+ message: "子对话模型的名称不能重复。"
3624
+ });
3625
+ if (policy.default !== void 0 && !names.includes(policy.default)) context.addIssue({
3626
+ code: "custom",
3627
+ message: "默认的子对话模型不在候选里。"
3628
+ });
3629
+ });
3630
+ const NO_SUB_CONVERSATION_MODELS = { candidates: [] };
2151
3631
  const AgentRevisionRequestContentSchema = z.object({
2152
3632
  displayName: z.string().trim().min(1).max(80),
2153
3633
  persona: z.string().max(64 * 1024).default(""),
2154
3634
  personaDocument: PromptDocumentV1Schema.optional(),
2155
3635
  model: AgentModelSchema,
2156
3636
  imagePolicy: ImageUnderstandingPolicyApiSchema.optional(),
2157
- dynamicClientApprovalPolicy: DynamicClientApprovalPolicySchema.optional()
3637
+ dynamicClientApprovalPolicy: DynamicClientApprovalPolicySchema.optional(),
3638
+ compaction: AgentCompactionPolicySchema.optional(),
3639
+ subConversationModels: AgentSubConversationModelsSchema.optional(),
3640
+ fallbackModels: AgentFallbackModelsSchema.optional(),
3641
+ aliases: AgentAliasesSchema.optional()
2158
3642
  }).strict();
2159
3643
  const validatePersonaDocumentProjection = (value, context) => {
2160
3644
  if (value.personaDocument !== void 0 && promptDocumentPlainText(value.personaDocument) !== value.persona) context.addIssue({
@@ -2173,11 +3657,21 @@ const ReviseAgentRequestSchema = AgentRevisionRequestContentSchema.extend({ expe
2173
3657
  const UpdateAgentCapabilitiesRequestSchema = AgentCapabilitiesSchema.partial().extend({
2174
3658
  scheduledTasks: z.boolean().optional(),
2175
3659
  codeRun: z.boolean().optional(),
2176
- commandNetwork: z.boolean().optional()
3660
+ commandNetwork: z.boolean().optional(),
3661
+ communityFeedbackAuto: z.boolean().optional(),
3662
+ commandAccounts: z.array(CommandAccountGrantSchema).max(8).optional(),
3663
+ extensionAutonomy: z.enum([
3664
+ "manual",
3665
+ "confirm",
3666
+ "autonomous"
3667
+ ]).optional(),
3668
+ extensionRequesters: z.enum(["everyone", "admins"]).optional(),
3669
+ extensionConfigRequesters: z.enum(["everyone", "admins"]).optional()
2177
3670
  }).strict().refine((value) => Object.values(value).some((entry) => entry !== void 0), "至少提供一个能力。");
2178
3671
  const TriggerPolicySchema = z.enum([
2179
3672
  "always",
2180
3673
  "mentioned-or-replied",
3674
+ "smart",
2181
3675
  "command",
2182
3676
  "observe-only"
2183
3677
  ]);
@@ -2186,6 +3680,16 @@ const WorkTreeOrderSchema = z.object({
2186
3680
  channelIdsByAgent: z.record(AgentIdSchema, z.array(ChannelIdSchema)),
2187
3681
  unboundChannelIds: z.array(ChannelIdSchema)
2188
3682
  }).strict();
3683
+ /** The group key of 「未接线」 in `collapsedGroupIds`; agent groups use the agent id. */
3684
+ const UNBOUND_CHANNEL_GROUP_ID = "unbound";
3685
+ /**
3686
+ * How the console arranges its channel list: pinned channels in their order and the groups it has collapsed. Shared
3687
+ * by every device signed in to the console; it never changes bindings.
3688
+ */
3689
+ const ChannelListViewSchema = z.object({
3690
+ pinnedChannelIds: z.array(ChannelIdSchema).max(200),
3691
+ collapsedGroupIds: z.array(z.union([AgentIdSchema, z.literal(UNBOUND_CHANNEL_GROUP_ID)])).max(500)
3692
+ }).strict();
2189
3693
  const SnapshotMessagePartSchema = z.discriminatedUnion("type", [
2190
3694
  z.object({
2191
3695
  type: z.literal("text"),
@@ -2199,7 +3703,8 @@ const SnapshotMessagePartSchema = z.discriminatedUnion("type", [
2199
3703
  z.object({
2200
3704
  type: z.literal("image"),
2201
3705
  assetId: AssetIdSchema,
2202
- alt: z.string().optional()
3706
+ alt: z.string().optional(),
3707
+ sticker: z.literal(true).optional()
2203
3708
  }).strict(),
2204
3709
  z.object({
2205
3710
  type: z.literal("file"),
@@ -2258,7 +3763,14 @@ const HostSnapshotMessageSchema = z.object({
2258
3763
  action: z.enum(["retry", "confirm-delivered"]),
2259
3764
  resolvedAt: z.number().int().safe().nonnegative()
2260
3765
  }).strict().optional(),
2261
- origin: z.enum(["admin-console"]).optional(),
3766
+ origin: z.enum([
3767
+ "admin-console",
3768
+ "command",
3769
+ "extension-notice"
3770
+ ]).optional(),
3771
+ command: CommandExecutionRecordSchema.optional(),
3772
+ /** A host notice about extension work: a request an administrator must confirm, or what an action did. */
3773
+ extensionNotice: z.object({ requestNumber: z.number().int().positive().optional() }).strict().optional(),
2262
3774
  /** What the agent's inbound hooks decided for this message, when anything differs from the default. */
2263
3775
  inboundHook: z.object({
2264
3776
  trigger: z.enum([
@@ -2271,11 +3783,23 @@ const HostSnapshotMessageSchema = z.object({
2271
3783
  extensions: z.array(z.string()),
2272
3784
  problems: z.array(z.string()).optional()
2273
3785
  }).strict().optional(),
3786
+ /** Extensions that processed the agent's message before it was sent; `followUp` marks a message one appended. */
3787
+ outboundProcessing: z.object({
3788
+ extensions: z.array(z.string()),
3789
+ rewritten: z.boolean(),
3790
+ followUp: z.literal(true).optional()
3791
+ }).strict().optional(),
2274
3792
  /** A scheduled task came due: a Host fact shown as a notice, not a member message. */
2275
3793
  scheduledTask: z.object({
2276
3794
  label: z.string(),
2277
3795
  extensionName: z.string().optional(),
2278
3796
  note: z.string().optional()
3797
+ }).strict().optional(),
3798
+ /** The agent finished waiting for someone to finish speaking: a Host fact shown as a notice. */
3799
+ responseWait: z.object({
3800
+ displayName: z.string().optional(),
3801
+ cause: z.enum(["quiet", "limit"]),
3802
+ waitedSeconds: z.number().int().nonnegative()
2279
3803
  }).strict().optional()
2280
3804
  }).strict();
2281
3805
  const HostConnectionEventSchema = z.object({
@@ -2328,7 +3852,9 @@ const PlatformUserListResponseSchema = z.object({
2328
3852
  }).strict(),
2329
3853
  activeChannelCount: z.number().int().nonnegative(),
2330
3854
  channelPreview: z.array(PlatformUserChannelPreviewSchema).max(3),
2331
- historicalOnly: z.boolean()
3855
+ historicalOnly: z.boolean(),
3856
+ /** Listed in Settings → Administrators. */
3857
+ administrator: z.boolean().default(false)
2332
3858
  }).strict()),
2333
3859
  facets: z.object({
2334
3860
  adapters: z.array(PlatformUserFacetAdapterSchema),
@@ -2350,6 +3876,7 @@ const ChannelRuntimePhaseSchema = z.enum([
2350
3876
  "idle",
2351
3877
  "thinking",
2352
3878
  "using-tool",
3879
+ "compacting",
2353
3880
  "waiting-input",
2354
3881
  "unavailable"
2355
3882
  ]);
@@ -2373,11 +3900,13 @@ const channelRuntimeToolFields = {
2373
3900
  inputPreview: z.string().optional(),
2374
3901
  resultPreview: z.string().optional(),
2375
3902
  wroteToChannel: z.boolean().optional(),
3903
+ /** `cancelled`: an extension stopped the message before it was sent. */
2376
3904
  deliveryState: z.enum([
2377
3905
  "sent",
2378
3906
  "partially-sent",
2379
3907
  "failed",
2380
- "unknown"
3908
+ "unknown",
3909
+ "cancelled"
2381
3910
  ]).optional(),
2382
3911
  durationMs: z.number().int().nonnegative().optional()
2383
3912
  };
@@ -2549,6 +4078,18 @@ const ChannelRuntimeProjectionSchema = z.object({
2549
4078
  episodeId: EpisodeIdSchema.optional(),
2550
4079
  phase: ChannelRuntimePhaseSchema,
2551
4080
  summary: z.string(),
4081
+ /** A compaction under way: inside the current session, or before a new session opens. */
4082
+ compaction: z.object({
4083
+ kind: z.enum(["in-session", "new-session"]),
4084
+ startedAt: z.number().int().nonnegative()
4085
+ }).strict().optional(),
4086
+ /** The conversation runs on a fallback model; it tries the main model again at a new message after `retryMainAt`. */
4087
+ modelFallback: z.object({
4088
+ model: AgentModelSchema,
4089
+ reason: ModelFallbackReasonSchema,
4090
+ since: z.number().int().nonnegative(),
4091
+ retryMainAt: z.number().int().nonnegative()
4092
+ }).strict().optional(),
2552
4093
  pendingInjectCount: z.number().int().nonnegative(),
2553
4094
  occupancy: ChannelRuntimeOccupancySchema.optional(),
2554
4095
  cache: ChannelRuntimeCacheSchema.optional(),
@@ -2674,6 +4215,47 @@ const MessagePacingSchema = z.enum([
2674
4215
  ]);
2675
4216
  const DEFAULT_MESSAGE_PACING = "normal";
2676
4217
  const MessagePacingSettingsSchema = z.object({ pacing: MessagePacingSchema }).strict();
4218
+ /**
4219
+ * A conversation of its own under a channel's conversation (docs/NekroNxt界面交互模型.md §5.6): the agent opens one
4220
+ * for a separate piece of work, and the host opens scripted ones to check creation candidates. It has its own log
4221
+ * and context, and is shown under its channel.
4222
+ */
4223
+ const SubConversationSchema = z.object({
4224
+ id: SubConversationIdSchema,
4225
+ channelId: ChannelIdSchema,
4226
+ episodeId: EpisodeIdSchema,
4227
+ agentId: AgentIdSchema,
4228
+ title: z.string().min(1).max(200),
4229
+ /** `agent`: the agent opened it with a tool; `host`: NekroNXT opened it, such as to check a candidate. */
4230
+ openedBy: z.enum(["agent", "host"]),
4231
+ /** `model`: the agent's model talks in it; `script`: the host plays fixed tool calls. */
4232
+ driver: z.enum(["model", "script"]),
4233
+ status: z.enum(["open", "closed"]),
4234
+ closeReason: z.enum([
4235
+ "completed",
4236
+ "closed-by-agent",
4237
+ "closed-by-admin",
4238
+ "failed",
4239
+ "conversation-ended"
4240
+ ]).optional(),
4241
+ /** What it handed back to the channel's conversation when it ended. */
4242
+ summary: z.string().max(4e3).optional(),
4243
+ authoringTaskId: AuthoringTaskIdSchema.optional(),
4244
+ /** The model a model-driven sub-conversation talks in; absent for scripts and ones opened before it was kept. */
4245
+ model: AgentModelSchema.optional(),
4246
+ createdAt: z.number().int().nonnegative(),
4247
+ closedAt: z.number().int().nonnegative().optional()
4248
+ }).strict();
4249
+ /** How long ended sub-conversations are kept before they are cleaned up. */
4250
+ const SubConversationRetentionSchema = z.enum([
4251
+ "1d",
4252
+ "3d",
4253
+ "7d",
4254
+ "30d",
4255
+ "never"
4256
+ ]);
4257
+ const DEFAULT_SUB_CONVERSATION_RETENTION = "7d";
4258
+ const SubConversationSettingsSchema = z.object({ retention: SubConversationRetentionSchema }).strict();
2677
4259
  /** `keyword`: SQLite keyword search only; `builtin`: keywords fused with the built-in semantic model. */
2678
4260
  const RetrievalModeSchema = z.enum(["keyword", "builtin"]);
2679
4261
  /** Search used by extension indexes (表情包与扩展素材能力 §6.4). */
@@ -2709,6 +4291,26 @@ const RetrievalStatusSchema = z.object({
2709
4291
  error: z.string().optional()
2710
4292
  }).strict()
2711
4293
  }).strict();
4294
+ /** Where the Host keeps restore points it takes before an upgrade, or none. */
4295
+ const UpgradeBackupModeSchema = z.enum([
4296
+ "data",
4297
+ "directory",
4298
+ "off"
4299
+ ]);
4300
+ const UpgradeBackupSettingsSchema = z.object({
4301
+ mode: UpgradeBackupModeSchema,
4302
+ /** The chosen directory when `mode` is `directory`. */
4303
+ directory: z.string().nullable(),
4304
+ /** Set through the server's environment; the settings page cannot change it. */
4305
+ locked: z.boolean(),
4306
+ /** Restore points kept; older ones are removed after an upgrade succeeds. */
4307
+ keep: z.number().int().positive(),
4308
+ /** Restore points currently in the chosen place. */
4309
+ usage: z.object({
4310
+ count: z.number().int().nonnegative(),
4311
+ bytes: z.number().int().nonnegative()
4312
+ }).strict()
4313
+ }).strict();
2712
4314
  /** What the agent keeps about individual members of one channel; each note comes with that member's messages. */
2713
4315
  const ChannelMemberNotesViewSchema = z.object({
2714
4316
  notes: z.array(z.object({
@@ -2820,7 +4422,10 @@ const AttentionItemSchema = z.object({
2820
4422
  "authoring-approval",
2821
4423
  "connection-unhealthy",
2822
4424
  "agent-model-unavailable",
2823
- "agent-vision-unavailable"
4425
+ "agent-vision-unavailable",
4426
+ "logs-unavailable",
4427
+ "community-feedback",
4428
+ "extension-update"
2824
4429
  ]),
2825
4430
  severity: z.enum([
2826
4431
  "critical",
@@ -2833,7 +4438,10 @@ const AttentionItemSchema = z.object({
2833
4438
  "channel",
2834
4439
  "authoring-task",
2835
4440
  "connection",
2836
- "agent"
4441
+ "agent",
4442
+ "logs",
4443
+ "community-feedback",
4444
+ "extension-update"
2837
4445
  ]),
2838
4446
  id: NonEmptyStringSchema
2839
4447
  }).strict(),
@@ -2852,7 +4460,10 @@ const AttentionItemSchema = z.object({
2852
4460
  "resolve-delivery",
2853
4461
  "open-authoring-task",
2854
4462
  "open-connection",
2855
- "open-agent"
4463
+ "open-agent",
4464
+ "open-logs",
4465
+ "open-community-feedback",
4466
+ "open-extension-updates"
2856
4467
  ]),
2857
4468
  label: z.string().min(1).max(40)
2858
4469
  }).strict(),
@@ -2980,7 +4591,61 @@ const CodeRunAvailabilitySchema = z.object({
2980
4591
  error: z.string().optional()
2981
4592
  }).strict().optional()
2982
4593
  }).strict();
4594
+ /** The GitHub CLI commands call: found on this machine, or downloaded by NekroNXT where it can. */
4595
+ const GithubCliAvailabilitySchema = CodeRunAvailabilitySchema;
4596
+ /** The optional headless Chromium that loads and checks creation candidates when no page is open. */
4597
+ const VerificationBrowserAvailabilitySchema = CodeRunAvailabilitySchema;
4598
+ /** A platform's own program that linked accounts work through, such as the GitHub CLI. */
4599
+ const LinkedAccountPlatformToolSchema = z.object({
4600
+ /** The runtime download routes it is managed by (`downloadGithubCli`, `removeGithubCli`). */
4601
+ id: z.enum(["github-cli"]),
4602
+ name: z.string(),
4603
+ availability: GithubCliAvailabilitySchema
4604
+ }).strict();
4605
+ /** 设置 → 关联账号: every platform the host supports, with its accounts and tools. */
4606
+ const LinkedAccountsViewSchema = z.object({
4607
+ platforms: z.array(z.object({
4608
+ id: LinkedAccountPlatformIdSchema,
4609
+ name: z.string(),
4610
+ addMethods: z.array(LinkedAccountMethodSchema),
4611
+ tool: LinkedAccountPlatformToolSchema.optional(),
4612
+ accounts: z.array(LinkedAccountViewSchema)
4613
+ }).strict()),
4614
+ /** Logins found in the local GitHub CLI; empty when it is missing or not logged in. */
4615
+ localGithubLogins: z.array(LocalGithubLoginSchema)
4616
+ }).strict();
4617
+ const RemoveLinkedAccountResultSchema = z.discriminatedUnion("removed", [z.object({
4618
+ removed: z.literal(true),
4619
+ view: LinkedAccountsViewSchema
4620
+ }).strict(), z.object({
4621
+ removed: z.literal(false),
4622
+ grantedAgentIds: z.array(AgentIdSchema)
4623
+ }).strict()]);
4624
+ /** An extension action an agent asked an administrator to confirm, or one it took on its own. */
4625
+ const ExtensionRequestSchema = z.object({
4626
+ number: z.number().int().positive(),
4627
+ kind: z.string(),
4628
+ agentId: AgentIdSchema,
4629
+ channelId: ChannelIdSchema.nullable(),
4630
+ extensionId: ExtensionIdSchema.nullable(),
4631
+ summary: z.string(),
4632
+ status: z.enum([
4633
+ "pending",
4634
+ "approved",
4635
+ "rejected",
4636
+ "expired",
4637
+ "completed",
4638
+ "failed"
4639
+ ]),
4640
+ autonomous: z.boolean(),
4641
+ resultMessage: z.string().nullable(),
4642
+ decidedBy: z.string().nullable(),
4643
+ createdAt: z.number().int().nonnegative(),
4644
+ expiresAt: z.number().int().nonnegative(),
4645
+ decidedAt: z.number().int().nonnegative().nullable()
4646
+ }).strict();
2983
4647
  const HostSnapshotSchema = z.object({
4648
+ communityFeedback: CommunityFeedbackSnapshotSchema.optional(),
2984
4649
  upgrade: HostUpgradeSummarySchema.optional(),
2985
4650
  cursor: HostSyncCursorSchema,
2986
4651
  diagnosticsSampledAt: z.number().int().nonnegative(),
@@ -2999,18 +4664,31 @@ const HostSnapshotSchema = z.object({
2999
4664
  id: NonEmptyStringSchema,
3000
4665
  name: z.string(),
3001
4666
  description: z.string().optional(),
3002
- inputModalities: z.array(z.string()).optional()
4667
+ inputModalities: z.array(z.string()).optional(),
4668
+ /** Selectable thinking levels, least to most; absent when the model offers no choice. */
4669
+ reasoning: z.object({
4670
+ efforts: z.array(z.object({
4671
+ id: NonEmptyStringSchema,
4672
+ name: z.string()
4673
+ }).strict()).min(1),
4674
+ defaultEffort: NonEmptyStringSchema.optional()
4675
+ }).strict().optional()
3003
4676
  }).strict()),
3004
4677
  capabilityAvailability: z.object({
3005
4678
  subagents: z.object({ available: z.boolean() }).strict(),
3006
4679
  /** Optional in older hosts, which never offer `run_code`. */
3007
4680
  codeRun: CodeRunAvailabilitySchema.optional(),
4681
+ /** Optional in older hosts, which never offer command accounts. */
4682
+ githubCli: GithubCliAvailabilitySchema.optional(),
4683
+ /** Optional in older hosts, which check candidates only in an open page. */
4684
+ verificationBrowser: VerificationBrowserAvailabilitySchema.optional(),
3008
4685
  /** What this host can confine for commands beyond file writes; optional in older hosts. */
3009
4686
  commandConfinement: z.object({
3010
4687
  readScope: z.boolean(),
3011
4688
  networkControl: z.boolean()
3012
4689
  }).strict().optional(),
3013
4690
  webSearch: z.object({
4691
+ unavailableReason: z.string().optional(),
3014
4692
  provider: z.literal("deepseek-official"),
3015
4693
  available: z.boolean(),
3016
4694
  credentialConfigured: z.boolean(),
@@ -3031,6 +4709,19 @@ const HostSnapshotSchema = z.object({
3031
4709
  capabilities: AgentCapabilitiesSchema,
3032
4710
  imagePolicy: ImageUnderstandingPolicyApiSchema,
3033
4711
  dynamicClientApprovalPolicy: DynamicClientApprovalPolicySchema,
4712
+ /** Optional for older hosts, whose agents always follow both defaults. */
4713
+ compaction: AgentCompactionPolicySchema.optional(),
4714
+ /** Optional for older hosts, whose agents offer no candidates. */
4715
+ subConversationModels: AgentSubConversationModelsSchema.optional(),
4716
+ /** Optional for older hosts, whose agents have no fallback models. */
4717
+ fallbackModels: AgentFallbackModelsSchema.optional(),
4718
+ /** Optional for older hosts, whose agents have no aliases. */
4719
+ aliases: AgentAliasesSchema.optional(),
4720
+ /**
4721
+ * Enabled extensions that process the agent's messages before they are sent, in the order they run. Absent
4722
+ * when none does.
4723
+ */
4724
+ outboundOrder: z.array(ExtensionIdSchema).optional(),
3034
4725
  imageDiagnostics: z.object({
3035
4726
  route: z.object({
3036
4727
  mode: z.enum([
@@ -3079,6 +4770,8 @@ const HostSnapshotSchema = z.object({
3079
4770
  "direct"
3080
4771
  ]),
3081
4772
  displayName: z.string().optional(),
4773
+ localDisplayName: z.string().optional(),
4774
+ platformDisplayName: z.string().optional(),
3082
4775
  boundAgentId: AgentIdSchema.optional(),
3083
4776
  runtimePhase: ChannelRuntimePhaseSchema.default("idle"),
3084
4777
  activity: ChannelActivitySummarySchema.default({
@@ -3091,10 +4784,14 @@ const HostSnapshotSchema = z.object({
3091
4784
  channelId: ChannelIdSchema,
3092
4785
  agentId: AgentIdSchema,
3093
4786
  triggerPolicy: TriggerPolicySchema,
4787
+ /** Channel pause, independent of the response rule. */
4788
+ paused: z.boolean().default(false),
3094
4789
  processingFeedback: z.enum(["auto", "off"]).default("auto"),
3095
4790
  /** Absent means `observe`. */
3096
4791
  localAgentMessages: z.enum(["observe", "trigger"]).optional(),
3097
4792
  activityTriggerOverrides: ActivityTriggerOverridesSchema.default({}),
4793
+ /** Absent on older hosts; missing keys use the defaults. */
4794
+ responseTiming: ResponseTimingSettingsSchema.optional(),
3098
4795
  boundAt: z.number().int().safe().nonnegative()
3099
4796
  }).strict())
3100
4797
  }).strict()),
@@ -3103,12 +4800,18 @@ const HostSnapshotSchema = z.object({
3103
4800
  channelIdsByAgent: {},
3104
4801
  unboundChannelIds: []
3105
4802
  }),
4803
+ channelListView: ChannelListViewSchema.default({
4804
+ pinnedChannelIds: [],
4805
+ collapsedGroupIds: []
4806
+ }),
3106
4807
  messages: z.array(HostSnapshotMessageSchema),
3107
4808
  connections: z.array(z.object({
3108
4809
  id: ConnectionIdSchema,
3109
4810
  adapterKey: NonEmptyStringSchema,
3110
4811
  alias: ConnectionAliasOutputSchema.optional(),
3111
4812
  activityTriggerDefaults: z.array(AdapterActivityKeySchema).default([]),
4813
+ configuredSecrets: z.array(z.string()).optional(),
4814
+ boundCredentials: BoundCredentialsSchema.optional(),
3112
4815
  status: z.object({
3113
4816
  state: z.enum([
3114
4817
  "stopped",
@@ -3178,9 +4881,45 @@ const HostSnapshotSchema = z.object({
3178
4881
  displayName: z.string(),
3179
4882
  description: z.string(),
3180
4883
  createdByAgentId: AgentIdSchema.optional(),
4884
+ /** The Revision of another extension this one was branched from. */
4885
+ branchOf: z.object({
4886
+ extensionId: ExtensionIdSchema,
4887
+ revisionId: ExtensionRevisionIdSchema,
4888
+ /** Present while the original is on this machine. */
4889
+ displayName: z.string().optional()
4890
+ }).strict().optional(),
4891
+ /** Shape version of the data stored on this machine. */
4892
+ dataVersion: z.number().int().positive().default(1),
4893
+ /** The unfinished revise task of this extension, if any. */
4894
+ openRevisionTaskId: AuthoringTaskIdSchema.optional(),
4895
+ /** Whether this machine publishes (`owner`) or follows the line on each community. */
4896
+ communityLinks: z.array(z.object({
4897
+ communityUrl: z.string(),
4898
+ role: z.enum(["owner", "subscriber"])
4899
+ }).strict()).default([]),
3181
4900
  revisions: z.array(z.object({
3182
4901
  id: ExtensionRevisionIdSchema,
3183
4902
  revisionNumber: z.number().int().positive(),
4903
+ /** Version number from the lineage, `v3` (or `v3·2` for a second Revision of the same generation). */
4904
+ versionLabel: z.string(),
4905
+ parentRevisionId: ExtensionRevisionIdSchema.optional(),
4906
+ origin: z.enum([
4907
+ "authored",
4908
+ "file",
4909
+ "community",
4910
+ "branch"
4911
+ ]),
4912
+ authoringTaskId: AuthoringTaskIdSchema.optional(),
4913
+ dataVersion: z.number().int().positive(),
4914
+ /** Community releases this Revision is; installs and publishes from here both record one. */
4915
+ releases: z.array(z.object({
4916
+ communityUrl: z.string(),
4917
+ releaseId: CommunityReleaseIdSchema,
4918
+ number: z.number().int().positive().nullable(),
4919
+ publisherHandle: z.string(),
4920
+ via: z.enum(["install", "publish"]),
4921
+ recordedAt: z.number().int().nonnegative()
4922
+ }).strict()).default([]),
3184
4923
  format: z.enum(["current", "unavailable"]).optional(),
3185
4924
  ui: ExtensionUiContributionsSchema.default(EMPTY_EXTENSION_UI_CONTRIBUTIONS),
3186
4925
  /** The host instance's configuration form (`config.host`). */
@@ -3190,8 +4929,6 @@ const HostSnapshotSchema = z.object({
3190
4929
  /** 扩展包自带图标的读取路径(同源、按摘要寻址、可长期缓存);没有图标时缺省。 */
3191
4930
  iconUrl: z.string().regex(/^\/api\/extensions\/[^/]+\/revisions\/[^/]+\/icon\/[a-f0-9]{64}\.(?:svg|png|webp)$/u).optional(),
3192
4931
  createdAt: z.number().int().safe().nonnegative(),
3193
- /** 从社区安装的版本的来源;本机保存与文件导入没有来源。 */
3194
- source: CommunitySourceSchema.optional(),
3195
4932
  provides: z.array(ExtensionProvideSchema),
3196
4933
  /** Whether this Revision can be enabled for agents (agent-layer contributions or capabilities). */
3197
4934
  agentLayer: z.boolean(),
@@ -3238,6 +4975,7 @@ const HostSnapshotSchema = z.object({
3238
4975
  /** Secret fields are removed; `configuredSecrets` lists those the Host stores. */
3239
4976
  config: JsonValueSchema,
3240
4977
  configuredSecrets: z.array(z.string()).optional(),
4978
+ boundCredentials: BoundCredentialsSchema.optional(),
3241
4979
  activatedAt: z.number().int().safe().nonnegative(),
3242
4980
  runtime: z.object({
3243
4981
  status: z.enum([
@@ -3271,6 +5009,7 @@ const HostSnapshotSchema = z.object({
3271
5009
  /** Secret fields are removed; `configuredSecrets` lists those the Host stores. */
3272
5010
  config: JsonValueSchema.default({}),
3273
5011
  configuredSecrets: z.array(z.string()).optional(),
5012
+ boundCredentials: BoundCredentialsSchema.optional(),
3274
5013
  runtime: z.object({
3275
5014
  status: z.enum([
3276
5015
  "active",
@@ -3335,17 +5074,36 @@ const HostSnapshotSchema = z.object({
3335
5074
  }).strict()
3336
5075
  }).strict()),
3337
5076
  authoringTasks: z.array(AuthoringTaskSummarySchema).default([]),
3338
- scheduledTasks: z.array(ScheduledTaskSchema).default([])
5077
+ /** Open sub-conversations, and the most recently ended ones of each channel. */
5078
+ subConversations: z.array(SubConversationSchema).default([]),
5079
+ scheduledTasks: z.array(ScheduledTaskSchema).default([]),
5080
+ /** Extension requests waiting for an administrator. */
5081
+ extensionRequests: z.array(ExtensionRequestSchema).default([])
3339
5082
  }).strict();
3340
- const MessageInputPartSchema = z.discriminatedUnion("type", [z.object({
3341
- type: z.literal("text"),
3342
- text: z.string().trim().min(1)
3343
- }).strict(), z.object({
3344
- type: z.literal("mention"),
3345
- memberId: ChannelMemberIdSchema
3346
- }).strict()]);
5083
+ const CHANNEL_COMPOSER_MAX_ATTACHMENTS = 20;
5084
+ const CHANNEL_COMPOSER_MAX_BYTES = 64 * 1024 * 1024;
5085
+ const MessageInputPartSchema = z.discriminatedUnion("type", [
5086
+ z.object({
5087
+ type: z.literal("text"),
5088
+ text: z.string().trim().min(1)
5089
+ }).strict(),
5090
+ z.object({
5091
+ type: z.literal("mention"),
5092
+ memberId: ChannelMemberIdSchema
5093
+ }).strict(),
5094
+ z.object({
5095
+ type: z.literal("image"),
5096
+ assetId: AssetIdSchema,
5097
+ alt: z.string().trim().max(500).optional()
5098
+ }).strict(),
5099
+ z.object({
5100
+ type: z.literal("file"),
5101
+ assetId: AssetIdSchema,
5102
+ name: z.string().trim().max(255).optional()
5103
+ }).strict()
5104
+ ]);
3347
5105
  const SendChannelMessageRequestSchema = z.object({
3348
- parts: z.array(MessageInputPartSchema).min(1),
5106
+ parts: z.array(MessageInputPartSchema).min(1).max(256).refine((parts) => parts.filter((part) => part.type === "image" || part.type === "file").length <= 20, "每条消息最多添加 20 个附件。"),
3349
5107
  clientEventId: NonEmptyStringSchema.optional(),
3350
5108
  senderMemberId: ChannelMemberIdSchema.optional()
3351
5109
  }).strict().refine((body) => body.parts.every((part) => part.type !== "text" || [...part.text].length <= 64 * 1024), "Message text must not exceed 64 KiB.");
@@ -3444,6 +5202,8 @@ const DshPluginCatalogEntrySchema = z.object({
3444
5202
  "tarball",
3445
5203
  "imported"
3446
5204
  ]).optional(),
5205
+ /** Published by the DSH maintainers on npm for the DSH release this build runs. */
5206
+ official: z.boolean().optional(),
3447
5207
  installedAt: z.number().int().safe().nonnegative().optional(),
3448
5208
  clientUiDetected: z.boolean().optional(),
3449
5209
  hostUi: DshNxtHostUiSchema.optional(),
@@ -3455,6 +5215,8 @@ const DshPluginCatalogEntrySchema = z.object({
3455
5215
  suggestedScope: z.enum(["host", "agent"]),
3456
5216
  selectedScope: z.enum(["host", "agent"]).optional(),
3457
5217
  config: JsonValueSchema,
5218
+ /** Host services this official entry declared and received; known once it has loaded. */
5219
+ grantedServices: z.array(NonEmptyStringSchema).optional(),
3458
5220
  activations: z.array(z.object({
3459
5221
  targetKey: NonEmptyStringSchema,
3460
5222
  target: z.enum(["host", "agent"]),
@@ -3463,18 +5225,24 @@ const DshPluginCatalogEntrySchema = z.object({
3463
5225
  diagnostic: z.object({
3464
5226
  status: z.enum([
3465
5227
  "active",
5228
+ "pending",
3466
5229
  "load-failed",
3467
5230
  "restore-failed",
3468
5231
  "dispose-failed"
3469
5232
  ]),
3470
5233
  phase: z.enum([
3471
5234
  "import",
5235
+ "dependency",
3472
5236
  "apply",
3473
5237
  "update",
3474
5238
  "dispose",
3475
5239
  "restore"
3476
5240
  ]),
3477
5241
  message: z.string().optional(),
5242
+ /** Services a pending entry still waits for. */
5243
+ waitingFor: z.array(NonEmptyStringSchema).optional(),
5244
+ /** The waited-for services this entry can never receive, since only official plugins get them. */
5245
+ restrictedServices: z.array(NonEmptyStringSchema).optional(),
3478
5246
  observedAt: z.number().int().safe().nonnegative()
3479
5247
  }).optional()
3480
5248
  }).strict())
@@ -3621,19 +5389,23 @@ const HostSseEventSchema = z.discriminatedUnion("event", [
3621
5389
  ]);
3622
5390
  /** Request content a model accepts; `image` enables native vision for agents using the model. */
3623
5391
  const LlmModelInputModalitiesSchema = z.array(z.enum(["text", "image"])).min(1);
5392
+ /** Thinking levels a model offers, least to most; the ids are the adapter's own. */
5393
+ const LlmModelReasoningEffortsSchema = z.array(NonEmptyStringSchema).min(1);
3624
5394
  const LlmProviderModelSchema = z.object({
3625
5395
  id: NonEmptyStringSchema,
3626
5396
  name: NonEmptyStringSchema,
3627
5397
  contextWindow: z.number().int().positive().optional(),
3628
5398
  maxTokens: z.number().int().positive().optional(),
3629
- inputModalities: LlmModelInputModalitiesSchema.optional()
5399
+ inputModalities: LlmModelInputModalitiesSchema.optional(),
5400
+ reasoningEfforts: LlmModelReasoningEffortsSchema.optional()
3630
5401
  }).strict();
3631
5402
  const LlmDiscoveredModelSchema = z.object({
3632
5403
  id: NonEmptyStringSchema,
3633
5404
  name: NonEmptyStringSchema.optional(),
3634
5405
  contextWindow: z.number().int().positive().optional(),
3635
5406
  maxTokens: z.number().int().positive().optional(),
3636
- inputModalities: LlmModelInputModalitiesSchema.optional()
5407
+ inputModalities: LlmModelInputModalitiesSchema.optional(),
5408
+ reasoningEfforts: LlmModelReasoningEffortsSchema.optional()
3637
5409
  }).strict();
3638
5410
  const LlmProviderCredentialSchema = z.object({
3639
5411
  configured: z.boolean(),
@@ -3671,7 +5443,62 @@ const LlmProviderViewSchema = z.object({
3671
5443
  /** The provider's adapter can list the models its endpoint offers. */
3672
5444
  discoverable: z.boolean(),
3673
5445
  /** `null` when the current configuration was never tested; absent from hosts that do not record tests. */
3674
- lastTest: LlmProviderTestResultSchema.nullable().optional()
5446
+ lastTest: LlmProviderTestResultSchema.nullable().optional(),
5447
+ /** Present when the provider can sign in with a subscription account instead of an API key. */
5448
+ subscription: z.object({
5449
+ label: NonEmptyStringSchema,
5450
+ /** The route uses the signed-in account rather than an API key. */
5451
+ active: z.boolean(),
5452
+ accountLabel: z.string().nullable()
5453
+ }).strict().optional()
5454
+ }).strict();
5455
+ const SubscriptionStatusSchema = z.object({
5456
+ provider: NonEmptyStringSchema,
5457
+ label: NonEmptyStringSchema,
5458
+ usageUrl: z.url(),
5459
+ available: z.boolean(),
5460
+ mode: z.enum([
5461
+ "unconfigured",
5462
+ "api-key",
5463
+ "subscription"
5464
+ ]),
5465
+ activeAccountId: z.string().nullable(),
5466
+ accounts: z.array(z.object({
5467
+ id: NonEmptyStringSchema,
5468
+ label: NonEmptyStringSchema,
5469
+ email: z.string().nullable(),
5470
+ createdAt: z.number().int().nonnegative()
5471
+ }).strict()),
5472
+ login: z.object({
5473
+ id: NonEmptyStringSchema,
5474
+ status: z.enum([
5475
+ "running",
5476
+ "authorized",
5477
+ "cancelled",
5478
+ "failed"
5479
+ ]),
5480
+ notices: z.array(z.object({
5481
+ message: z.string(),
5482
+ url: z.string().optional(),
5483
+ code: z.string().optional()
5484
+ }).strict()),
5485
+ prompt: z.object({
5486
+ id: NonEmptyStringSchema,
5487
+ kind: z.enum([
5488
+ "text",
5489
+ "secret",
5490
+ "select"
5491
+ ]),
5492
+ message: z.string(),
5493
+ placeholder: z.string().optional(),
5494
+ options: z.array(z.object({
5495
+ id: z.string(),
5496
+ label: z.string(),
5497
+ description: z.string().optional()
5498
+ }).strict()).optional()
5499
+ }).strict().nullable(),
5500
+ error: z.string().nullable()
5501
+ }).strict().nullable()
3675
5502
  }).strict();
3676
5503
  const LlmProviderSettingsSchema = z.object({
3677
5504
  writable: z.boolean(),
@@ -3724,6 +5551,8 @@ const defineContract = (contract) => ({
3724
5551
  parseError: (input) => contract.error.parse(input)
3725
5552
  });
3726
5553
  const agentParam = z.object({ agentId: AgentIdSchema }).strict();
5554
+ const credentialParam = z.object({ credentialId: CredentialIdSchema }).strict();
5555
+ const linkedAccountParam = z.object({ accountId: LinkedAccountIdSchema }).strict();
3727
5556
  const agentRevisionParam = z.object({
3728
5557
  agentId: AgentIdSchema,
3729
5558
  revisionId: AgentRevisionIdSchema
@@ -3734,7 +5563,11 @@ const AgentRevisionChangedFieldSchema = z.enum([
3734
5563
  "model",
3735
5564
  "capabilities",
3736
5565
  "imagePolicy",
3737
- "approvalPolicy"
5566
+ "approvalPolicy",
5567
+ "compaction",
5568
+ "subConversationModels",
5569
+ "fallbackModels",
5570
+ "aliases"
3738
5571
  ]);
3739
5572
  const AgentRevisionHistorySchema = z.object({
3740
5573
  agentId: AgentIdSchema,
@@ -3760,40 +5593,192 @@ const agentExtensionParam = z.object({
3760
5593
  extensionId: ExtensionIdSchema
3761
5594
  }).strict();
3762
5595
  const PermissionApprovalSchema = z.object({ permissionDigest: z.string().regex(/^[a-f0-9]{64}$/u) }).strict();
3763
- const extensionParam = z.object({ extensionId: ExtensionIdSchema }).strict();
3764
- const dshPluginPackageParam = z.object({ packageId: DshPluginPackageIdSchema }).strict();
3765
- const dshPluginEntryParam = z.object({ entryId: DshPluginEntryIdSchema }).strict();
3766
- const extensionRevisionParam = z.object({
5596
+ /** One version of one line in the lineage view of an extension family. */
5597
+ const ExtensionLineageNodeSchema = z.object({
5598
+ revisionId: ExtensionRevisionIdSchema,
3767
5599
  extensionId: ExtensionIdSchema,
3768
- revisionId: ExtensionRevisionIdSchema
3769
- }).strict();
3770
- const dshSettingsParam = z.object({ namespace: NonEmptyStringSchema }).strict();
3771
- const dshCredentialParam = z.object({ ref: DshCredentialRefSchema }).strict();
3772
- const llmProviderParam = z.object({ provider: NonEmptyStringSchema }).strict();
3773
- const authoringTaskParam = z.object({ taskId: AuthoringTaskIdSchema }).strict();
3774
- const scheduledTaskParam = z.object({ taskId: ScheduledTaskIdSchema }).strict();
3775
- const authoringAttemptParam = z.object({
3776
- taskId: AuthoringTaskIdSchema,
3777
- attemptId: AuthoringAttemptIdSchema
5600
+ label: z.string(),
5601
+ parentRevisionId: ExtensionRevisionIdSchema.optional(),
5602
+ origin: z.enum([
5603
+ "authored",
5604
+ "file",
5605
+ "community",
5606
+ "branch"
5607
+ ]),
5608
+ createdAt: z.number().int().nonnegative(),
5609
+ current: z.boolean(),
5610
+ releaseNumbers: z.array(z.number().int().positive())
3778
5611
  }).strict();
3779
- const DshPluginInstallInspectionSchema = z.object({
3780
- token: NonEmptyStringSchema,
3781
- operationId: z.string().uuid().optional(),
3782
- packageName: NonEmptyStringSchema,
3783
- packageVersion: NonEmptyStringSchema,
3784
- packageDigest: z.string().regex(/^[a-f0-9]{64}$/u),
3785
- lockfileDigest: z.string().regex(/^[a-f0-9]{64}$/u),
3786
- blockedBuilds: z.array(NonEmptyStringSchema),
3787
- clientUiDetected: z.boolean(),
3788
- hostUi: DshNxtHostUiSchema.optional(),
3789
- entries: z.array(z.object({
3790
- entryKey: NonEmptyStringSchema,
3791
- moduleName: NonEmptyStringSchema,
3792
- suggestedScope: z.enum(["host", "agent"])
3793
- }).strict())
5612
+ /** Every line of the family an extension belongs to: the original and every branch of a branch on this machine. */
5613
+ const ExtensionLineageSchema = z.object({ lines: z.array(z.object({
5614
+ extensionId: ExtensionIdSchema,
5615
+ displayName: z.string(),
5616
+ branchOf: z.object({
5617
+ extensionId: ExtensionIdSchema,
5618
+ revisionId: ExtensionRevisionIdSchema
5619
+ }).strict().optional(),
5620
+ nodes: z.array(ExtensionLineageNodeSchema)
5621
+ }).strict()) }).strict();
5622
+ const DataChangeCountSchema = z.object({
5623
+ added: z.number().int().nonnegative(),
5624
+ overwritten: z.number().int().nonnegative(),
5625
+ removed: z.number().int().nonnegative(),
5626
+ unchanged: z.number().int().nonnegative()
3794
5627
  }).strict();
3795
- const BinaryUploadRequestSchema = z.object({
3796
- bytes: z.instanceof(Uint8Array),
5628
+ /** Where a data migration takes data from. */
5629
+ const ExtensionDataSourceSchema = z.discriminatedUnion("kind", [
5630
+ z.object({
5631
+ kind: z.literal("extension"),
5632
+ extensionId: ExtensionIdSchema
5633
+ }).strict(),
5634
+ z.object({
5635
+ kind: z.literal("snapshot"),
5636
+ snapshotId: z.string().min(1).max(80)
5637
+ }).strict(),
5638
+ z.object({
5639
+ kind: z.literal("package"),
5640
+ token: z.string().min(1).max(80)
5641
+ }).strict()
5642
+ ]);
5643
+ const ExtensionDataMigrationInputSchema = z.object({
5644
+ source: ExtensionDataSourceSchema,
5645
+ mode: z.enum(["overwrite", "replace"]),
5646
+ /** Storage of a source agent goes to the mapped agent here; unmapped agents are skipped. */
5647
+ agentMap: z.record(z.string(), AgentIdSchema).optional(),
5648
+ /** Also move the host and agent configuration (never credentials) the same way. */
5649
+ includeConfig: z.boolean().optional()
5650
+ }).strict();
5651
+ const ExtensionDataPreviewSchema = z.object({
5652
+ diff: z.object({
5653
+ storage: DataChangeCountSchema,
5654
+ index: DataChangeCountSchema,
5655
+ library: DataChangeCountSchema
5656
+ }).strict(),
5657
+ destructive: z.boolean(),
5658
+ sourceDataVersion: z.number().int().positive(),
5659
+ targetDataVersion: z.number().int().positive(),
5660
+ needsMigration: z.boolean(),
5661
+ /** Configuration fields that would change, when configuration moves too. */
5662
+ config: z.object({
5663
+ hostFields: z.array(z.string()),
5664
+ agents: z.array(z.object({
5665
+ agentId: AgentIdSchema,
5666
+ fields: z.array(z.string())
5667
+ }).strict())
5668
+ }).strict().optional()
5669
+ }).strict();
5670
+ const ExtensionDataStateSchema = z.object({
5671
+ dataVersion: z.number().int().positive(),
5672
+ counts: z.object({
5673
+ storage: z.number().int().nonnegative(),
5674
+ index: z.number().int().nonnegative(),
5675
+ library: z.number().int().nonnegative()
5676
+ }).strict(),
5677
+ snapshots: z.array(z.object({
5678
+ id: z.string(),
5679
+ reason: z.enum([
5680
+ "switch",
5681
+ "migration",
5682
+ "manual"
5683
+ ]),
5684
+ label: z.string(),
5685
+ dataVersion: z.number().int().positive(),
5686
+ byteSize: z.number().int().nonnegative(),
5687
+ createdAt: z.number().int().nonnegative()
5688
+ }).strict())
5689
+ }).strict();
5690
+ const ExtensionDataPackageInspectionSchema = z.object({
5691
+ token: z.string(),
5692
+ extensionId: z.string(),
5693
+ displayName: z.string(),
5694
+ dataVersion: z.number().int().positive(),
5695
+ exportedAt: z.number().int().nonnegative(),
5696
+ agents: z.array(z.object({
5697
+ id: z.string(),
5698
+ name: z.string()
5699
+ }).strict()),
5700
+ counts: z.object({
5701
+ storage: z.number().int().nonnegative(),
5702
+ index: z.number().int().nonnegative(),
5703
+ library: z.number().int().nonnegative()
5704
+ }).strict()
5705
+ }).strict();
5706
+ const AdministratorSchema = z.object({
5707
+ connectionId: ConnectionIdSchema,
5708
+ connectionName: z.string(),
5709
+ platformUserId: z.string(),
5710
+ identityId: PlatformIdentityIdSchema.optional(),
5711
+ displayName: z.string(),
5712
+ addedVia: z.enum(["console", "claim"]),
5713
+ addedAt: z.number().int().nonnegative()
5714
+ }).strict();
5715
+ const extensionParam = z.object({ extensionId: ExtensionIdSchema }).strict();
5716
+ const ExtensionConfigVersionSourceSchema = z.enum([
5717
+ "console",
5718
+ "agent",
5719
+ "chat-admin",
5720
+ "revert",
5721
+ "auto-revert"
5722
+ ]);
5723
+ /**
5724
+ * One saved state of an extension's host configuration or of one agent's configuration. Versions are numbered per
5725
+ * extension, layer and agent; reverting writes an old one again as a new version. Secret fields only show whether
5726
+ * they were set and which named credential they were bound to.
5727
+ */
5728
+ const ExtensionConfigVersionSchema = z.object({
5729
+ id: z.number().int().positive(),
5730
+ extensionId: ExtensionIdSchema,
5731
+ layer: z.enum(["host", "agent"]),
5732
+ agentId: AgentIdSchema.nullable(),
5733
+ version: z.number().int().positive(),
5734
+ config: JsonValueSchema,
5735
+ configuredSecrets: z.array(z.string()).optional(),
5736
+ boundCredentials: z.record(z.string(), CredentialIdSchema).optional(),
5737
+ source: ExtensionConfigVersionSourceSchema,
5738
+ actorAgentId: AgentIdSchema.nullable(),
5739
+ requesterMemberId: z.string().nullable(),
5740
+ reason: z.string().nullable(),
5741
+ createdAt: z.number().int().nonnegative()
5742
+ }).strict();
5743
+ const extensionConfigVersionParam = z.object({
5744
+ extensionId: ExtensionIdSchema,
5745
+ /** Decimal text of the version id; the path builder only takes strings. */
5746
+ versionId: z.string().regex(/^[1-9]\d{0,15}$/u)
5747
+ }).strict();
5748
+ const dshPluginPackageParam = z.object({ packageId: DshPluginPackageIdSchema }).strict();
5749
+ const dshPluginEntryParam = z.object({ entryId: DshPluginEntryIdSchema }).strict();
5750
+ const extensionRevisionParam = z.object({
5751
+ extensionId: ExtensionIdSchema,
5752
+ revisionId: ExtensionRevisionIdSchema
5753
+ }).strict();
5754
+ const dshSettingsParam = z.object({ namespace: NonEmptyStringSchema }).strict();
5755
+ const dshCredentialParam = z.object({ ref: DshCredentialRefSchema }).strict();
5756
+ const llmProviderParam = z.object({ provider: NonEmptyStringSchema }).strict();
5757
+ const authoringTaskParam = z.object({ taskId: AuthoringTaskIdSchema }).strict();
5758
+ const subConversationParam = z.object({ conversationId: SubConversationIdSchema }).strict();
5759
+ const scheduledTaskParam = z.object({ taskId: ScheduledTaskIdSchema }).strict();
5760
+ const authoringAttemptParam = z.object({
5761
+ taskId: AuthoringTaskIdSchema,
5762
+ attemptId: AuthoringAttemptIdSchema
5763
+ }).strict();
5764
+ const DshPluginInstallInspectionSchema = z.object({
5765
+ token: NonEmptyStringSchema,
5766
+ operationId: z.string().uuid().optional(),
5767
+ packageName: NonEmptyStringSchema,
5768
+ packageVersion: NonEmptyStringSchema,
5769
+ packageDigest: z.string().regex(/^[a-f0-9]{64}$/u),
5770
+ lockfileDigest: z.string().regex(/^[a-f0-9]{64}$/u),
5771
+ blockedBuilds: z.array(NonEmptyStringSchema),
5772
+ clientUiDetected: z.boolean(),
5773
+ hostUi: DshNxtHostUiSchema.optional(),
5774
+ entries: z.array(z.object({
5775
+ entryKey: NonEmptyStringSchema,
5776
+ moduleName: NonEmptyStringSchema,
5777
+ suggestedScope: z.enum(["host", "agent"])
5778
+ }).strict())
5779
+ }).strict();
5780
+ const BinaryUploadRequestSchema = z.object({
5781
+ bytes: z.instanceof(Uint8Array),
3797
5782
  fileName: z.string().max(255).optional(),
3798
5783
  operationId: z.string().uuid().optional()
3799
5784
  }).strict();
@@ -3806,6 +5791,174 @@ const encodeBinaryUpload = (input) => ({
3806
5791
  }
3807
5792
  });
3808
5793
  const HostApiContracts = {
5794
+ listCommands: defineContract({
5795
+ method: "GET",
5796
+ path: "/api/commands",
5797
+ params: z.object({ channelId: ChannelIdSchema.optional() }).strict(),
5798
+ request: NoRequestBodySchema,
5799
+ response: z.object({
5800
+ commands: z.array(CommandCatalogEntrySchema),
5801
+ problems: z.array(z.string()),
5802
+ /** Host-wide behavior: whether platform members without a grant are told so. */
5803
+ settings: z.object({ unauthorizedFeedback: z.boolean() }).strict(),
5804
+ /** Present when a channel was requested. */
5805
+ channel: z.object({
5806
+ kind: z.enum([
5807
+ "internal",
5808
+ "direct",
5809
+ "group"
5810
+ ]),
5811
+ /** The channel is an external group where commands must address the account. */
5812
+ requiresMention: z.boolean(),
5813
+ bareCommands: z.boolean()
5814
+ }).strict().optional()
5815
+ }).strict(),
5816
+ error: HostApiErrorSchema
5817
+ }),
5818
+ executeCommand: defineContract({
5819
+ method: "POST",
5820
+ path: "/api/commands/execute",
5821
+ params: EmptyParamsSchema,
5822
+ request: z.object({
5823
+ channelId: ChannelIdSchema,
5824
+ text: z.string().min(1).max(16e3),
5825
+ requestId: z.string().min(1).max(200)
5826
+ }).strict(),
5827
+ response: CommandExecutionRecordSchema,
5828
+ error: HostApiErrorSchema,
5829
+ invalidatesSnapshot: true
5830
+ }),
5831
+ getCommandExecution: defineContract({
5832
+ method: "GET",
5833
+ path: "/api/commands/executions/:executionId",
5834
+ params: z.object({ executionId: z.string().min(1) }).strict(),
5835
+ request: NoRequestBodySchema,
5836
+ response: CommandExecutionRecordSchema,
5837
+ error: HostApiErrorSchema
5838
+ }),
5839
+ setCommandPolicy: defineContract({
5840
+ method: "PUT",
5841
+ path: "/api/commands/policy",
5842
+ params: EmptyParamsSchema,
5843
+ request: z.object({
5844
+ scope: z.union([z.literal("global"), ChannelIdSchema]),
5845
+ name: z.string().min(1),
5846
+ policy: CommandPolicySchema
5847
+ }).strict(),
5848
+ response: z.object({ saved: z.literal(true) }).strict(),
5849
+ error: HostApiErrorSchema,
5850
+ invalidatesSnapshot: true
5851
+ }),
5852
+ listCommandMembers: defineContract({
5853
+ method: "GET",
5854
+ path: "/api/commands/members/:channelId",
5855
+ params: z.object({ channelId: ChannelIdSchema }).strict(),
5856
+ request: NoRequestBodySchema,
5857
+ response: z.object({ members: z.array(z.object({
5858
+ identityId: PlatformIdentityIdSchema,
5859
+ displayName: z.string(),
5860
+ platformUserId: z.string(),
5861
+ authorized: z.boolean()
5862
+ }).strict()) }).strict(),
5863
+ error: HostApiErrorSchema
5864
+ }),
5865
+ setCommandSettings: defineContract({
5866
+ method: "PUT",
5867
+ path: "/api/commands/settings",
5868
+ params: EmptyParamsSchema,
5869
+ request: z.object({ unauthorizedFeedback: z.boolean() }).strict(),
5870
+ response: z.object({ saved: z.literal(true) }).strict(),
5871
+ error: HostApiErrorSchema
5872
+ }),
5873
+ setCommandChannelSettings: defineContract({
5874
+ method: "PUT",
5875
+ path: "/api/commands/channel-settings",
5876
+ params: EmptyParamsSchema,
5877
+ request: z.object({
5878
+ channelId: ChannelIdSchema,
5879
+ bareCommands: z.boolean()
5880
+ }).strict(),
5881
+ response: z.object({ saved: z.literal(true) }).strict(),
5882
+ error: HostApiErrorSchema,
5883
+ invalidatesSnapshot: true
5884
+ }),
5885
+ setCommandGrant: defineContract({
5886
+ method: "PUT",
5887
+ path: "/api/commands/grants",
5888
+ params: EmptyParamsSchema,
5889
+ request: z.object({
5890
+ channelId: ChannelIdSchema,
5891
+ identityId: PlatformIdentityIdSchema,
5892
+ enabled: z.boolean()
5893
+ }).strict(),
5894
+ response: z.object({ saved: z.literal(true) }).strict(),
5895
+ error: HostApiErrorSchema,
5896
+ invalidatesSnapshot: true
5897
+ }),
5898
+ queryLogs: defineContract({
5899
+ method: "GET",
5900
+ path: "/api/logs",
5901
+ params: z.object({ query: z.string().max(32768).optional() }).strict(),
5902
+ request: NoRequestBodySchema,
5903
+ response: hostLogPageSchema,
5904
+ error: HostApiErrorSchema
5905
+ }),
5906
+ getLog: defineContract({
5907
+ method: "GET",
5908
+ path: "/api/logs/:id",
5909
+ params: z.object({ id: z.string().min(1).max(256) }).strict(),
5910
+ request: NoRequestBodySchema,
5911
+ response: z.object({ entry: hostLogEntrySchema }).strict(),
5912
+ error: HostApiErrorSchema
5913
+ }),
5914
+ logSources: defineContract({
5915
+ method: "GET",
5916
+ path: "/api/logs/sources",
5917
+ params: EmptyParamsSchema,
5918
+ request: NoRequestBodySchema,
5919
+ response: z.object({ sources: z.array(hostLogSourceSchema) }).strict(),
5920
+ error: HostApiErrorSchema
5921
+ }),
5922
+ logStatus: defineContract({
5923
+ method: "GET",
5924
+ path: "/api/logs/status",
5925
+ params: EmptyParamsSchema,
5926
+ request: NoRequestBodySchema,
5927
+ response: hostLogStatusSchema,
5928
+ error: HostApiErrorSchema
5929
+ }),
5930
+ logSettings: defineContract({
5931
+ method: "GET",
5932
+ path: "/api/logs/settings",
5933
+ params: EmptyParamsSchema,
5934
+ request: NoRequestBodySchema,
5935
+ response: hostLogSettingsSchema,
5936
+ error: HostApiErrorSchema
5937
+ }),
5938
+ updateLogSettings: defineContract({
5939
+ method: "PUT",
5940
+ path: "/api/logs/settings",
5941
+ params: EmptyParamsSchema,
5942
+ request: hostLogSettingsSchema,
5943
+ response: hostLogSettingsSchema,
5944
+ error: HostApiErrorSchema
5945
+ }),
5946
+ startLogDebug: defineContract({
5947
+ method: "POST",
5948
+ path: "/api/logs/debug",
5949
+ params: EmptyParamsSchema,
5950
+ request: hostLogDebugRequestSchema,
5951
+ response: z.object({ lease: hostLogDebugLeaseSchema }).strict(),
5952
+ error: HostApiErrorSchema
5953
+ }),
5954
+ stopLogDebug: defineContract({
5955
+ method: "DELETE",
5956
+ path: "/api/logs/debug/:id",
5957
+ params: z.object({ id: z.string().min(1).max(256) }).strict(),
5958
+ request: NoRequestBodySchema,
5959
+ response: z.object({ stopped: z.literal(true) }).strict(),
5960
+ error: HostApiErrorSchema
5961
+ }),
3809
5962
  retryRuntimeCompatibility: defineContract({
3810
5963
  method: "POST",
3811
5964
  path: "/api/runtime/compatibility/retry",
@@ -3834,13 +5987,25 @@ const HostApiContracts = {
3834
5987
  response: z.object({
3835
5988
  task: AuthoringTaskSummarySchema,
3836
5989
  attempts: z.array(AuthoringAttemptSummarySchema),
3837
- /** Secret fields of the latest candidate and which have a test value for this task's dynamic runs. */
3838
- testSecrets: z.object({
5990
+ /**
5991
+ * Test configuration of this task's dynamic runs: fields of the latest candidate the user can type, which
5992
+ * credentials are set, the user's values and the values the agent provided.
5993
+ */
5994
+ testConfig: z.object({
3839
5995
  fields: z.array(z.object({
3840
5996
  key: z.string(),
3841
- title: z.string()
5997
+ title: z.string(),
5998
+ kind: z.enum([
5999
+ "secret",
6000
+ "string",
6001
+ "number"
6002
+ ])
3842
6003
  }).strict()),
3843
- configured: z.array(z.string())
6004
+ configured: z.array(z.string()),
6005
+ values: z.record(z.string(), z.union([z.string(), z.number()])),
6006
+ agentValues: z.record(z.string(), JsonValueSchema),
6007
+ /** Secret fields bound to a named credential, by the user or else by the agent. */
6008
+ boundCredentials: BoundCredentialsSchema.optional()
3844
6009
  }).strict().optional(),
3845
6010
  events: z.array(z.object({
3846
6011
  sequence: z.number().int().positive(),
@@ -3887,12 +6052,22 @@ const HostApiContracts = {
3887
6052
  response: AuthoringTaskSummarySchema,
3888
6053
  error: HostApiErrorSchema
3889
6054
  }),
3890
- setAuthoringTestSecrets: defineContract({
6055
+ setAuthoringTestConfig: defineContract({
3891
6056
  method: "PUT",
3892
6057
  path: "/api/authoring/tasks/:taskId/test-secrets",
3893
6058
  params: authoringTaskParam,
3894
- request: z.object({ secrets: z.record(z.string(), z.string().max(8192)) }).strict(),
3895
- response: z.object({ configured: z.array(z.string()) }).strict(),
6059
+ request: z.object({
6060
+ secrets: z.record(z.string(), z.string().max(8192)),
6061
+ /** Text and number values; an empty string goes back to the agent's value or the default. */
6062
+ values: z.record(z.string(), z.union([z.string().max(8192), z.number()])).optional(),
6063
+ /** Secret fields to bind to named credentials instead of a typed value; `null` leaves the field unset. */
6064
+ credentialBindings: CredentialBindingsRequestSchema.optional()
6065
+ }).strict(),
6066
+ response: z.object({
6067
+ configured: z.array(z.string()),
6068
+ values: z.record(z.string(), z.union([z.string(), z.number()])),
6069
+ boundCredentials: BoundCredentialsSchema.optional()
6070
+ }).strict(),
3896
6071
  error: HostApiErrorSchema
3897
6072
  }),
3898
6073
  deleteAuthoringTask: defineContract({
@@ -4097,15 +6272,19 @@ const HostApiContracts = {
4097
6272
  processingFeedback: z.enum(["auto", "off"]).optional(),
4098
6273
  /** Messages from another local agent's account: `observe` keeps them as context unless they @ this agent. */
4099
6274
  localAgentMessages: z.enum(["observe", "trigger"]).optional(),
4100
- activityTriggerOverrides: ActivityTriggerOverridesSchema.optional()
6275
+ activityTriggerOverrides: ActivityTriggerOverridesSchema.optional(),
6276
+ /** Omitted keeps the binding's current timing; `{}` resets every field to its default. */
6277
+ responseTiming: ResponseTimingSettingsSchema.optional()
4101
6278
  }).strict(),
4102
6279
  response: z.object({
4103
6280
  channelId: ChannelIdSchema,
4104
6281
  agentId: AgentIdSchema,
4105
6282
  triggerPolicy: TriggerPolicySchema,
6283
+ paused: z.boolean().default(false),
4106
6284
  processingFeedback: z.enum(["auto", "off"]).default("auto"),
4107
6285
  localAgentMessages: z.enum(["observe", "trigger"]).optional(),
4108
6286
  activityTriggerOverrides: ActivityTriggerOverridesSchema.default({}),
6287
+ responseTiming: ResponseTimingSettingsSchema.optional(),
4109
6288
  boundAt: z.number().int().safe().nonnegative()
4110
6289
  }).strict(),
4111
6290
  error: HostApiErrorSchema
@@ -4131,6 +6310,23 @@ const HostApiContracts = {
4131
6310
  response: WorkTreeOrderSchema,
4132
6311
  error: HostApiErrorSchema
4133
6312
  }),
6313
+ getChannelListView: defineContract({
6314
+ method: "GET",
6315
+ path: "/api/channel-list-view",
6316
+ params: EmptyParamsSchema,
6317
+ request: NoRequestBodySchema,
6318
+ response: ChannelListViewSchema,
6319
+ error: HostApiErrorSchema
6320
+ }),
6321
+ updateChannelListView: defineContract({
6322
+ invalidatesSnapshot: true,
6323
+ method: "PUT",
6324
+ path: "/api/channel-list-view",
6325
+ params: EmptyParamsSchema,
6326
+ request: ChannelListViewSchema,
6327
+ response: ChannelListViewSchema,
6328
+ error: HostApiErrorSchema
6329
+ }),
4134
6330
  listChannelMessages: defineContract({
4135
6331
  method: "GET",
4136
6332
  path: "/api/channels/:channelId/messages",
@@ -4160,12 +6356,48 @@ const HostApiContracts = {
4160
6356
  }).strict(),
4161
6357
  error: HostApiErrorSchema
4162
6358
  }),
6359
+ uploadChannelAsset: defineContract({
6360
+ method: "POST",
6361
+ path: "/api/channels/:channelId/assets",
6362
+ params: channelParam,
6363
+ request: BinaryUploadRequestSchema,
6364
+ encodeRequest: (input) => ({
6365
+ body: input.bytes,
6366
+ headers: {
6367
+ "content-type": "application/octet-stream",
6368
+ "x-file-name": encodeURIComponent(input.fileName ?? "附件")
6369
+ }
6370
+ }),
6371
+ response: z.object({
6372
+ assetId: AssetIdSchema,
6373
+ mediaType: z.string().min(1),
6374
+ byteSize: z.number().int().nonnegative(),
6375
+ fileName: z.string().min(1).max(255),
6376
+ partType: z.enum(["image", "file"])
6377
+ }).strict(),
6378
+ error: HostApiErrorSchema
6379
+ }),
6380
+ deleteChannelAsset: defineContract({
6381
+ method: "DELETE",
6382
+ path: "/api/channels/:channelId/assets/:assetId",
6383
+ params: z.object({
6384
+ channelId: ChannelIdSchema,
6385
+ assetId: AssetIdSchema
6386
+ }).strict(),
6387
+ request: NoRequestBodySchema,
6388
+ response: z.object({
6389
+ assetId: AssetIdSchema,
6390
+ revoked: z.literal(true)
6391
+ }).strict(),
6392
+ error: HostApiErrorSchema
6393
+ }),
4163
6394
  renameChannel: defineContract({
4164
6395
  invalidatesSnapshot: true,
4165
6396
  method: "POST",
4166
6397
  path: "/api/channels/:channelId/display-name",
4167
6398
  params: channelParam,
4168
- request: z.object({ displayName: z.string().trim().min(1).max(120) }).strict(),
6399
+ /** Empty selects the known platform name for an external channel. */
6400
+ request: z.object({ displayName: z.string().trim().max(120) }).strict(),
4169
6401
  response: z.object({
4170
6402
  channelId: ChannelIdSchema,
4171
6403
  displayName: z.string().trim().min(1).max(120)
@@ -4207,6 +6439,59 @@ const HostApiContracts = {
4207
6439
  response: ChannelRuntimeContextSchema,
4208
6440
  error: HostApiErrorSchema
4209
6441
  }),
6442
+ listSubConversations: defineContract({
6443
+ method: "GET",
6444
+ path: "/api/sub-conversations/channels/:channelId",
6445
+ params: channelParam,
6446
+ request: NoRequestBodySchema,
6447
+ response: z.object({ items: z.array(SubConversationSchema) }).strict(),
6448
+ error: HostApiErrorSchema
6449
+ }),
6450
+ getSubConversationRuntime: defineContract({
6451
+ method: "GET",
6452
+ path: "/api/sub-conversations/:conversationId/runtime",
6453
+ params: subConversationParam,
6454
+ request: NoRequestBodySchema,
6455
+ response: z.object({
6456
+ conversation: SubConversationSchema,
6457
+ runtime: ChannelRuntimeProjectionSchema
6458
+ }).strict(),
6459
+ error: HostApiErrorSchema
6460
+ }),
6461
+ closeSubConversation: defineContract({
6462
+ invalidatesSnapshot: true,
6463
+ method: "POST",
6464
+ path: "/api/sub-conversations/:conversationId/close",
6465
+ params: subConversationParam,
6466
+ request: z.object({}).strict(),
6467
+ response: SubConversationSchema,
6468
+ error: HostApiErrorSchema
6469
+ }),
6470
+ deleteSubConversation: defineContract({
6471
+ invalidatesSnapshot: true,
6472
+ method: "DELETE",
6473
+ path: "/api/sub-conversations/:conversationId",
6474
+ params: subConversationParam,
6475
+ request: NoRequestBodySchema,
6476
+ response: z.object({ deleted: z.literal(true) }).strict(),
6477
+ error: HostApiErrorSchema
6478
+ }),
6479
+ getSubConversationSettings: defineContract({
6480
+ method: "GET",
6481
+ path: "/api/settings/sub-conversations",
6482
+ params: EmptyParamsSchema,
6483
+ request: NoRequestBodySchema,
6484
+ response: SubConversationSettingsSchema,
6485
+ error: HostApiErrorSchema
6486
+ }),
6487
+ updateSubConversationSettings: defineContract({
6488
+ method: "PUT",
6489
+ path: "/api/settings/sub-conversations",
6490
+ params: EmptyParamsSchema,
6491
+ request: SubConversationSettingsSchema,
6492
+ response: SubConversationSettingsSchema,
6493
+ error: HostApiErrorSchema
6494
+ }),
4210
6495
  getChannelRuntimeInput: defineContract({
4211
6496
  method: "GET",
4212
6497
  path: "/api/channels/:channelId/runtime/inputs/:messageId",
@@ -4287,6 +6572,58 @@ const HostApiContracts = {
4287
6572
  response: MessagePacingSettingsSchema,
4288
6573
  error: HostApiErrorSchema
4289
6574
  }),
6575
+ getCompactionSettings: defineContract({
6576
+ method: "GET",
6577
+ path: "/api/settings/compaction",
6578
+ params: EmptyParamsSchema,
6579
+ request: NoRequestBodySchema,
6580
+ response: CompactionSettingsSchema,
6581
+ error: HostApiErrorSchema
6582
+ }),
6583
+ updateCompactionSettings: defineContract({
6584
+ invalidatesSnapshot: true,
6585
+ method: "PUT",
6586
+ path: "/api/settings/compaction",
6587
+ params: EmptyParamsSchema,
6588
+ request: CompactionSettingsSchema,
6589
+ response: CompactionSettingsSchema,
6590
+ error: HostApiErrorSchema
6591
+ }),
6592
+ getModelFallbackSettings: defineContract({
6593
+ method: "GET",
6594
+ path: "/api/settings/model-fallback",
6595
+ params: EmptyParamsSchema,
6596
+ request: NoRequestBodySchema,
6597
+ response: ModelFallbackSettingsSchema,
6598
+ error: HostApiErrorSchema
6599
+ }),
6600
+ updateModelFallbackSettings: defineContract({
6601
+ method: "PUT",
6602
+ path: "/api/settings/model-fallback",
6603
+ params: EmptyParamsSchema,
6604
+ request: ModelFallbackSettingsSchema,
6605
+ response: ModelFallbackSettingsSchema,
6606
+ error: HostApiErrorSchema
6607
+ }),
6608
+ getUpgradeBackupSettings: defineContract({
6609
+ method: "GET",
6610
+ path: "/api/settings/upgrade-backup",
6611
+ params: EmptyParamsSchema,
6612
+ request: NoRequestBodySchema,
6613
+ response: UpgradeBackupSettingsSchema,
6614
+ error: HostApiErrorSchema
6615
+ }),
6616
+ updateUpgradeBackupSettings: defineContract({
6617
+ method: "PUT",
6618
+ path: "/api/settings/upgrade-backup",
6619
+ params: EmptyParamsSchema,
6620
+ request: z.object({
6621
+ mode: UpgradeBackupModeSchema,
6622
+ directory: z.string().trim().min(1).max(1024).optional()
6623
+ }).strict(),
6624
+ response: UpgradeBackupSettingsSchema,
6625
+ error: HostApiErrorSchema
6626
+ }),
4290
6627
  getRetrievalStatus: defineContract({
4291
6628
  method: "GET",
4292
6629
  path: "/api/settings/retrieval",
@@ -4337,6 +6674,154 @@ const HostApiContracts = {
4337
6674
  response: CodeRunAvailabilitySchema,
4338
6675
  error: HostApiErrorSchema
4339
6676
  }),
6677
+ downloadGithubCli: defineContract({
6678
+ invalidatesSnapshot: true,
6679
+ method: "POST",
6680
+ path: "/api/runtimes/github-cli/download",
6681
+ params: EmptyParamsSchema,
6682
+ request: NoRequestBodySchema,
6683
+ response: GithubCliAvailabilitySchema,
6684
+ error: HostApiErrorSchema
6685
+ }),
6686
+ removeGithubCli: defineContract({
6687
+ invalidatesSnapshot: true,
6688
+ method: "DELETE",
6689
+ path: "/api/runtimes/github-cli",
6690
+ params: EmptyParamsSchema,
6691
+ request: NoRequestBodySchema,
6692
+ response: GithubCliAvailabilitySchema,
6693
+ error: HostApiErrorSchema
6694
+ }),
6695
+ downloadVerificationBrowser: defineContract({
6696
+ invalidatesSnapshot: true,
6697
+ method: "POST",
6698
+ path: "/api/runtimes/verification-browser/download",
6699
+ params: EmptyParamsSchema,
6700
+ request: NoRequestBodySchema,
6701
+ response: VerificationBrowserAvailabilitySchema,
6702
+ error: HostApiErrorSchema
6703
+ }),
6704
+ removeVerificationBrowser: defineContract({
6705
+ invalidatesSnapshot: true,
6706
+ method: "DELETE",
6707
+ path: "/api/runtimes/verification-browser",
6708
+ params: EmptyParamsSchema,
6709
+ request: NoRequestBodySchema,
6710
+ response: VerificationBrowserAvailabilitySchema,
6711
+ error: HostApiErrorSchema
6712
+ }),
6713
+ getLinkedAccounts: defineContract({
6714
+ method: "GET",
6715
+ path: "/api/settings/linked-accounts",
6716
+ params: EmptyParamsSchema,
6717
+ request: NoRequestBodySchema,
6718
+ response: LinkedAccountsViewSchema,
6719
+ error: HostApiErrorSchema
6720
+ }),
6721
+ addLinkedAccount: defineContract({
6722
+ invalidatesSnapshot: true,
6723
+ method: "POST",
6724
+ path: "/api/settings/linked-accounts",
6725
+ params: EmptyParamsSchema,
6726
+ request: AddLinkedAccountRequestSchema,
6727
+ response: LinkedAccountsViewSchema,
6728
+ error: HostApiErrorSchema
6729
+ }),
6730
+ replaceLinkedAccountToken: defineContract({
6731
+ invalidatesSnapshot: true,
6732
+ method: "PUT",
6733
+ path: "/api/settings/linked-accounts/:accountId/token",
6734
+ params: linkedAccountParam,
6735
+ request: ReplaceLinkedAccountTokenRequestSchema,
6736
+ response: LinkedAccountsViewSchema,
6737
+ error: HostApiErrorSchema
6738
+ }),
6739
+ removeLinkedAccount: defineContract({
6740
+ invalidatesSnapshot: true,
6741
+ method: "POST",
6742
+ path: "/api/settings/linked-accounts/:accountId/remove",
6743
+ params: linkedAccountParam,
6744
+ request: RemoveLinkedAccountRequestSchema,
6745
+ response: RemoveLinkedAccountResultSchema,
6746
+ error: HostApiErrorSchema
6747
+ }),
6748
+ getLinkedAccountUses: defineContract({
6749
+ method: "GET",
6750
+ path: "/api/settings/linked-accounts/:accountId/uses",
6751
+ params: linkedAccountParam,
6752
+ request: NoRequestBodySchema,
6753
+ response: LinkedAccountUsesViewSchema,
6754
+ error: HostApiErrorSchema
6755
+ }),
6756
+ getCredentials: defineContract({
6757
+ method: "GET",
6758
+ path: "/api/settings/credentials",
6759
+ params: EmptyParamsSchema,
6760
+ request: NoRequestBodySchema,
6761
+ response: CredentialsViewSchema,
6762
+ error: HostApiErrorSchema
6763
+ }),
6764
+ createCredential: defineContract({
6765
+ invalidatesSnapshot: true,
6766
+ method: "POST",
6767
+ path: "/api/settings/credentials",
6768
+ params: EmptyParamsSchema,
6769
+ request: CreateCredentialRequestSchema,
6770
+ response: CredentialsViewSchema,
6771
+ error: HostApiErrorSchema
6772
+ }),
6773
+ updateCredential: defineContract({
6774
+ invalidatesSnapshot: true,
6775
+ method: "PATCH",
6776
+ path: "/api/settings/credentials/:credentialId",
6777
+ params: credentialParam,
6778
+ request: UpdateCredentialRequestSchema,
6779
+ response: CredentialsViewSchema,
6780
+ error: HostApiErrorSchema
6781
+ }),
6782
+ replaceCredentialValue: defineContract({
6783
+ invalidatesSnapshot: true,
6784
+ method: "PUT",
6785
+ path: "/api/settings/credentials/:credentialId/value",
6786
+ params: credentialParam,
6787
+ request: ReplaceCredentialValueRequestSchema,
6788
+ response: CredentialsViewSchema,
6789
+ error: HostApiErrorSchema
6790
+ }),
6791
+ removeCredential: defineContract({
6792
+ invalidatesSnapshot: true,
6793
+ method: "POST",
6794
+ path: "/api/settings/credentials/:credentialId/remove",
6795
+ params: credentialParam,
6796
+ request: RemoveCredentialRequestSchema,
6797
+ response: RemoveCredentialResultSchema,
6798
+ error: HostApiErrorSchema
6799
+ }),
6800
+ getCredentialUses: defineContract({
6801
+ method: "GET",
6802
+ path: "/api/settings/credentials/:credentialId/uses",
6803
+ params: credentialParam,
6804
+ request: NoRequestBodySchema,
6805
+ response: CredentialUsesViewSchema,
6806
+ error: HostApiErrorSchema
6807
+ }),
6808
+ dismissCredentialRequest: defineContract({
6809
+ method: "DELETE",
6810
+ path: "/api/settings/credentials/requests/:requestId",
6811
+ params: z.object({ requestId: NonEmptyStringSchema.max(64) }).strict(),
6812
+ request: NoRequestBodySchema,
6813
+ response: CredentialsViewSchema,
6814
+ error: HostApiErrorSchema
6815
+ }),
6816
+ setModelProviderAccess: defineContract({
6817
+ invalidatesSnapshot: true,
6818
+ method: "PUT",
6819
+ path: "/api/settings/credentials/model-providers/:provider",
6820
+ params: z.object({ provider: NonEmptyStringSchema.max(128) }).strict(),
6821
+ request: SetModelProviderAccessRequestSchema,
6822
+ response: CredentialsViewSchema,
6823
+ error: HostApiErrorSchema
6824
+ }),
4340
6825
  getChannelMemberNotes: defineContract({
4341
6826
  method: "GET",
4342
6827
  path: "/api/channels/:channelId/member-notes",
@@ -4494,11 +6979,15 @@ const HostApiContracts = {
4494
6979
  method: "POST",
4495
6980
  path: "/api/connections/:connectionId/configuration",
4496
6981
  params: connectionParam,
4497
- request: z.object({ configuration: z.record(z.string(), z.union([
4498
- z.string(),
4499
- z.number(),
4500
- z.boolean()
4501
- ])) }).strict(),
6982
+ request: z.object({
6983
+ configuration: z.record(z.string(), z.union([
6984
+ z.string(),
6985
+ z.number(),
6986
+ z.boolean()
6987
+ ])),
6988
+ /** Omitted keys keep their value; null explicitly clears an optional credential. */
6989
+ credentials: z.record(z.string().min(1), z.string().min(1).max(16384).nullable()).optional()
6990
+ }).strict(),
4502
6991
  response: z.object({
4503
6992
  connectionId: ConnectionIdSchema,
4504
6993
  configuration: z.record(z.string(), z.union([
@@ -4654,36 +7143,172 @@ const HostApiContracts = {
4654
7143
  */
4655
7144
  listManagementDevices: defineContract({
4656
7145
  method: "GET",
4657
- path: "/api/management/devices",
4658
- params: EmptyParamsSchema,
7146
+ path: "/api/management/devices",
7147
+ params: EmptyParamsSchema,
7148
+ request: NoRequestBodySchema,
7149
+ response: z.object({ devices: z.array(ManagementDeviceViewSchema) }).strict(),
7150
+ error: HostApiErrorSchema
7151
+ }),
7152
+ revokeManagementDevice: defineContract({
7153
+ method: "DELETE",
7154
+ path: "/api/management/devices/:deviceId",
7155
+ params: z.object({ deviceId: ManagementDeviceIdSchema }).strict(),
7156
+ request: NoRequestBodySchema,
7157
+ response: z.object({ revoked: z.boolean() }).strict(),
7158
+ error: HostApiErrorSchema
7159
+ }),
7160
+ managementLogout: defineContract({
7161
+ method: "DELETE",
7162
+ path: "/api/management/session",
7163
+ params: EmptyParamsSchema,
7164
+ request: NoRequestBodySchema,
7165
+ response: z.object({ authenticated: z.literal(false) }).strict(),
7166
+ error: HostApiErrorSchema
7167
+ }),
7168
+ getCommunityStatus: defineContract({
7169
+ method: "GET",
7170
+ path: "/api/community/status",
7171
+ params: EmptyParamsSchema,
7172
+ request: NoRequestBodySchema,
7173
+ response: CommunityStatusSchema,
7174
+ error: HostApiErrorSchema
7175
+ }),
7176
+ getCommunityFeedbackSettings: defineContract({
7177
+ method: "GET",
7178
+ path: "/api/community/feedback/settings",
7179
+ params: EmptyParamsSchema,
7180
+ request: NoRequestBodySchema,
7181
+ response: CommunityFeedbackSettingsSchema,
7182
+ error: HostApiErrorSchema
7183
+ }),
7184
+ updateCommunityFeedbackSettings: defineContract({
7185
+ method: "PUT",
7186
+ path: "/api/community/feedback/settings",
7187
+ params: EmptyParamsSchema,
7188
+ request: CommunityFeedbackSettingsUpdateSchema,
7189
+ response: CommunityFeedbackSettingsSchema,
7190
+ error: HostApiErrorSchema,
7191
+ invalidatesSnapshot: true
7192
+ }),
7193
+ listCommunityFeedback: defineContract({
7194
+ timeoutMs: 6e4,
7195
+ method: "GET",
7196
+ path: "/api/community/feedback",
7197
+ params: z.object({ refresh: z.literal("1").optional() }).strict(),
4659
7198
  request: NoRequestBodySchema,
4660
- response: z.object({ devices: z.array(ManagementDeviceViewSchema) }).strict(),
7199
+ response: CommunityFeedbackLocalListSchema,
4661
7200
  error: HostApiErrorSchema
4662
7201
  }),
4663
- revokeManagementDevice: defineContract({
4664
- method: "DELETE",
4665
- path: "/api/management/devices/:deviceId",
4666
- params: z.object({ deviceId: ManagementDeviceIdSchema }).strict(),
7202
+ getCommunityFeedback: defineContract({
7203
+ timeoutMs: 6e4,
7204
+ method: "GET",
7205
+ path: "/api/community/feedback/items/:ref",
7206
+ params: z.object({ ref: CommunityFeedbackRefSchema }).strict(),
4667
7207
  request: NoRequestBodySchema,
4668
- response: z.object({ revoked: z.boolean() }).strict(),
7208
+ response: CommunityFeedbackSchema,
4669
7209
  error: HostApiErrorSchema
4670
7210
  }),
4671
- managementLogout: defineContract({
4672
- method: "DELETE",
4673
- path: "/api/management/session",
7211
+ createCommunityFeedbackDraft: defineContract({
7212
+ method: "POST",
7213
+ path: "/api/community/feedback/drafts",
4674
7214
  params: EmptyParamsSchema,
7215
+ request: CommunityFeedbackDraftInputSchema,
7216
+ response: CommunityFeedbackDraftSchema,
7217
+ error: HostApiErrorSchema,
7218
+ invalidatesSnapshot: true
7219
+ }),
7220
+ updateCommunityFeedbackDraft: defineContract({
7221
+ method: "PUT",
7222
+ path: "/api/community/feedback/drafts/:draftId",
7223
+ params: z.object({ draftId: CommunityFeedbackDraftIdSchema }).strict(),
7224
+ request: CommunityFeedbackDraftUpdateSchema,
7225
+ response: CommunityFeedbackDraftSchema,
7226
+ error: HostApiErrorSchema,
7227
+ invalidatesSnapshot: true
7228
+ }),
7229
+ sendCommunityFeedbackDraft: defineContract({
7230
+ timeoutMs: 6e4,
7231
+ method: "POST",
7232
+ path: "/api/community/feedback/drafts/:draftId/send",
7233
+ params: z.object({ draftId: CommunityFeedbackDraftIdSchema }).strict(),
7234
+ request: z.object({ consent: z.boolean().default(false) }).strict(),
7235
+ response: CommunityFeedbackDraftSchema,
7236
+ error: HostApiErrorSchema,
7237
+ invalidatesSnapshot: true
7238
+ }),
7239
+ discardCommunityFeedbackDraft: defineContract({
7240
+ method: "DELETE",
7241
+ path: "/api/community/feedback/drafts/:draftId",
7242
+ params: z.object({ draftId: CommunityFeedbackDraftIdSchema }).strict(),
4675
7243
  request: NoRequestBodySchema,
4676
- response: z.object({ authenticated: z.literal(false) }).strict(),
7244
+ response: CommunityFeedbackDraftSchema,
7245
+ error: HostApiErrorSchema,
7246
+ invalidatesSnapshot: true
7247
+ }),
7248
+ previewCommunityFeedbackPayload: defineContract({
7249
+ method: "GET",
7250
+ path: "/api/community/feedback/drafts/:draftId/preview",
7251
+ params: z.object({ draftId: CommunityFeedbackDraftIdSchema }).strict(),
7252
+ request: NoRequestBodySchema,
7253
+ response: CommunityFeedbackPayloadSchema,
4677
7254
  error: HostApiErrorSchema
4678
7255
  }),
4679
- getCommunityStatus: defineContract({
7256
+ getLastSentCommunityFeedbackPayload: defineContract({
4680
7257
  method: "GET",
4681
- path: "/api/community/status",
7258
+ path: "/api/community/feedback/last-sent",
4682
7259
  params: EmptyParamsSchema,
4683
7260
  request: NoRequestBodySchema,
4684
- response: CommunityStatusSchema,
7261
+ response: CommunityFeedbackLastPayloadSchema,
4685
7262
  error: HostApiErrorSchema
4686
7263
  }),
7264
+ replyCommunityFeedback: defineContract({
7265
+ method: "POST",
7266
+ path: "/api/community/feedback/items/:ref/messages",
7267
+ params: z.object({ ref: CommunityFeedbackRefSchema }).strict(),
7268
+ request: z.object({ body: z.string().trim().min(1).max(4e3) }).strict(),
7269
+ response: CommunityFeedbackSchema,
7270
+ error: HostApiErrorSchema,
7271
+ invalidatesSnapshot: true
7272
+ }),
7273
+ withdrawCommunityFeedback: defineContract({
7274
+ method: "POST",
7275
+ path: "/api/community/feedback/items/:ref/withdraw",
7276
+ params: z.object({ ref: CommunityFeedbackRefSchema }).strict(),
7277
+ request: CommunityFeedbackWithdrawSchema,
7278
+ response: CommunityFeedbackSchema,
7279
+ error: HostApiErrorSchema,
7280
+ invalidatesSnapshot: true
7281
+ }),
7282
+ reopenCommunityFeedback: defineContract({
7283
+ method: "POST",
7284
+ path: "/api/community/feedback/items/:ref/reopen",
7285
+ params: z.object({ ref: CommunityFeedbackRefSchema }).strict(),
7286
+ request: CommunityFeedbackReopenSchema,
7287
+ response: CommunityFeedbackSchema,
7288
+ error: HostApiErrorSchema,
7289
+ invalidatesSnapshot: true
7290
+ }),
7291
+ markCommunityFeedbackAffected: defineContract({
7292
+ method: "POST",
7293
+ path: "/api/community/feedback/items/:ref/affected",
7294
+ params: z.object({ ref: CommunityFeedbackRefSchema }).strict(),
7295
+ request: z.object({
7296
+ affected: z.boolean().default(true),
7297
+ consent: z.boolean().default(false)
7298
+ }).strict(),
7299
+ response: CommunityFeedbackSchema,
7300
+ error: HostApiErrorSchema,
7301
+ invalidatesSnapshot: true
7302
+ }),
7303
+ confirmCommunityFeedbackFixed: defineContract({
7304
+ method: "POST",
7305
+ path: "/api/community/feedback/items/:ref/confirm-fixed",
7306
+ params: z.object({ ref: CommunityFeedbackRefSchema }).strict(),
7307
+ request: z.object({}).strict(),
7308
+ response: CommunityFeedbackSchema,
7309
+ error: HostApiErrorSchema,
7310
+ invalidatesSnapshot: true
7311
+ }),
4687
7312
  startCommunityLogin: defineContract({
4688
7313
  method: "POST",
4689
7314
  path: "/api/community/login",
@@ -4712,22 +7337,27 @@ const HostApiContracts = {
4712
7337
  official: z.enum(["1"]).optional(),
4713
7338
  /** 排序方式,默认最近更新;游标只在同一种排序下有效。 */
4714
7339
  sort: CommunityExtensionSortSchema.optional(),
4715
- cursor: z.string().max(200).optional()
7340
+ cursor: z.string().max(200).optional(),
7341
+ /** 跳过本机缓存,重新向社区读取。 */
7342
+ refresh: z.enum(["1"]).optional()
4716
7343
  }).strict(),
4717
7344
  request: NoRequestBodySchema,
4718
7345
  response: z.object({
4719
7346
  items: z.array(CommunityExtensionSummarySchema),
4720
7347
  nextCursor: z.string().nullable()
4721
- }).strict(),
7348
+ }).extend(CommunityFreshnessSchema.shape).strict(),
4722
7349
  error: HostApiErrorSchema
4723
7350
  }),
4724
7351
  getCommunityExtension: defineContract({
4725
7352
  timeoutMs: 3e4,
4726
7353
  method: "GET",
4727
7354
  path: "/api/community/extensions/:extensionId",
4728
- params: z.object({ extensionId: ExtensionIdSchema }).strict(),
7355
+ params: z.object({
7356
+ extensionId: ExtensionIdSchema,
7357
+ refresh: z.enum(["1"]).optional()
7358
+ }).strict(),
4729
7359
  request: NoRequestBodySchema,
4730
- response: CommunityExtensionDetailSchema,
7360
+ response: CommunityExtensionDetailSchema.extend(CommunityFreshnessSchema.shape),
4731
7361
  error: HostApiErrorSchema
4732
7362
  }),
4733
7363
  /** 下载社区发布并按包摘要校验,结果与本地文件导入的检查相同,再经 `commitExtensionImport` 确认。 */
@@ -4772,13 +7402,13 @@ const HostApiContracts = {
4772
7402
  }).strict(),
4773
7403
  error: HostApiErrorSchema
4774
7404
  }),
4775
- listCommunityInstalled: defineContract({
4776
- timeoutMs: 3e4,
7405
+ listCommunitySync: defineContract({
7406
+ timeoutMs: 6e4,
4777
7407
  method: "GET",
4778
- path: "/api/community/installed",
7408
+ path: "/api/community/sync",
4779
7409
  params: z.object({ refresh: z.enum(["1"]).optional() }).strict(),
4780
7410
  request: NoRequestBodySchema,
4781
- response: CommunityInstalledSchema,
7411
+ response: CommunitySyncSchema,
4782
7412
  error: HostApiErrorSchema
4783
7413
  }),
4784
7414
  listCommunityMine: defineContract({
@@ -4840,6 +7470,7 @@ const HostApiContracts = {
4840
7470
  }).strict(),
4841
7471
  response: z.object({
4842
7472
  releaseId: CommunityReleaseIdSchema,
7473
+ releaseNumber: z.number().int().positive(),
4843
7474
  reviewStatus: CommunityReviewStatusSchema,
4844
7475
  pageUrl: z.string().url(),
4845
7476
  reportUrl: z.string().url(),
@@ -4858,22 +7489,27 @@ const HostApiContracts = {
4858
7489
  query: z.string().trim().min(1).max(200).optional(),
4859
7490
  tag: z.string().trim().min(1).max(40).optional(),
4860
7491
  official: z.literal("1").optional(),
4861
- cursor: z.string().min(1).max(500).optional()
7492
+ cursor: z.string().min(1).max(500).optional(),
7493
+ /** 跳过本机缓存,重新向社区读取。 */
7494
+ refresh: z.enum(["1"]).optional()
4862
7495
  }).strict(),
4863
7496
  request: NoRequestBodySchema,
4864
7497
  response: z.object({
4865
7498
  items: z.array(CommunityPersonaSummarySchema),
4866
7499
  nextCursor: z.string().nullable()
4867
- }).strict(),
7500
+ }).extend(CommunityFreshnessSchema.shape).strict(),
4868
7501
  error: HostApiErrorSchema
4869
7502
  }),
4870
7503
  getCommunityPersona: defineContract({
4871
7504
  timeoutMs: 3e4,
4872
7505
  method: "GET",
4873
7506
  path: "/api/community/personas/:personaId",
4874
- params: z.object({ personaId: CommunityPersonaIdSchema }).strict(),
7507
+ params: z.object({
7508
+ personaId: CommunityPersonaIdSchema,
7509
+ refresh: z.enum(["1"]).optional()
7510
+ }).strict(),
4875
7511
  request: NoRequestBodySchema,
4876
- response: CommunityPersonaDetailSchema,
7512
+ response: CommunityPersonaDetailSchema.extend(CommunityFreshnessSchema.shape),
4877
7513
  error: HostApiErrorSchema
4878
7514
  }),
4879
7515
  /**
@@ -5050,6 +7686,46 @@ const HostApiContracts = {
5050
7686
  response: LlmProviderSettingsSchema,
5051
7687
  error: HostApiErrorSchema
5052
7688
  }),
7689
+ llmSubscriptionStatus: defineContract({
7690
+ method: "GET",
7691
+ path: "/api/llm/subscriptions/:provider",
7692
+ params: llmProviderParam,
7693
+ request: NoRequestBodySchema,
7694
+ response: SubscriptionStatusSchema,
7695
+ error: HostApiErrorSchema
7696
+ }),
7697
+ llmSubscriptionAction: defineContract({
7698
+ invalidatesSnapshot: true,
7699
+ method: "POST",
7700
+ path: "/api/llm/subscriptions/:provider",
7701
+ params: llmProviderParam,
7702
+ request: z.discriminatedUnion("action", [
7703
+ z.object({
7704
+ action: z.literal("use-subscription"),
7705
+ expectedRevision: z.number().int().nonnegative()
7706
+ }).strict(),
7707
+ z.object({ action: z.enum(["login", "cancel"]) }).strict(),
7708
+ z.object({
7709
+ action: z.literal("answer"),
7710
+ promptId: NonEmptyStringSchema,
7711
+ value: z.string().max(4096)
7712
+ }).strict(),
7713
+ z.object({
7714
+ action: z.enum(["activate", "remove"]),
7715
+ accountId: NonEmptyStringSchema
7716
+ }).strict(),
7717
+ z.object({
7718
+ action: z.literal("rename"),
7719
+ accountId: NonEmptyStringSchema,
7720
+ label: z.string().min(1).max(80)
7721
+ }).strict()
7722
+ ]),
7723
+ response: z.object({
7724
+ status: SubscriptionStatusSchema,
7725
+ revocationConfirmed: z.boolean().optional()
7726
+ }).strict(),
7727
+ error: HostApiErrorSchema
7728
+ }),
5053
7729
  llmDiscoverModels: defineContract({
5054
7730
  method: "POST",
5055
7731
  path: "/api/llm/discover-models",
@@ -5183,7 +7859,19 @@ const HostApiContracts = {
5183
7859
  request: z.object({
5184
7860
  episodeId: EpisodeIdSchema,
5185
7861
  requestId: DynamicIdSchema,
5186
- pluginRunId: DynamicIdSchema.optional()
7862
+ pluginRunId: DynamicIdSchema.optional(),
7863
+ /**
7864
+ * Why the run did not go ahead: the user declined it, or the page could not start one of its halves. A failed
7865
+ * half is settled as a failed attempt (its Host is retracted and the agent hears about it), not as a decline.
7866
+ */
7867
+ reason: z.enum([
7868
+ "rejected",
7869
+ "host-half-failed",
7870
+ "client-half-failed"
7871
+ ]).optional(),
7872
+ startedHere: z.boolean().optional(),
7873
+ message: z.string().max(4e3).optional(),
7874
+ stack: z.string().max(16e3).optional()
5187
7875
  }).strict(),
5188
7876
  response: z.object({ accepted: z.boolean() }).strict(),
5189
7877
  error: HostApiErrorSchema
@@ -5318,23 +8006,15 @@ const HostApiContracts = {
5318
8006
  method: "POST",
5319
8007
  path: "/api/extensions/save-from-dynamic",
5320
8008
  params: EmptyParamsSchema,
5321
- request: z.union([z.object({
8009
+ request: z.object({
5322
8010
  taskId: AuthoringTaskIdSchema,
8011
+ /** The candidate the user saw; saving refuses when a newer one appeared since. */
5323
8012
  attemptId: AuthoringAttemptIdSchema,
5324
8013
  displayName: z.string().trim().min(1).max(80),
5325
8014
  slug: z.string().trim().regex(/^[a-z0-9][a-z0-9-]{1,62}[a-z0-9]$/u),
5326
8015
  description: z.string().max(500).default(""),
5327
8016
  targetExtensionId: ExtensionIdSchema.optional()
5328
- }).strict(), z.object({
5329
- agentId: AgentIdSchema,
5330
- episodeId: EpisodeIdSchema,
5331
- pluginId: DynamicIdSchema,
5332
- packageId: DynamicIdSchema,
5333
- displayName: z.string().trim().min(1).max(80),
5334
- slug: z.string().trim().regex(/^[a-z0-9][a-z0-9-]{1,62}[a-z0-9]$/u),
5335
- description: z.string().max(500).default(""),
5336
- targetExtensionId: ExtensionIdSchema.optional()
5337
- }).strict()]),
8017
+ }).strict(),
5338
8018
  response: z.object({
5339
8019
  extensionId: ExtensionIdSchema,
5340
8020
  revisionId: ExtensionRevisionIdSchema,
@@ -5411,6 +8091,7 @@ const HostApiContracts = {
5411
8091
  extensionRevisionId: ExtensionRevisionIdSchema,
5412
8092
  config: JsonValueSchema,
5413
8093
  configuredSecrets: z.array(z.string()).optional(),
8094
+ boundCredentials: BoundCredentialsSchema.optional(),
5414
8095
  activatedAt: z.number().int().safe().nonnegative()
5415
8096
  }).strict().optional(),
5416
8097
  pending: ExtensionActivationTransitionSchema.optional()
@@ -5430,6 +8111,16 @@ const HostApiContracts = {
5430
8111
  }).strict(),
5431
8112
  error: HostApiErrorSchema
5432
8113
  }),
8114
+ putAgentOutboundOrder: defineContract({
8115
+ invalidatesSnapshot: true,
8116
+ method: "PUT",
8117
+ path: "/api/agents/:agentId/outbound-order",
8118
+ params: agentParam,
8119
+ /** Every enabled extension that processes the agent's messages before sending, in the new order. */
8120
+ request: z.object({ extensionIds: z.array(ExtensionIdSchema).max(64) }).strict(),
8121
+ response: z.object({ extensionIds: z.array(ExtensionIdSchema) }).strict(),
8122
+ error: HostApiErrorSchema
8123
+ }),
5433
8124
  updateExtensionActivationConfig: defineContract({
5434
8125
  invalidatesSnapshot: true,
5435
8126
  method: "PUT",
@@ -5438,11 +8129,14 @@ const HostApiContracts = {
5438
8129
  request: z.object({
5439
8130
  config: JsonValueSchema,
5440
8131
  /** Write-only credential drafts keyed by secret field; an absent or empty draft keeps the stored one. */
5441
- secrets: z.record(z.string(), z.string().max(8192)).optional()
8132
+ secrets: z.record(z.string(), z.string().max(8192)).optional(),
8133
+ /** Secret fields to bind to named credentials instead of a typed value; a field takes one or the other. */
8134
+ credentialBindings: CredentialBindingsRequestSchema.optional()
5442
8135
  }).strict(),
5443
8136
  response: z.object({
5444
8137
  config: JsonValueSchema,
5445
- configuredSecrets: z.array(z.string()).optional()
8138
+ configuredSecrets: z.array(z.string()).optional(),
8139
+ boundCredentials: BoundCredentialsSchema.optional()
5446
8140
  }).strict(),
5447
8141
  error: HostApiErrorSchema
5448
8142
  }),
@@ -5455,14 +8149,37 @@ const HostApiContracts = {
5455
8149
  request: z.object({
5456
8150
  config: JsonValueSchema,
5457
8151
  /** Write-only credential drafts keyed by secret field; an absent or empty draft keeps the stored one. */
5458
- secrets: z.record(z.string(), z.string().max(8192)).optional()
8152
+ secrets: z.record(z.string(), z.string().max(8192)).optional(),
8153
+ /** Secret fields to bind to named credentials instead of a typed value; a field takes one or the other. */
8154
+ credentialBindings: CredentialBindingsRequestSchema.optional()
5459
8155
  }).strict(),
5460
8156
  response: z.object({
5461
8157
  config: JsonValueSchema,
5462
- configuredSecrets: z.array(z.string()).optional()
8158
+ configuredSecrets: z.array(z.string()).optional(),
8159
+ boundCredentials: BoundCredentialsSchema.optional()
5463
8160
  }).strict(),
5464
8161
  error: HostApiErrorSchema
5465
8162
  }),
8163
+ /** Configuration history of one extension, newest first: the host layer and every agent's configuration. */
8164
+ getExtensionConfigVersions: defineContract({
8165
+ method: "GET",
8166
+ path: "/api/extensions/:extensionId/config-versions",
8167
+ params: extensionParam,
8168
+ request: NoRequestBodySchema,
8169
+ response: z.object({ versions: z.array(ExtensionConfigVersionSchema) }).strict(),
8170
+ error: HostApiErrorSchema
8171
+ }),
8172
+ /** Writes an earlier configuration again as a new version of the same layer (and agent). */
8173
+ revertExtensionConfig: defineContract({
8174
+ invalidatesSnapshot: true,
8175
+ timeoutMs: 3e5,
8176
+ method: "POST",
8177
+ path: "/api/extensions/:extensionId/config-versions/:versionId/revert",
8178
+ params: extensionConfigVersionParam,
8179
+ request: z.object({ reason: z.string().trim().max(500).optional() }).strict(),
8180
+ response: z.object({ version: ExtensionConfigVersionSchema }).strict(),
8181
+ error: HostApiErrorSchema
8182
+ }),
5466
8183
  installHostExtension: defineContract({
5467
8184
  invalidatesSnapshot: true,
5468
8185
  timeoutMs: 3e5,
@@ -5474,7 +8191,9 @@ const HostApiContracts = {
5474
8191
  /** Approval of the host layer (browser permissions and `permissions.host`). */
5475
8192
  permissionApproval: PermissionApprovalSchema.optional(),
5476
8193
  /** Approval of expanded agent-layer capabilities for the agents that move to this Revision. */
5477
- agentPermissionApproval: PermissionApprovalSchema.optional()
8194
+ agentPermissionApproval: PermissionApprovalSchema.optional(),
8195
+ /** Data copy to put back first, when the target Revision only reads an older data version. */
8196
+ restoreDataSnapshotId: z.string().min(1).max(80).optional()
5478
8197
  }).strict(),
5479
8198
  response: z.object({ installation: z.object({
5480
8199
  extensionId: ExtensionIdSchema,
@@ -5592,6 +8311,19 @@ upTo: z.object({
5592
8311
  }).strict(),
5593
8312
  error: HostApiErrorSchema
5594
8313
  }),
8314
+ setChannelPaused: defineContract({
8315
+ method: "POST",
8316
+ path: "/api/channels/:channelId/pause",
8317
+ params: channelParam,
8318
+ request: z.object({ paused: z.boolean() }).strict(),
8319
+ response: z.object({
8320
+ paused: z.boolean(),
8321
+ changed: z.boolean(),
8322
+ stopped: z.boolean()
8323
+ }).strict(),
8324
+ error: HostApiErrorSchema,
8325
+ invalidatesSnapshot: true
8326
+ }),
5595
8327
  resolveOutbound: defineContract({
5596
8328
  method: "POST",
5597
8329
  path: "/api/outbound/:outboundId/resolve",
@@ -5674,6 +8406,202 @@ upTo: z.object({
5674
8406
  request: NoRequestBodySchema,
5675
8407
  response: z.object({ deleted: z.literal(true) }).strict(),
5676
8408
  error: HostApiErrorSchema
8409
+ }),
8410
+ getExtensionLineage: defineContract({
8411
+ method: "GET",
8412
+ path: "/api/extensions/:extensionId/lineage",
8413
+ params: extensionParam,
8414
+ request: NoRequestBodySchema,
8415
+ response: ExtensionLineageSchema,
8416
+ error: HostApiErrorSchema
8417
+ }),
8418
+ branchExtension: defineContract({
8419
+ invalidatesSnapshot: true,
8420
+ timeoutMs: 3e5,
8421
+ method: "POST",
8422
+ path: "/api/extensions/:extensionId/branch",
8423
+ params: extensionParam,
8424
+ request: z.object({
8425
+ revisionId: ExtensionRevisionIdSchema,
8426
+ name: z.string().trim().min(1).max(80),
8427
+ slug: z.string().trim().regex(/^[a-z0-9][a-z0-9-]{1,62}[a-z0-9]$/u).optional(),
8428
+ copyData: z.boolean()
8429
+ }).strict(),
8430
+ response: z.object({
8431
+ extensionId: ExtensionIdSchema,
8432
+ revisionId: ExtensionRevisionIdSchema
8433
+ }).strict(),
8434
+ error: HostApiErrorSchema
8435
+ }),
8436
+ rollbackExtension: defineContract({
8437
+ invalidatesSnapshot: true,
8438
+ timeoutMs: 3e5,
8439
+ method: "POST",
8440
+ path: "/api/extensions/:extensionId/revert",
8441
+ params: extensionParam,
8442
+ request: NoRequestBodySchema,
8443
+ response: z.object({ message: z.string() }).strict(),
8444
+ error: HostApiErrorSchema
8445
+ }),
8446
+ getExtensionData: defineContract({
8447
+ method: "GET",
8448
+ path: "/api/extensions/:extensionId/data",
8449
+ params: extensionParam,
8450
+ request: NoRequestBodySchema,
8451
+ response: ExtensionDataStateSchema,
8452
+ error: HostApiErrorSchema
8453
+ }),
8454
+ previewExtensionDataMigration: defineContract({
8455
+ timeoutMs: 6e4,
8456
+ method: "POST",
8457
+ path: "/api/extensions/:extensionId/data/preview",
8458
+ params: extensionParam,
8459
+ request: ExtensionDataMigrationInputSchema,
8460
+ response: ExtensionDataPreviewSchema,
8461
+ error: HostApiErrorSchema
8462
+ }),
8463
+ migrateExtensionData: defineContract({
8464
+ invalidatesSnapshot: true,
8465
+ timeoutMs: 3e5,
8466
+ method: "POST",
8467
+ path: "/api/extensions/:extensionId/data/migrate",
8468
+ params: extensionParam,
8469
+ request: ExtensionDataMigrationInputSchema,
8470
+ response: z.object({
8471
+ snapshotId: z.string(),
8472
+ preview: ExtensionDataPreviewSchema
8473
+ }).strict(),
8474
+ error: HostApiErrorSchema
8475
+ }),
8476
+ exportExtensionData: defineContract({
8477
+ method: "GET",
8478
+ timeoutMs: 3e5,
8479
+ path: "/api/extensions/:extensionId/data/export",
8480
+ params: extensionParam,
8481
+ request: NoRequestBodySchema,
8482
+ responseFormat: "bytes",
8483
+ response: z.instanceof(Uint8Array),
8484
+ error: HostApiErrorSchema
8485
+ }),
8486
+ /** The same package with the host and agent configuration; secrets are left out. */
8487
+ exportExtensionDataWithConfig: defineContract({
8488
+ method: "GET",
8489
+ timeoutMs: 3e5,
8490
+ path: "/api/extensions/:extensionId/data/export-config",
8491
+ params: extensionParam,
8492
+ request: NoRequestBodySchema,
8493
+ responseFormat: "bytes",
8494
+ response: z.instanceof(Uint8Array),
8495
+ error: HostApiErrorSchema
8496
+ }),
8497
+ createExtensionDataSnapshot: defineContract({
8498
+ method: "POST",
8499
+ path: "/api/extensions/:extensionId/data/snapshots",
8500
+ params: extensionParam,
8501
+ request: z.object({ label: z.string().trim().min(1).max(80) }).strict(),
8502
+ response: z.object({ snapshotId: z.string() }).strict(),
8503
+ error: HostApiErrorSchema
8504
+ }),
8505
+ inspectExtensionDataPackage: defineContract({
8506
+ timeoutMs: 3e5,
8507
+ method: "POST",
8508
+ path: "/api/extensions/data/inspect",
8509
+ params: EmptyParamsSchema,
8510
+ request: BinaryUploadRequestSchema,
8511
+ encodeRequest: encodeBinaryUpload,
8512
+ response: ExtensionDataPackageInspectionSchema,
8513
+ error: HostApiErrorSchema
8514
+ }),
8515
+ listExtensionRequests: defineContract({
8516
+ method: "GET",
8517
+ path: "/api/extension-requests",
8518
+ params: EmptyParamsSchema,
8519
+ request: NoRequestBodySchema,
8520
+ response: z.object({ requests: z.array(ExtensionRequestSchema) }).strict(),
8521
+ error: HostApiErrorSchema
8522
+ }),
8523
+ approveExtensionRequest: defineContract({
8524
+ invalidatesSnapshot: true,
8525
+ timeoutMs: 3e5,
8526
+ method: "POST",
8527
+ path: "/api/extension-requests/:number/approve",
8528
+ params: z.object({ number: z.coerce.number().int().positive() }).strict(),
8529
+ request: NoRequestBodySchema,
8530
+ response: z.object({ message: z.string() }).strict(),
8531
+ error: HostApiErrorSchema
8532
+ }),
8533
+ rejectExtensionRequest: defineContract({
8534
+ method: "POST",
8535
+ path: "/api/extension-requests/:number/reject",
8536
+ params: z.object({ number: z.coerce.number().int().positive() }).strict(),
8537
+ request: z.object({ reason: z.string().trim().max(500).optional() }).strict(),
8538
+ response: z.object({ ok: z.literal(true) }).strict(),
8539
+ error: HostApiErrorSchema
8540
+ }),
8541
+ listAdministrators: defineContract({
8542
+ method: "GET",
8543
+ path: "/api/administrators",
8544
+ params: EmptyParamsSchema,
8545
+ request: NoRequestBodySchema,
8546
+ response: z.object({ administrators: z.array(AdministratorSchema) }).strict(),
8547
+ error: HostApiErrorSchema
8548
+ }),
8549
+ addAdministrator: defineContract({
8550
+ method: "POST",
8551
+ path: "/api/administrators",
8552
+ params: EmptyParamsSchema,
8553
+ request: z.object({ identityId: PlatformIdentityIdSchema }).strict(),
8554
+ response: AdministratorSchema,
8555
+ error: HostApiErrorSchema
8556
+ }),
8557
+ removeAdministrator: defineContract({
8558
+ method: "POST",
8559
+ path: "/api/administrators/remove",
8560
+ params: EmptyParamsSchema,
8561
+ request: z.object({
8562
+ connectionId: ConnectionIdSchema,
8563
+ platformUserId: z.string().min(1)
8564
+ }).strict(),
8565
+ response: z.object({ ok: z.literal(true) }).strict(),
8566
+ error: HostApiErrorSchema
8567
+ }),
8568
+ createAdministratorClaimCode: defineContract({
8569
+ method: "POST",
8570
+ path: "/api/administrators/claim-code",
8571
+ params: EmptyParamsSchema,
8572
+ request: NoRequestBodySchema,
8573
+ response: z.object({
8574
+ code: z.string(),
8575
+ expiresAt: z.number().int().nonnegative()
8576
+ }).strict(),
8577
+ error: HostApiErrorSchema
8578
+ }),
8579
+ dismissCommunityRelease: defineContract({
8580
+ method: "POST",
8581
+ path: "/api/community/sync/:extensionId/dismiss",
8582
+ params: extensionParam,
8583
+ request: z.object({ releaseId: CommunityReleaseIdSchema.nullable() }).strict(),
8584
+ response: z.object({ ok: z.literal(true) }).strict(),
8585
+ error: HostApiErrorSchema
8586
+ }),
8587
+ updateFromCommunity: defineContract({
8588
+ invalidatesSnapshot: true,
8589
+ timeoutMs: 3e5,
8590
+ method: "POST",
8591
+ path: "/api/community/sync/:extensionId/update",
8592
+ params: extensionParam,
8593
+ request: NoRequestBodySchema,
8594
+ response: z.object({ message: z.string() }).strict(),
8595
+ error: HostApiErrorSchema
8596
+ }),
8597
+ archiveAuthoringTask: defineContract({
8598
+ invalidatesSnapshot: true,
8599
+ method: "POST",
8600
+ path: "/api/authoring/tasks/:taskId/archive",
8601
+ params: z.object({ taskId: AuthoringTaskIdSchema }).strict(),
8602
+ request: NoRequestBodySchema,
8603
+ response: z.object({ ok: z.literal(true) }).strict(),
8604
+ error: HostApiErrorSchema
5677
8605
  })
5678
8606
  };
5679
8607
  const pathParameterPattern = /:([A-Za-z][A-Za-z0-9]*)/gu;
@@ -5683,9 +8611,9 @@ const buildValidatedHostApiPath = (contract, input) => {
5683
8611
  const consumed = /* @__PURE__ */ new Set();
5684
8612
  const pathname = contract.path.replace(pathParameterPattern, (_placeholder, key) => {
5685
8613
  const value = params[key];
5686
- if (typeof value !== "string") throw new TypeError(`Host API path parameter ${key} must be a string.`);
8614
+ if (typeof value !== "string" && typeof value !== "number") throw new TypeError(`Host API path parameter ${key} must be a string or number.`);
5687
8615
  consumed.add(key);
5688
- return encodeURIComponent(value);
8616
+ return encodeURIComponent(String(value));
5689
8617
  });
5690
8618
  const query = new URLSearchParams();
5691
8619
  for (const [key, value] of Object.entries(params)) {
@@ -5703,6 +8631,6 @@ function buildHostApiPath(name, input) {
5703
8631
  return buildValidatedHostApiPath(HostApiContracts[name], input);
5704
8632
  }
5705
8633
  //#endregion
5706
- export { ACTIVITY_MAX_BUCKETS, ACTIVITY_MAX_WINDOW_MS, ACTIVITY_MIN_BUCKET_MS, ActivityQuerySchema, AdapterActivityKeySchema, AdmissionIdSchema, AgentAppearanceSchema, AgentIdSchema, AgentRevisionChangedFieldSchema, AgentRevisionHistorySchema, AgentRevisionIdSchema, AssetIdSchema, AttentionItemSchema, AttentionListSchema, AuthoringAttemptIdSchema, AuthoringTaskIdSchema, CHANNEL_UNREAD_COUNT_CAP, COMMUNITY_EXTENSION_SORTS, COMMUNITY_LISTING_LIMITS, COMMUNITY_OFFICIAL_HANDLE, COMMUNITY_PERSONA_AVATAR_MAX_BYTES, COMMUNITY_PERSONA_AVATAR_TYPES, COMMUNITY_PERSONA_MAX_LENGTH, COMMUNITY_RATING_BADGES, COMMUNITY_RATING_BADGE_LIMIT, COMMUNITY_RATING_DIMENSIONS, COMMUNITY_RATING_DIMENSION_LABELS, COMMUNITY_REVIEWER_NAME, COMMUNITY_REVIEW_DIMENSION_LABELS, COMMUNITY_REVIEW_STATUSES, CONFIG_SCHEMA_MAX_BYTES, ChannelActivitySeriesSchema, ChannelActivitySummarySchema, ChannelContextPolicySchema, ChannelContextPolicyViewSchema, ChannelEventIdSchema, ChannelFactSseDataSchema, ChannelFactSseItemSchema, ChannelIdSchema, ChannelMemberIdSchema, ChannelMemberNotesViewSchema, ChannelMemoryActivitySchema, ChannelPendingContextSchema, ChannelPromptViewSchema, ChannelRuntimeCacheSampleSchema, ChannelRuntimeCacheSchema, ChannelRuntimeContextSchema, ChannelRuntimeInputSchema, ChannelRuntimeOccupancySchema, ChannelRuntimePerformanceSampleSchema, ChannelRuntimePerformanceSchema, ChannelRuntimePhaseSchema, ChannelRuntimeProjectionSchema, ChannelRuntimeSseDataSchema, ChannelRuntimeStepSchema, ChannelRuntimeToolSchema, ChannelRuntimeTurnSchema, ChannelRuntimeUsageSchema, ClientNotificationFeedResponseSchema, ClientNotificationSchema, CodeRunAvailabilitySchema, CommunityAccountSchema, CommunityEndpointSchema, CommunityEnvironmentSchema, CommunityExtensionDetailSchema, CommunityExtensionSortSchema, CommunityExtensionSummarySchema, CommunityInstalledItemSchema, CommunityInstalledSchema, CommunityListingInputSchema, CommunityMyExtensionSchema, CommunityMyPersonaSchema, CommunityMyPersonasSchema, CommunityPermissionItemSchema, CommunityPersonaDetailSchema, CommunityPersonaIdSchema, CommunityPersonaReviewStatusSchema, CommunityPersonaRevisionIdSchema, CommunityPersonaSummarySchema, CommunityRatingSchema, CommunityReleaseIdSchema, CommunityReleaseSchema, CommunityReviewReportSchema, CommunityReviewStatusSchema, CommunitySourceSchema, CommunityStatusSchema, ConfigSchemaDocumentSchema, ConfigSchemaMetaSchema, ConfigSchemaNodeSchema, ConnectionEventIdSchema, ConnectionIdSchema, ConnectionPanelRoleSchema, ConnectionTestResultSchema, DEFAULT_CHANNEL_CONTEXT_POLICY, DEFAULT_MESSAGE_PACING, DshCredentialRefSchema, DshCredentialViewSchema, DshCredentialsChangedSseDataSchema, DshNxtHostUiSchema, DshPluginCatalogEntrySchema, DshPluginEntryIdSchema, DshPluginOperationSseDataSchema, DshPluginPackageIdSchema, DshSettingsChangedSseDataSchema, DshSettingsMutationRequestSchema, DshSettingsNamespaceSchema, DshSettingsPathOperationSchema, DshSettingsPathSchema, DynamicChangedSseDataSchema, DynamicClientApprovalPolicySchema, EMPTY_CONFIG_SCHEMA, EMPTY_EXTENSION_PERMISSIONS, EMPTY_EXTENSION_UI_CONTRIBUTIONS, EXTENSION_ASSET_LIBRARY_DEFAULT_QUOTA_BYTES, EXTENSION_ASSET_LIBRARY_MAX_QUOTA_BYTES, EXTENSION_CONTEXT_DYNAMIC_MAX_CHARS, EXTENSION_CONTEXT_STATIC_MAX_CHARS, EXTENSION_DATA_HOOK_PERMISSIONS, EXTENSION_INBOUND_HOOK_MAX_TIMEOUT_MS, EXTENSION_INDEX_MAX_FILTERS, EXTENSION_INDEX_MAX_TEXT_FIELDS, EXTENSION_JOB_MAX_RUNTIME, EXTENSION_LLM_MAX_CALLS_PER_TURN, EXTENSION_LLM_MAX_OUTPUT_TOKENS, EXTENSION_MODEL_MAX_CALLS_PER_MINUTE, EXTENSION_PROVIDES, EXTENSION_SDK_BASE_LEVEL, EXTENSION_SDK_LEVEL, EXTENSION_SDK_RELEASES, EXTENSION_STORAGE_DEFAULT_QUOTA_BYTES, EXTENSION_STORAGE_MAX_QUOTA_BYTES, EXTENSION_STORAGE_SCOPES, EpisodeHandoffIdSchema, EpisodeIdSchema, ExtensionActivationTransitionSchema, ExtensionAssetLibraryCapabilitySchema, ExtensionAssetsCapabilitySchema, ExtensionCapabilitiesSchema, ExtensionConfigDeclarationSchema, ExtensionContextContributionSchema, ExtensionDeclaredJobSchema, ExtensionIdSchema, ExtensionImportInspectionSchema, ExtensionInboundHookCapabilitySchema, ExtensionIndexCapabilitySchema, ExtensionIndexCollectionSchema, ExtensionJobsCapabilitySchema, ExtensionLayeredConfigSchema, ExtensionLlmCapabilitySchema, ExtensionMcpCapabilitySchema, ExtensionMcpServerNameSchema, ExtensionMcpServerSchema, ExtensionMcpValueSchema, ExtensionModelsCapabilitySchema, ExtensionNetworkCapabilitySchema, ExtensionNetworkDomainSchema, ExtensionPanelAnchorSchema, ExtensionPanelDeclarationSchema, ExtensionPermissionRequirementSchema, ExtensionPermissionsSchema, ExtensionPlatformCapabilitySchema, ExtensionProvideSchema, ExtensionRequiresSchema, ExtensionRevisionIdSchema, ExtensionStorageCapabilitySchema, ExtensionStorageScopeSchema, ExtensionUiContributionsSchema, HOST_PAGE_DEFAULT_RAIL_ORDER, HOST_UI_KIT_COMPONENT_NAMES, HostApiContracts, HostApiErrorSchema, HostConnectionEventSchema, HostIconNameSchema, HostLayerCapabilitiesSchema, HostPageContributionSchema, HostPageIconSchema, HostSnapshotMessageSchema, HostSnapshotSchema, HostSseEventSchema, HostSseStatusDataSchema, HostSyncCursorSchema, HostUiKitComponentNameSchema, HostUiNavigationGroupSchema, HostUiNavigationItemSchema, HostUiNavigationModelSchema, HostUiNetworkOriginSchema, HostUiOwnerSchema, HostUiPageEntrySchema, HostUiPageGeometryEvidenceSchema, HostUiPageInstanceIdSchema, HostUiPagePreferencesSchema, HostUiPermissionDeclarationSchema, HostUiPermissionSchema, HostUpgradeSummarySchema, INSECURE_HTTP_MANAGEMENT_PAIR_PROOF_PREFIX, ImageUnderstandingPolicyApiSchema, InsecureHttpManagementChallengeResponseSchema, InstanceDescriptorSchema, InstanceDescriptorWireSchema, JsonValueSchema, LlmDiscoveredModelSchema, LlmModelInputModalitiesSchema, LlmProviderCredentialSchema, LlmProviderModelSchema, LlmProviderSettingsSchema, LlmProviderTestResultSchema, LlmProviderViewSchema, LogicalMessageIdSchema, MANAGEMENT_PAIR_PROOF_PREFIX, ManagementChallengeResponseSchema, ManagementDeviceEnrollmentRequestSchema, ManagementDeviceEnrollmentResponseSchema, ManagementDeviceIdSchema, ManagementDeviceViewSchema, ManagementSessionRequestSchema, ManagementSessionResponseSchema, McpServerFormSchema, MessagePacingSchema, MessagePacingSettingsSchema, MessagePartSchema, MessagePartsSchema, MessageRendererContributionSchema, NonEmptyMessagePartsSchema, NotificationEventKeySchema, NotificationSettingsViewSchema, OutboundIntentIdSchema, PANEL_ANCHOR_LAYER, PROMPT_DOCUMENT_MAX_PLAIN_TEXT_LENGTH, PROMPT_DOCUMENT_MAX_REFERENCES, PanelContributionSchema, PanelDensitySchema, PhysicalDeliveryIdSchema, PlatformIdentityIdSchema, PlatformUserListResponseSchema, ProductUpdateStatusSchema, PromptDocumentV1Schema, PromptSegmentSchema, RICH_EXTENSION_MAX_BYTES, RetrievalModeSchema, RetrievalStatusSchema, RichExtensionSchema, RichKindSchema, RichTargetUrlSchema, RuntimeCompatibilityDiagnosticSchema, ScheduledTaskIdSchema, ScheduledTaskSchema, ServerInstanceIdSchema, TestBarkNotificationRequestSchema, ToolViewContributionSchema, ToolViewDensitySchema, UpdateNotificationSettingsRequestSchema, WorkTreeOrderSchema, activityDurationMs, agentPermissionDeclaration, buildHostApiContractPath, buildHostApiPath, communityPersonaReviewLabel, communityPublisherLabel, communityReviewLabel, configDescription, configFieldKind, configFields, configSchema, configSecretKeys, extensionCapabilitiesExpand, extensionSdkVersion, hostLayerAsCapabilities, hostPageRailOrder, hostPermissionDeclaration, insecureHttpManagementPairProofMessage, managementPairProofMessage, mcpSecretFields, messagePartAssetId, messagePartAssetIds, messagePartsSearchText, normalizePromptDocument, parseConfigValue, parseJsonValue, parseMessageParts, promptDocumentFromText, promptDocumentPlainText, requiredExtensionSdkLevel, richPartContextText, summarizeExtensionCapabilities, validateConfigValue };
8634
+ export { ACTIVITY_MAX_BUCKETS, ACTIVITY_MAX_WINDOW_MS, ACTIVITY_MIN_BUCKET_MS, ActivityQuerySchema, AdapterActivityKeySchema, AddLinkedAccountRequestSchema, AdministratorSchema, AdmissionIdSchema, AgentAliasesSchema, AgentAppearanceSchema, AgentCompactionModelChoiceSchema, AgentCompactionPolicySchema, AgentFallbackModelsSchema, AgentIdSchema, AgentRevisionChangedFieldSchema, AgentRevisionHistorySchema, AgentRevisionIdSchema, AgentSubConversationModelsSchema, AssetIdSchema, AttentionItemSchema, AttentionListSchema, AuthoringAttemptIdSchema, AuthoringTaskIdSchema, BoundCredentialsSchema, 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, CREDENTIAL_DESCRIPTION_MAX_CHARS, CREDENTIAL_NAME_MAX_CHARS, CREDENTIAL_REDACTABLE_MIN_CHARS, CREDENTIAL_VALUE_MAX_CHARS, ChannelActivitySeriesSchema, ChannelActivitySummarySchema, ChannelContextPolicySchema, ChannelContextPolicyViewSchema, ChannelEventIdSchema, ChannelFactSseDataSchema, ChannelFactSseItemSchema, ChannelIdSchema, ChannelListViewSchema, ChannelMemberIdSchema, ChannelMemberNotesViewSchema, ChannelMemoryActivitySchema, ChannelPendingContextSchema, ChannelPromptViewSchema, ChannelRuntimeCacheSampleSchema, ChannelRuntimeCacheSchema, ChannelRuntimeContextSchema, ChannelRuntimeInputSchema, ChannelRuntimeOccupancySchema, ChannelRuntimePerformanceSampleSchema, ChannelRuntimePerformanceSchema, ChannelRuntimePhaseSchema, ChannelRuntimeProjectionSchema, ChannelRuntimeSseDataSchema, ChannelRuntimeStepSchema, ChannelRuntimeToolSchema, ChannelRuntimeTurnSchema, ChannelRuntimeUsageSchema, ClientNotificationFeedResponseSchema, ClientNotificationSchema, CodeRunAvailabilitySchema, CommandAccountUsageSchema, 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, CommunityFreshnessSchema, CommunityInstalledItemSchema, CommunityInstalledSchema, CommunityListingInputSchema, CommunityMyExtensionSchema, CommunityMyPersonaSchema, CommunityMyPersonasSchema, CommunityPermissionItemSchema, CommunityPersonaDetailSchema, CommunityPersonaIdSchema, CommunityPersonaReviewStatusSchema, CommunityPersonaRevisionIdSchema, CommunityPersonaSummarySchema, CommunityRatingSchema, CommunityReleaseIdSchema, CommunityReleaseSchema, CommunityReviewReportSchema, CommunityReviewStatusSchema, CommunitySourceSchema, CommunityStatusSchema, CommunitySyncItemSchema, CommunitySyncSchema, CompactionSettingsSchema, ConfigSchemaDocumentSchema, ConfigSchemaMetaSchema, ConfigSchemaNodeSchema, ConnectionEventIdSchema, ConnectionIdSchema, ConnectionPanelRoleSchema, ConnectionTestResultSchema, CreateCredentialRequestSchema, CredentialAgentScopeSchema, CredentialBindingsRequestSchema, CredentialConsumerKindSchema, CredentialDescriptionSchema, CredentialDomainsSchema, CredentialEnvNameSchema, CredentialIdSchema, CredentialNameSchema, CredentialRequestViewSchema, CredentialUsageSchema, CredentialUseSchema, CredentialUsersSchema, CredentialUsesViewSchema, CredentialValueSchema, CredentialViewSchema, CredentialsViewSchema, DEFAULT_CHANNEL_CONTEXT_POLICY, DEFAULT_COMPACTION_SETTINGS, DEFAULT_MESSAGE_PACING, DEFAULT_MODEL_FALLBACK_SETTINGS, 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_OUTBOUND_MAX_TIMEOUT_MS, EXTENSION_OUTBOUND_SDK_LEVEL, 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, ExtensionConfigVersionSchema, ExtensionConfigVersionSourceSchema, ExtensionContextContributionSchema, ExtensionDataMigrationInputSchema, ExtensionDataPackageInspectionSchema, ExtensionDataPreviewSchema, ExtensionDataSourceSchema, ExtensionDataStateSchema, ExtensionDeclaredJobSchema, ExtensionIdSchema, ExtensionImportInspectionSchema, ExtensionInboundHookCapabilitySchema, ExtensionIndexCapabilitySchema, ExtensionIndexCollectionSchema, ExtensionJobsCapabilitySchema, ExtensionLayeredConfigSchema, ExtensionLineageNodeSchema, ExtensionLineageSchema, ExtensionLlmCapabilitySchema, ExtensionMcpCapabilitySchema, ExtensionMcpServerNameSchema, ExtensionMcpServerSchema, ExtensionMcpValueSchema, ExtensionModelsCapabilitySchema, ExtensionNetworkCapabilitySchema, ExtensionNetworkDomainSchema, ExtensionOutboundCapabilitySchema, ExtensionPanelAnchorSchema, ExtensionPanelDeclarationSchema, ExtensionPermissionRequirementSchema, ExtensionPermissionsSchema, ExtensionPlatformCapabilitySchema, ExtensionProvideSchema, ExtensionRequestSchema, ExtensionRequiresSchema, ExtensionRevisionIdSchema, ExtensionStorageCapabilitySchema, ExtensionStorageScopeSchema, ExtensionUiContributionsSchema, FALLBACK_MODEL_LIMIT, 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, LinkedAccountIdSchema, LinkedAccountMethodSchema, LinkedAccountPlatformIdSchema, LinkedAccountPlatformToolSchema, LinkedAccountTokenSourceSchema, LinkedAccountUseSchema, LinkedAccountUsesViewSchema, LinkedAccountViewSchema, LinkedAccountsViewSchema, LlmDiscoveredModelSchema, LlmModelInputModalitiesSchema, LlmModelReasoningEffortsSchema, 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, ModelFallbackReasonSchema, ModelFallbackSettingsSchema, ModelProviderAccessSchema, NO_SUB_CONVERSATION_MODELS, 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, RESPONSE_TIMING_DEFAULTS, RESPONSE_TIMING_LIMITS, RESPONSE_WAIT_MIN_QUIET_SECONDS, RICH_EXTENSION_MAX_BYTES, RemoveCredentialRequestSchema, RemoveCredentialResultSchema, RemoveLinkedAccountRequestSchema, RemoveLinkedAccountResultSchema, ReplaceCredentialValueRequestSchema, ReplaceLinkedAccountTokenRequestSchema, ResponseTimingSettingsSchema, RetrievalModeSchema, RetrievalStatusSchema, RichExtensionSchema, RichKindSchema, RichTargetUrlSchema, RuntimeCompatibilityDiagnosticSchema, SUB_CONVERSATION_MAIN_MODEL, SUB_CONVERSATION_MODEL_LIMITS, ScheduledTaskIdSchema, ScheduledTaskSchema, ServerInstanceIdSchema, SetModelProviderAccessRequestSchema, SubConversationIdSchema, SubConversationRetentionSchema, SubConversationSchema, SubConversationSettingsSchema, SubscriptionStatusSchema, TestBarkNotificationRequestSchema, ToolViewContributionSchema, ToolViewDensitySchema, UNBOUND_CHANNEL_GROUP_ID, UpdateCredentialRequestSchema, UpdateNotificationSettingsRequestSchema, UpgradeBackupModeSchema, UpgradeBackupSettingsSchema, VerificationBrowserAvailabilitySchema, WorkTreeOrderSchema, activityDurationMs, adminOnlyConfigKeys, agentPermissionDeclaration, buildHostApiContractPath, buildHostApiPath, commandNameOf, commandUsage, communityPersonaReviewLabel, communityPublisherLabel, communityReviewLabel, configDescription, configFieldKind, configFieldLevel, configFields, configSchema, configSecretKeys, credentialRequestRoute, 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, outboundProcessesBeforeSend, parseCommandArguments, parseConfigValue, parseJsonValue, parseMessageParts, promptDocumentFromText, promptDocumentPlainText, recognizeCommand, requiredExtensionSdkLevel, resolveResponseTiming, richPartContextText, summarizeExtensionCapabilities, tokenizeCommand, undeliveredCommandReplies, validateConfigValue };
5707
8635
 
5708
8636
  //# sourceMappingURL=index.mjs.map