@zhin.js/runtime 1.0.13 → 1.0.14

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.
@@ -1,5 +1,7 @@
1
1
  import type { PluginId } from '@zhin.js/plugin-runtime';
2
2
  import type { ProjectGraph } from './project-graph.js';
3
+ /** Host configuration keys consumed by Runtime composition and Host installers. */
4
+ export declare const HOST_CONFIG_KEYS: readonly string[];
3
5
  export type JsonSchema = Readonly<Record<string, unknown>>;
4
6
  export type RuntimeConfigDocument = Readonly<Record<string, unknown>>;
5
7
  export interface ComposedConfig {
@@ -1,6 +1,18 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
3
  import Ajv2020 from 'ajv/dist/2020.js';
4
+ import hostConfigSchema from './host-config-schema.json' with { type: 'json' };
5
+ function deepFreeze(value) {
6
+ if (value && typeof value === 'object' && !Object.isFrozen(value)) {
7
+ for (const nested of Object.values(value))
8
+ deepFreeze(nested);
9
+ Object.freeze(value);
10
+ }
11
+ return value;
12
+ }
13
+ const HOST_CONFIG_SCHEMA = deepFreeze(hostConfigSchema);
14
+ /** Host configuration keys consumed by Runtime composition and Host installers. */
15
+ export const HOST_CONFIG_KEYS = Object.freeze(Object.keys(HOST_CONFIG_SCHEMA.properties));
4
16
  export class ConfigSchemaCollisionError extends Error {
5
17
  plugin;
6
18
  instanceKey;
@@ -43,6 +55,7 @@ export class ConfigComposer {
43
55
  type: 'object',
44
56
  additionalProperties: false,
45
57
  properties: {
58
+ ...HOST_CONFIG_SCHEMA.properties,
46
59
  plugin: withDefault(rootOwn),
47
60
  plugins: {
48
61
  type: 'object',
@@ -50,45 +63,10 @@ export class ConfigComposer {
50
63
  default: {},
51
64
  properties: Object.fromEntries(childSchemas.map(([key, schema]) => [key, withDefault(schema)])),
52
65
  },
53
- http: Object.freeze({
54
- type: 'object',
55
- additionalProperties: true,
56
- }),
57
- database: Object.freeze({
58
- type: 'object',
59
- additionalProperties: true,
60
- }),
61
- ai: Object.freeze({
62
- type: 'object',
63
- additionalProperties: true,
64
- }),
65
- mcp: Object.freeze({
66
- type: 'object',
67
- additionalProperties: true,
68
- }),
69
- a2a: Object.freeze({
70
- type: 'object',
71
- additionalProperties: true,
72
- }),
73
- speech: Object.freeze({
74
- type: 'object',
75
- additionalProperties: true,
76
- }),
77
- htmlRenderer: Object.freeze({
78
- type: 'object',
79
- additionalProperties: true,
80
- }),
81
- assistant: Object.freeze({
82
- type: 'object',
83
- additionalProperties: true,
84
- }),
85
- log_level: Object.freeze({
86
- type: ['string', 'number'],
87
- }),
88
66
  },
89
67
  });
90
68
  const document = structuredClone(input);
91
- const validate = new Ajv2020({
69
+ const ajv = new Ajv2020({
92
70
  allErrors: true,
93
71
  useDefaults: true,
94
72
  strict: true,
@@ -96,7 +74,9 @@ export class ConfigComposer {
96
74
  // 不触发 allowUnionTypes);保留此项是面向未来插件 schema 可能出现的
97
75
  // anyOf/oneOf 标量 union,避免届时 Ajv strict 模式直接报错。
98
76
  allowUnionTypes: true,
99
- }).compile(effectiveSchema);
77
+ });
78
+ ajv.addKeyword({ keyword: 'x-descriptionZh', schemaType: 'string' });
79
+ const validate = ajv.compile(effectiveSchema);
100
80
  if (!validate(document)) {
101
81
  throw new ConfigValidationError(formatErrors(validate.errors ?? []), source);
102
82
  }
@@ -0,0 +1,123 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "additionalProperties": false,
5
+ "properties": {
6
+ "http": { "type": "object", "additionalProperties": true, "description": "HTTP, Console, REST/RPC/SSE, and Webhook Host.", "x-descriptionZh": "HTTP、Console、REST/RPC/SSE 与 Webhook Host。" },
7
+ "database": { "type": "object", "additionalProperties": true, "description": "Database Host and dialect connection options.", "x-descriptionZh": "Database Host 与方言连接参数。" },
8
+ "ai": {
9
+ "type": "object",
10
+ "additionalProperties": true,
11
+ "description": "Providers, Agents, sessions, memory, tools, and execution security.",
12
+ "x-descriptionZh": "Provider、Agent、会话、记忆、工具与执行安全策略。",
13
+ "properties": {
14
+ "agent": {
15
+ "type": "object",
16
+ "additionalProperties": true,
17
+ "description": "Agent execution, queueing, tool, and model policies.",
18
+ "x-descriptionZh": "Agent 执行、排队、工具与模型策略。",
19
+ "properties": {
20
+ "inboundQueue": {
21
+ "type": "object",
22
+ "additionalProperties": true,
23
+ "description": "Inbound turn queue policy.",
24
+ "x-descriptionZh": "入站回合排队策略。",
25
+ "properties": {
26
+ "groupMode": {
27
+ "type": "string",
28
+ "enum": ["supersede", "fifo"],
29
+ "description": "Replace an older queued group turn, or process all turns in arrival order.",
30
+ "x-descriptionZh": "覆盖较早的群聊排队回合,或按到达顺序处理全部回合。"
31
+ }
32
+ }
33
+ },
34
+ "execSecurity": {
35
+ "type": "string",
36
+ "enum": ["deny", "allowlist", "full"],
37
+ "description": "Shell command security boundary.",
38
+ "x-descriptionZh": "Shell 命令安全边界。"
39
+ },
40
+ "execPreset": {
41
+ "type": "string",
42
+ "enum": ["readonly", "network", "development", "custom"],
43
+ "description": "Command allowlist preset used outside full mode.",
44
+ "x-descriptionZh": "非 full 模式使用的命令白名单预设。"
45
+ },
46
+ "execApprovalMode": { "type": "string", "enum": ["ask", "allow", "deny"], "description": "Approval policy for main Agent commands.", "x-descriptionZh": "主 Agent 命令的审批策略。" },
47
+ "subagentExecApprovalMode": { "type": "string", "enum": ["ask", "allow", "deny"], "description": "Approval policy for sub-Agent commands.", "x-descriptionZh": "子 Agent 命令的审批策略。" },
48
+ "workerExecApprovalMode": { "type": "string", "enum": ["ask", "allow", "deny"], "description": "Approval policy for worker commands.", "x-descriptionZh": "Worker 命令的审批策略。" },
49
+ "taskExecApprovalMode": { "type": "string", "enum": ["ask", "allow", "deny"], "description": "Approval policy for task commands.", "x-descriptionZh": "Task 命令的审批策略。" },
50
+ "toolExecution": {
51
+ "type": "string",
52
+ "enum": ["parallel", "sequential", "tiered"],
53
+ "description": "How tool calls in one model step are scheduled.",
54
+ "x-descriptionZh": "同一模型步骤中的工具调用调度方式。"
55
+ },
56
+ "modelSizeHint": {
57
+ "type": "string",
58
+ "enum": ["", "small", "medium", "large"],
59
+ "description": "Optional model-size hint; an empty string clears the hint.",
60
+ "x-descriptionZh": "可选模型尺寸提示;空字符串表示清除提示。"
61
+ },
62
+ "promptCacheRetention": {
63
+ "type": "string",
64
+ "enum": ["in_memory", "24h"],
65
+ "description": "Provider prompt-cache retention policy.",
66
+ "x-descriptionZh": "Provider Prompt Cache 保留策略。"
67
+ },
68
+ "steeringMode": {
69
+ "type": "string",
70
+ "enum": ["one-at-a-time", "all"],
71
+ "description": "Process steering messages one at a time or drain all pending messages together.",
72
+ "x-descriptionZh": "逐条处理 Steering 消息,或一次取出全部待处理消息。"
73
+ },
74
+ "followUpMode": {
75
+ "type": "string",
76
+ "enum": ["one-at-a-time", "all"],
77
+ "description": "Process follow-up messages one at a time or drain all pending messages together.",
78
+ "x-descriptionZh": "逐条处理 Follow-up 消息,或一次取出全部待处理消息。"
79
+ },
80
+ "outputSchema": {
81
+ "anyOf": [
82
+ { "type": "boolean" },
83
+ { "type": "string", "enum": ["segments"] },
84
+ { "type": "object" }
85
+ ],
86
+ "description": "Structured final-output mode: false for text, true or segments for canonical message segments, or a custom JSON Schema object.",
87
+ "x-descriptionZh": "结构化最终输出:false 表示文本,true 或 segments 表示规范消息段,也可传入自定义 JSON Schema 对象。"
88
+ },
89
+ "schedule": {
90
+ "type": "object",
91
+ "additionalProperties": true,
92
+ "description": "Unattended Schedule execution policy.",
93
+ "x-descriptionZh": "无人值守 Schedule 执行策略。",
94
+ "properties": {
95
+ "security": {
96
+ "type": "object",
97
+ "additionalProperties": true,
98
+ "description": "Schedule command security policy.",
99
+ "x-descriptionZh": "Schedule 命令安全策略。",
100
+ "properties": {
101
+ "execPreset": {
102
+ "type": "string",
103
+ "enum": ["readonly", "network"],
104
+ "description": "Schedule Jobs may use only the read-only or network preset.",
105
+ "x-descriptionZh": "Schedule Job 只能使用只读或网络预设。"
106
+ }
107
+ }
108
+ }
109
+ }
110
+ }
111
+ }
112
+ }
113
+ }
114
+ },
115
+ "mcp": { "type": "object", "additionalProperties": true, "description": "Expose Bot tools through an MCP Server.", "x-descriptionZh": "把 Bot 工具公开为 MCP Server。" },
116
+ "a2a": { "type": "object", "additionalProperties": true, "description": "A2A Agent Card, remote execution, and Workroom callbacks.", "x-descriptionZh": "A2A Agent Card、远程执行与 Workroom 回调。" },
117
+ "speech": { "type": "object", "additionalProperties": true, "description": "Speech-to-text and text-to-speech Host.", "x-descriptionZh": "语音识别与语音合成 Host。" },
118
+ "htmlRenderer": { "type": "object", "additionalProperties": true, "description": "HTML and image rendering options.", "x-descriptionZh": "HTML/图片渲染参数。" },
119
+ "assistant": { "type": "object", "additionalProperties": true, "description": "Scheduled jobs, event ingress, and failure notifications.", "x-descriptionZh": "调度任务、事件入口和失败通知。" },
120
+ "log_level": { "type": ["string", "number"], "description": "Runtime log level.", "x-descriptionZh": "Runtime 日志级别。" },
121
+ "plugin": { "type": "object", "description": "Root Plugin configuration; replaced by its project schema during composition.", "x-descriptionZh": "Root Plugin 配置;组合时由项目 Schema 替换。" }
122
+ }
123
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/runtime",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "Static Plugin graph, generation transaction and HMR Root runtime for Zhin.js",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -18,22 +18,23 @@
18
18
  "dependencies": {
19
19
  "ajv": "8.18.0",
20
20
  "semver": "7.8.5",
21
- "@zhin.js/feature-kit": "1.0.12",
22
- "@zhin.js/plugin-runtime": "1.1.7"
21
+ "@zhin.js/plugin-runtime": "1.1.8",
22
+ "@zhin.js/feature-kit": "1.0.13"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "^26.1.2",
26
26
  "typescript": "^6.0.3",
27
- "@zhin.js/adapter": "1.1.11",
28
- "@zhin.js/agent-feature": "1.0.12",
29
- "@zhin.js/command": "1.0.15",
30
- "@zhin.js/component": "1.0.12",
31
- "@zhin.js/mcp-feature": "1.0.12",
32
- "@zhin.js/page": "1.0.12",
33
- "@zhin.js/skill": "1.0.12",
34
- "@zhin.js/layout": "1.0.12",
35
- "@zhin.js/middleware": "1.0.12",
36
- "@zhin.js/tool": "1.0.12"
27
+ "@zhin.js/agent-feature": "1.0.13",
28
+ "@zhin.js/adapter": "1.2.1",
29
+ "@zhin.js/command": "1.0.16",
30
+ "@zhin.js/component": "1.0.13",
31
+ "@zhin.js/layout": "1.0.13",
32
+ "@zhin.js/mcp-feature": "1.0.13",
33
+ "@zhin.js/middleware": "1.0.13",
34
+ "@zhin.js/prompt-section": "0.0.1",
35
+ "@zhin.js/skill": "1.0.13",
36
+ "@zhin.js/page": "1.0.13",
37
+ "@zhin.js/tool": "1.0.13"
37
38
  },
38
39
  "repository": {
39
40
  "type": "git",