@yuhere/js-jsonrpc2 2.1.12 → 2.1.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.
Files changed (181) hide show
  1. package/dist/cli/cli.d.ts +0 -1
  2. package/dist/cli/cli.js +0 -1
  3. package/dist/cli/demo-methods.d.ts +0 -1
  4. package/dist/cli/demo-methods.js +0 -1
  5. package/dist/cli/express.d.ts +0 -1
  6. package/dist/cli/express.js +0 -1
  7. package/dist/cli/stdio.d.ts +0 -1
  8. package/dist/cli/stdio.js +0 -1
  9. package/dist/core/Repository.d.ts +0 -1
  10. package/dist/core/Repository.js +0 -1
  11. package/dist/core/convert.d.ts +0 -1
  12. package/dist/core/convert.js +0 -1
  13. package/dist/core/descriptor.d.ts +0 -1
  14. package/dist/core/descriptor.js +0 -1
  15. package/dist/core/index.d.ts +0 -1
  16. package/dist/core/index.js +0 -1
  17. package/dist/core/llm-tools.d.ts +0 -1
  18. package/dist/core/llm-tools.js +41 -43
  19. package/dist/core/permission.d.ts +0 -1
  20. package/dist/core/permission.js +0 -1
  21. package/dist/core/spec-check.d.ts +0 -1
  22. package/dist/core/spec-check.js +0 -1
  23. package/dist/core/system-methods.d.ts +0 -1
  24. package/dist/core/system-methods.js +0 -1
  25. package/dist/errors/RPCError.d.ts +0 -1
  26. package/dist/errors/RPCError.js +0 -1
  27. package/dist/errors/codes.d.ts +0 -1
  28. package/dist/errors/codes.js +0 -1
  29. package/dist/errors/index.d.ts +0 -1
  30. package/dist/errors/index.js +0 -1
  31. package/dist/index.d.ts +0 -1
  32. package/dist/index.js +0 -1
  33. package/dist/metrics/memory.d.ts +0 -1
  34. package/dist/metrics/memory.js +0 -1
  35. package/dist/metrics/prom.d.ts +0 -1
  36. package/dist/metrics/prom.js +0 -1
  37. package/dist/schema/json/index.d.ts +1 -2
  38. package/dist/schema/json/index.js +0 -1
  39. package/dist/schema/json/marker.d.ts +0 -1
  40. package/dist/schema/json/marker.js +0 -1
  41. package/dist/schema/json/primitives.d.ts +49 -70
  42. package/dist/schema/json/primitives.js +70 -77
  43. package/dist/schema/z/protocol.d.ts +1 -2
  44. package/dist/schema/z/protocol.js +0 -1
  45. package/dist/schema/z/register.d.ts +0 -1
  46. package/dist/schema/z/register.js +0 -1
  47. package/dist/stream/stringify-stream.d.ts +0 -1
  48. package/dist/stream/stringify-stream.js +94 -70
  49. package/dist/transport/express/body.d.ts +0 -1
  50. package/dist/transport/express/body.js +0 -1
  51. package/dist/transport/express/index.d.ts +0 -1
  52. package/dist/transport/express/index.js +0 -1
  53. package/dist/transport/express/middleware.d.ts +0 -1
  54. package/dist/transport/express/middleware.js +0 -1
  55. package/dist/transport/express/respond.d.ts +0 -1
  56. package/dist/transport/express/respond.js +0 -1
  57. package/dist/transport/stdio/index.d.ts +0 -1
  58. package/dist/transport/stdio/index.js +0 -1
  59. package/dist/transport/stdio/middleware.d.ts +0 -1
  60. package/dist/transport/stdio/middleware.js +0 -1
  61. package/dist/transport/ws/index.d.ts +0 -1
  62. package/dist/transport/ws/index.js +0 -1
  63. package/dist/transport/ws/middleware.d.ts +0 -1
  64. package/dist/transport/ws/middleware.js +0 -1
  65. package/dist/transport/ws/standalone.d.ts +0 -1
  66. package/dist/transport/ws/standalone.js +0 -1
  67. package/dist/types.d.ts +0 -1
  68. package/dist/types.js +0 -1
  69. package/dist/webclient/webui/src/client/httpTransport.d.ts +8 -0
  70. package/dist/webclient/webui/src/client/httpTransport.js +114 -0
  71. package/dist/webclient/webui/src/client/index.d.ts +4 -0
  72. package/dist/webclient/webui/src/client/index.js +2 -0
  73. package/dist/webclient/webui/src/client/rpc.d.ts +24 -0
  74. package/dist/webclient/webui/src/client/rpc.js +32 -0
  75. package/dist/webclient/webui/src/client/types.d.ts +14 -0
  76. package/dist/webclient/webui/src/client/types.js +1 -0
  77. package/dist/webclient/webui/src/client/wsTransport.d.ts +8 -0
  78. package/{webui/src/api/wsTransport.ts → dist/webclient/webui/src/client/wsTransport.js} +263 -305
  79. package/htdoc/assets/favicon-CXdFuLlv.png +0 -0
  80. package/{webui/src/styles/geek.css → htdoc/assets/index-Rq1yIwo2.css} +58 -0
  81. package/htdoc/assets/{index-Cr0Jnrgb.js → index-mYqtDOwe.js} +1344 -398
  82. package/htdoc/assets/index-mYqtDOwe.js.map +1 -0
  83. package/htdoc/index.html +4 -2
  84. package/package.json +10 -7
  85. package/dist/cli/cli.d.ts.map +0 -1
  86. package/dist/cli/cli.js.map +0 -1
  87. package/dist/cli/demo-methods.d.ts.map +0 -1
  88. package/dist/cli/demo-methods.js.map +0 -1
  89. package/dist/cli/express.d.ts.map +0 -1
  90. package/dist/cli/express.js.map +0 -1
  91. package/dist/cli/stdio.d.ts.map +0 -1
  92. package/dist/cli/stdio.js.map +0 -1
  93. package/dist/core/Repository.d.ts.map +0 -1
  94. package/dist/core/Repository.js.map +0 -1
  95. package/dist/core/convert.d.ts.map +0 -1
  96. package/dist/core/convert.js.map +0 -1
  97. package/dist/core/descriptor.d.ts.map +0 -1
  98. package/dist/core/descriptor.js.map +0 -1
  99. package/dist/core/index.d.ts.map +0 -1
  100. package/dist/core/index.js.map +0 -1
  101. package/dist/core/llm-tools.d.ts.map +0 -1
  102. package/dist/core/llm-tools.js.map +0 -1
  103. package/dist/core/permission.d.ts.map +0 -1
  104. package/dist/core/permission.js.map +0 -1
  105. package/dist/core/spec-check.d.ts.map +0 -1
  106. package/dist/core/spec-check.js.map +0 -1
  107. package/dist/core/system-methods.d.ts.map +0 -1
  108. package/dist/core/system-methods.js.map +0 -1
  109. package/dist/errors/RPCError.d.ts.map +0 -1
  110. package/dist/errors/RPCError.js.map +0 -1
  111. package/dist/errors/codes.d.ts.map +0 -1
  112. package/dist/errors/codes.js.map +0 -1
  113. package/dist/errors/index.d.ts.map +0 -1
  114. package/dist/errors/index.js.map +0 -1
  115. package/dist/index.d.ts.map +0 -1
  116. package/dist/index.js.map +0 -1
  117. package/dist/metrics/memory.d.ts.map +0 -1
  118. package/dist/metrics/memory.js.map +0 -1
  119. package/dist/metrics/prom.d.ts.map +0 -1
  120. package/dist/metrics/prom.js.map +0 -1
  121. package/dist/schema/json/index.d.ts.map +0 -1
  122. package/dist/schema/json/index.js.map +0 -1
  123. package/dist/schema/json/marker.d.ts.map +0 -1
  124. package/dist/schema/json/marker.js.map +0 -1
  125. package/dist/schema/json/primitives.d.ts.map +0 -1
  126. package/dist/schema/json/primitives.js.map +0 -1
  127. package/dist/schema/z/protocol.d.ts.map +0 -1
  128. package/dist/schema/z/protocol.js.map +0 -1
  129. package/dist/schema/z/register.d.ts.map +0 -1
  130. package/dist/schema/z/register.js.map +0 -1
  131. package/dist/stream/stringify-stream.d.ts.map +0 -1
  132. package/dist/stream/stringify-stream.js.map +0 -1
  133. package/dist/transport/express/body.d.ts.map +0 -1
  134. package/dist/transport/express/body.js.map +0 -1
  135. package/dist/transport/express/index.d.ts.map +0 -1
  136. package/dist/transport/express/index.js.map +0 -1
  137. package/dist/transport/express/middleware.d.ts.map +0 -1
  138. package/dist/transport/express/middleware.js.map +0 -1
  139. package/dist/transport/express/respond.d.ts.map +0 -1
  140. package/dist/transport/express/respond.js.map +0 -1
  141. package/dist/transport/stdio/index.d.ts.map +0 -1
  142. package/dist/transport/stdio/index.js.map +0 -1
  143. package/dist/transport/stdio/middleware.d.ts.map +0 -1
  144. package/dist/transport/stdio/middleware.js.map +0 -1
  145. package/dist/transport/ws/index.d.ts.map +0 -1
  146. package/dist/transport/ws/index.js.map +0 -1
  147. package/dist/transport/ws/middleware.d.ts.map +0 -1
  148. package/dist/transport/ws/middleware.js.map +0 -1
  149. package/dist/transport/ws/standalone.d.ts.map +0 -1
  150. package/dist/transport/ws/standalone.js.map +0 -1
  151. package/dist/types.d.ts.map +0 -1
  152. package/dist/types.js.map +0 -1
  153. package/htdoc/assets/index-Ck-39Igh.css +0 -963
  154. package/htdoc/assets/index-Cr0Jnrgb.js.map +0 -1
  155. package/webui/index.html +0 -12
  156. package/webui/src/App.tsx +0 -164
  157. package/webui/src/api/docGen.ts +0 -188
  158. package/webui/src/api/glob.ts +0 -90
  159. package/webui/src/api/httpTransport.ts +0 -148
  160. package/webui/src/api/metrics.ts +0 -135
  161. package/webui/src/api/paramForm.ts +0 -80
  162. package/webui/src/api/rpc.ts +0 -57
  163. package/webui/src/api/schema.ts +0 -12
  164. package/webui/src/api/types.ts +0 -16
  165. package/webui/src/components/MethodDetail.tsx +0 -43
  166. package/webui/src/components/MethodTree.tsx +0 -118
  167. package/webui/src/components/MetricsPanel.md +0 -126
  168. package/webui/src/components/MetricsPanel.tsx +0 -290
  169. package/webui/src/components/SchemaForm.tsx +0 -697
  170. package/webui/src/components/SchemaView.tsx +0 -151
  171. package/webui/src/components/TestPanel.tsx +0 -322
  172. package/webui/src/components/Toolbar.tsx +0 -82
  173. package/webui/src/hooks/useMethodDetail.ts +0 -61
  174. package/webui/src/hooks/useMethods.ts +0 -27
  175. package/webui/src/hooks/useMetrics.ts +0 -91
  176. package/webui/src/main.tsx +0 -13
  177. package/webui/src/theme/ThemeProvider.tsx +0 -79
  178. package/webui/src/vite-env.d.ts +0 -1
  179. package/webui/tsconfig.json +0 -34
  180. package/webui/tsconfig.node.json +0 -13
  181. package/webui/vite.config.ts +0 -15
package/dist/cli/cli.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  #!/usr/bin/env node
2
2
  export {};
3
- //# sourceMappingURL=cli.d.ts.map
package/dist/cli/cli.js CHANGED
@@ -137,4 +137,3 @@ main().catch((err) => {
137
137
  console.error('启动失败:', err);
138
138
  process.exit(1);
139
139
  });
140
- //# sourceMappingURL=cli.js.map
@@ -7,4 +7,3 @@ import type { Repository } from '../core/Repository.js';
7
7
  * 被 dev/express.ts 与 src/cli.ts 共用。
8
8
  */
9
9
  export declare function installDemoMethods(repository: Repository): void;
10
- //# sourceMappingURL=demo-methods.d.ts.map
@@ -473,4 +473,3 @@ export function installDemoMethods(repository) {
473
473
  }
474
474
  });
475
475
  }
476
- //# sourceMappingURL=demo-methods.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=express.d.ts.map
@@ -39,4 +39,3 @@ const port = Number(process.env['PORT'] ?? 5000);
39
39
  server.listen(port, () => {
40
40
  console.log(`js-jsonrpc2 debug server listening on http://localhost:${port}`);
41
41
  });
42
- //# sourceMappingURL=express.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=stdio.d.ts.map
package/dist/cli/stdio.js CHANGED
@@ -2,4 +2,3 @@ import { createRepository, serveStdio, s } from '../index.js';
2
2
  const repository = createRepository();
3
3
  repository.register({ namespace: 'echo', signature: [s.string(), s.string()] }, (v) => v);
4
4
  await serveStdio({ repository, framing: 'lines' });
5
- //# sourceMappingURL=stdio.js.map
@@ -19,4 +19,3 @@ export declare class Repository {
19
19
  }
20
20
  export declare function createRepository(options?: RepositoryOptions): Repository;
21
21
  export type { MethodDescriptor };
22
- //# sourceMappingURL=Repository.d.ts.map
@@ -297,4 +297,3 @@ export class Repository {
297
297
  export function createRepository(options = {}) {
298
298
  return new Repository(options);
299
299
  }
300
- //# sourceMappingURL=Repository.js.map
@@ -1,4 +1,3 @@
1
1
  import type { MethodDescriptor } from './descriptor.js';
2
2
  import type { Injections } from '../types.js';
3
3
  export declare function convertParams(descriptor: MethodDescriptor, params: unknown, injections: Injections): Promise<unknown[]>;
4
- //# sourceMappingURL=convert.d.ts.map
@@ -26,4 +26,3 @@ export async function convertParams(descriptor, params, injections) {
26
26
  }
27
27
  return converted;
28
28
  }
29
- //# sourceMappingURL=convert.js.map
@@ -24,4 +24,3 @@ export declare function buildDescriptor(descriptor: RPCDescriptor, fn: RPCHandle
24
24
  export declare function signatureOf(descriptor: MethodDescriptor): unknown[];
25
25
  export declare function lookup(methods: Map<string, MethodDescriptor>, method: string): MethodDescriptor;
26
26
  export declare function invalidParams(message: string, data?: unknown): RPCError;
27
- //# sourceMappingURL=descriptor.d.ts.map
@@ -80,4 +80,3 @@ export function lookup(methods, method) {
80
80
  export function invalidParams(message, data) {
81
81
  return new RPCError(INVALID_PARAMS, message, data);
82
82
  }
83
- //# sourceMappingURL=descriptor.js.map
@@ -1,4 +1,3 @@
1
1
  export { Repository, createRepository } from './Repository.js';
2
2
  export type { MethodDescriptor } from './descriptor.js';
3
3
  export { validateRequest } from './spec-check.js';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,2 @@
1
1
  export { Repository, createRepository } from './Repository.js';
2
2
  export { validateRequest } from './spec-check.js';
3
- //# sourceMappingURL=index.js.map
@@ -22,4 +22,3 @@ export interface JSONSchema {
22
22
  }
23
23
  export declare function listLlmTools(repository: Repository, injections: Injections, rawOptions?: unknown): Promise<LlmTools>;
24
24
  export declare function invokeLlmTool(repository: Repository, call: LlmToolCall, injections: Injections): Promise<unknown>;
25
- //# sourceMappingURL=llm-tools.d.ts.map
@@ -50,12 +50,12 @@ function convert(desc) {
50
50
  out.minItems = c.min;
51
51
  if (c.max !== undefined)
52
52
  out.maxItems = c.max;
53
- out.items = convert(desc.children.items);
53
+ out.items = convert(desc.element);
54
54
  break;
55
55
  }
56
56
  case 'tuple': {
57
57
  out.type = 'array';
58
- const items = desc.children.items;
58
+ const items = desc.elements;
59
59
  out.items = items.map(convert);
60
60
  out.minItems = items.length;
61
61
  out.maxItems = items.length;
@@ -63,19 +63,19 @@ function convert(desc) {
63
63
  }
64
64
  case 'object': {
65
65
  out.type = 'object';
66
- const strict = Boolean(desc.constraints.strict);
67
- const props = desc.children
68
- .properties;
66
+ const optional = new Set((desc.constraints
67
+ ?.optionalProps) ?? []);
68
+ const allowUnknown = (desc.constraints
69
+ ?.allowUnknownProps) ?? true;
70
+ const props = desc.properties;
69
71
  out.properties = {};
70
72
  for (const [k, v] of Object.entries(props))
71
73
  out.properties[k] = convert(v);
72
- if (strict) {
73
- out.required = Object.keys(props);
74
+ const required = Object.keys(props).filter((k) => !optional.has(k));
75
+ if (required.length > 0)
76
+ out.required = required;
77
+ if (!allowUnknown)
74
78
  out.additionalProperties = false;
75
- }
76
- else {
77
- out.additionalProperties = true;
78
- }
79
79
  break;
80
80
  }
81
81
  case 'record': {
@@ -85,12 +85,11 @@ function convert(desc) {
85
85
  out.minProperties = c.min;
86
86
  if (c.max !== undefined)
87
87
  out.maxProperties = c.max;
88
- out.additionalProperties = convert(desc.children.values);
88
+ out.additionalProperties = convert(desc.value);
89
89
  break;
90
90
  }
91
91
  case 'union': {
92
- const options = desc.children.options;
93
- out.anyOf = options.map(convert);
92
+ out.anyOf = desc.options.map(convert);
94
93
  break;
95
94
  }
96
95
  case 'unknown': {
@@ -101,8 +100,10 @@ function convert(desc) {
101
100
  out.type = 'null';
102
101
  break;
103
102
  }
104
- default:
105
- throw new Error(`Unsupported schema kind for JSON Schema: ${desc.kind}`);
103
+ default: {
104
+ const _exhaustive = desc;
105
+ throw new Error(`Unsupported schema kind for JSON Schema: ${JSON.stringify(_exhaustive)}`);
106
+ }
106
107
  }
107
108
  if (desc.nullable) {
108
109
  if (desc.kind === 'unknown' || desc.kind === 'null') {
@@ -150,7 +151,6 @@ function renderSchema(schema, indent = 0) {
150
151
  if (c)
151
152
  head += ` \`${c}\``;
152
153
  lines.push(head);
153
- const ch = schema.children ?? {};
154
154
  const pushChild = (label, child) => {
155
155
  const sub = renderSchema(child, indent + 1);
156
156
  if (sub.length) {
@@ -158,36 +158,35 @@ function renderSchema(schema, indent = 0) {
158
158
  lines.push(...sub);
159
159
  }
160
160
  };
161
- if (isSchema(ch.inner))
162
- pushChild('inner', ch.inner);
163
- if (Array.isArray(ch.items)) {
164
- ch.items.forEach((it, i) => {
165
- if (isSchema(it))
166
- pushChild(`[${i}]`, it);
167
- });
168
- }
169
- else if (isSchema(ch.items)) {
170
- pushChild('items', ch.items);
171
- }
172
- if (Array.isArray(ch.options)) {
173
- ch.options.forEach((opt, i) => {
174
- if (isSchema(opt))
175
- pushChild(`option[${i}]`, opt);
176
- });
177
- }
178
- if (ch.properties && typeof ch.properties === 'object') {
179
- for (const [k, v] of Object.entries(ch.properties)) {
180
- if (isSchema(v))
161
+ switch (schema.kind) {
162
+ case 'array': {
163
+ pushChild('element', schema.element);
164
+ break;
165
+ }
166
+ case 'record': {
167
+ pushChild('value', schema.value);
168
+ break;
169
+ }
170
+ case 'object': {
171
+ for (const [k, v] of Object.entries(schema.properties)) {
181
172
  pushChild(k, v);
173
+ }
174
+ break;
175
+ }
176
+ case 'union': {
177
+ schema.options.forEach((opt, i) => pushChild(`option[${i}]`, opt));
178
+ break;
182
179
  }
180
+ case 'tuple': {
181
+ schema.elements.forEach((it, i) => pushChild(`[${i}]`, it));
182
+ break;
183
+ }
184
+ default:
185
+ // 叶子类型:无子节点。
186
+ break;
183
187
  }
184
- if (isSchema(ch.values))
185
- pushChild('values', ch.values);
186
188
  return lines;
187
189
  }
188
- function isSchema(v) {
189
- return !!v && typeof v === 'object' && typeof v.kind === 'string';
190
- }
191
190
  /** 渲染返回值槽位(Schema / VoidMarker / StreamMarker)。 */
192
191
  function renderReturnSlot(slot) {
193
192
  if (slot instanceof VoidMarker)
@@ -309,4 +308,3 @@ export async function invokeLlmTool(repository, call, injections) {
309
308
  })();
310
309
  }
311
310
  }
312
- //# sourceMappingURL=llm-tools.js.map
@@ -2,4 +2,3 @@ import type { MethodDescriptor } from './descriptor.js';
2
2
  import type { Injections } from '../types.js';
3
3
  export declare function checkPermission(descriptor: MethodDescriptor, injections: Injections): Promise<void>;
4
4
  export declare function assertAccessible(descriptor: MethodDescriptor, injections: Injections): Promise<void>;
5
- //# sourceMappingURL=permission.d.ts.map
@@ -26,4 +26,3 @@ export async function assertAccessible(descriptor, injections) {
26
26
  throw error;
27
27
  }
28
28
  }
29
- //# sourceMappingURL=permission.js.map
@@ -1,3 +1,2 @@
1
1
  import type { RPCRequestInput } from '../types.js';
2
2
  export declare function validateRequest(input: unknown): RPCRequestInput;
3
- //# sourceMappingURL=spec-check.d.ts.map
@@ -8,4 +8,3 @@ export function validateRequest(input) {
8
8
  }
9
9
  return result.data;
10
10
  }
11
- //# sourceMappingURL=spec-check.js.map
@@ -1,3 +1,2 @@
1
1
  import type { Repository } from './Repository.js';
2
2
  export declare function registerSystemMethods(repository: Repository): void;
3
- //# sourceMappingURL=system-methods.d.ts.map
@@ -111,4 +111,3 @@ export function registerSystemMethods(repository) {
111
111
  return repository.listLlmTools(injections, rawOptions);
112
112
  });
113
113
  }
114
- //# sourceMappingURL=system-methods.js.map
@@ -6,4 +6,3 @@ export declare class RPCError extends Error {
6
6
  toPayload(): RPCErrorPayload;
7
7
  toJSON(): RPCErrorPayload;
8
8
  }
9
- //# sourceMappingURL=RPCError.d.ts.map
@@ -20,4 +20,3 @@ export class RPCError extends Error {
20
20
  return this.toPayload();
21
21
  }
22
22
  }
23
- //# sourceMappingURL=RPCError.js.map
@@ -4,4 +4,3 @@ export declare const METHOD_NOT_FOUND = -32601;
4
4
  export declare const INVALID_PARAMS = -32602;
5
5
  export declare const INTERNAL_ERROR = -32603;
6
6
  export declare const PERMISSION_DENIED = -32604;
7
- //# sourceMappingURL=codes.d.ts.map
@@ -4,4 +4,3 @@ export const METHOD_NOT_FOUND = -32601;
4
4
  export const INVALID_PARAMS = -32602;
5
5
  export const INTERNAL_ERROR = -32603;
6
6
  export const PERMISSION_DENIED = -32604;
7
- //# sourceMappingURL=codes.js.map
@@ -1,3 +1,2 @@
1
1
  export { RPCError } from './RPCError.js';
2
2
  export * from './codes.js';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,2 @@
1
1
  export { RPCError } from './RPCError.js';
2
2
  export * from './codes.js';
3
- //# sourceMappingURL=index.js.map
package/dist/index.d.ts CHANGED
@@ -15,4 +15,3 @@ export { attachWebSocket, createWebSocketServer, serveStdio };
15
15
  export type { WSOptions, StandaloneWsOptions, StandaloneWsHandle } from './transport/ws/index.js';
16
16
  export type { StdioOptions } from './transport/stdio/index.js';
17
17
  export type { ExpressOptions } from './transport/express/index.js';
18
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -14,4 +14,3 @@ export { createExpressRouter };
14
14
  import { attachWebSocket, createWebSocketServer } from './transport/ws/index.js';
15
15
  import { serveStdio } from './transport/stdio/index.js';
16
16
  export { attachWebSocket, createWebSocketServer, serveStdio };
17
- //# sourceMappingURL=index.js.map
@@ -56,4 +56,3 @@ export interface MemoryMetrics extends RPCMetrics {
56
56
  reset(): void;
57
57
  }
58
58
  export declare function createMemoryMetrics(options?: MemoryMetricsOptions): MemoryMetrics;
59
- //# sourceMappingURL=memory.d.ts.map
@@ -185,4 +185,3 @@ export function createMemoryMetrics(options = {}) {
185
185
  },
186
186
  };
187
187
  }
188
- //# sourceMappingURL=memory.js.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=prom.d.ts.map
@@ -102,4 +102,3 @@
102
102
  // },
103
103
  // };
104
104
  // }
105
- //# sourceMappingURL=prom.js.map
@@ -6,7 +6,7 @@ export declare const s: {
6
6
  boolean: () => import("./primitives.js").BooleanSchema;
7
7
  literal: <const T extends import("./primitives.js").LiteralValue>(value: T) => import("./primitives.js").LiteralSchema<T>;
8
8
  array: <T>(item: import("./primitives.js").Schema<T>) => import("./primitives.js").ArraySchema<T>;
9
- object: <S extends import("./primitives.js").ObjectShape>(shape: S) => import("./primitives.js").ObjectSchema<S, false>;
9
+ object: <S extends import("./primitives.js").ObjectShape>(shape: S) => import("./primitives.js").ObjectSchema<S>;
10
10
  record: <T>(value: import("./primitives.js").Schema<T>) => import("./primitives.js").RecordSchema<T>;
11
11
  union: <const S extends readonly [import("./primitives.js").Schema<unknown>, ...import("./primitives.js").Schema<unknown>[]]>(schemas: S) => import("./primitives.js").UnionSchema<S>;
12
12
  tuple: <const S extends readonly [import("./primitives.js").Schema<unknown>, ...import("./primitives.js").Schema<unknown>[]]>(schemas: S) => import("./primitives.js").TupleSchema<S>;
@@ -17,4 +17,3 @@ export declare const s: {
17
17
  injectable: <const K extends string>(key: K) => import("./marker.js").InjectableMarker<K>;
18
18
  stream: <T>(inner: import("./primitives.js").Schema<T>) => import("./marker.js").StreamMarker<T>;
19
19
  };
20
- //# sourceMappingURL=index.d.ts.map
@@ -3,4 +3,3 @@ import { markers } from "./marker.js";
3
3
  export * from "./primitives.js";
4
4
  export * from "./marker.js";
5
5
  export const s = { ...primitives, ...markers };
6
- //# sourceMappingURL=index.js.map
@@ -20,4 +20,3 @@ export declare const markers: {
20
20
  injectable: <const K extends string>(key: K) => InjectableMarker<K>;
21
21
  stream: <T>(inner: Schema<T>) => StreamMarker<T>;
22
22
  };
23
- //# sourceMappingURL=marker.d.ts.map
@@ -24,4 +24,3 @@ export const markers = {
24
24
  injectable: (key) => new InjectableMarker(key),
25
25
  stream: (inner) => new StreamMarker(inner),
26
26
  };
27
- //# sourceMappingURL=marker.js.map
@@ -9,20 +9,36 @@ export type JSONValue = JSONPrimitive | JSONValue[] | {
9
9
  [key: string]: JSONValue;
10
10
  };
11
11
  export type SchemaKind = string;
12
- export interface SchemaDescription {
12
+ export interface BaseSchemaDescription {
13
13
  kind: SchemaKind;
14
14
  description?: string;
15
- /**
16
- * 该值是否允许为 null。
17
- *
18
- * 唯一真相来源:由 `NullableSchema` 及其子类通过 `.nullable(bool)` 设置,
19
- * `UnknownSchema` / `NullSchema` 不使用该字段(它们本身就接受 null)。
20
- * `kind` 永远表示值的真实形状,不会被 nullability 污染。
21
- */
22
15
  nullable?: boolean;
23
16
  constraints?: Record<string, unknown>;
24
- children?: Record<string, unknown>;
25
17
  }
18
+ export interface LeafSchemaDescription extends BaseSchemaDescription {
19
+ kind: "string" | "number" | "boolean" | "literal" | "enum" | "unknown" | "null";
20
+ }
21
+ export interface ObjectSchemaDescription extends BaseSchemaDescription {
22
+ kind: "object";
23
+ properties: Record<string, SchemaDescription>;
24
+ }
25
+ export interface ArraySchemaDescription extends BaseSchemaDescription {
26
+ kind: "array";
27
+ element: SchemaDescription;
28
+ }
29
+ export interface RecordSchemaDescription extends BaseSchemaDescription {
30
+ kind: "record";
31
+ value: SchemaDescription;
32
+ }
33
+ export interface UnionSchemaDescription extends BaseSchemaDescription {
34
+ kind: "union";
35
+ options: SchemaDescription[];
36
+ }
37
+ export interface TupleSchemaDescription extends BaseSchemaDescription {
38
+ kind: "tuple";
39
+ elements: SchemaDescription[];
40
+ }
41
+ export type SchemaDescription = LeafSchemaDescription | ObjectSchemaDescription | ArraySchemaDescription | RecordSchemaDescription | UnionSchemaDescription | TupleSchemaDescription;
26
42
  export declare class SchemaValidationError extends Error {
27
43
  readonly path: string[];
28
44
  constructor(message: string, path?: string[]);
@@ -36,14 +52,13 @@ export declare class SchemaValidationError extends Error {
36
52
  */
37
53
  export declare abstract class Schema<T> {
38
54
  abstract readonly kind: SchemaKind;
39
- private description?;
40
- constructor(description?: string);
55
+ private description;
41
56
  describe(description: string): this;
42
57
  /**
43
58
  * 创建保留原型和现有字段的新实例,供不可变链式方法使用。
44
59
  */
45
60
  protected cloneWith(updates: Record<string, unknown>): this;
46
- getDescription(): string | undefined;
61
+ getDescription(): string;
47
62
  parse(input: unknown): T;
48
63
  safeParse(input: unknown): {
49
64
  success: true;
@@ -84,7 +99,7 @@ export declare class StringSchema<K extends string = "string"> extends NullableS
84
99
  min(value: number): this;
85
100
  max(value: number): this;
86
101
  protected _parseValue(input: unknown, path: string[]): string;
87
- protected _describe(): SchemaDescription;
102
+ protected _describe(): LeafSchemaDescription;
88
103
  protected validateBound(value: number): void;
89
104
  }
90
105
  export declare class NumberSchema extends NullableSchema<number> {
@@ -95,28 +110,22 @@ export declare class NumberSchema extends NullableSchema<number> {
95
110
  min(value: number): this;
96
111
  max(value: number): this;
97
112
  protected _parseValue(input: unknown, path: string[]): number;
98
- protected _describe(): SchemaDescription;
113
+ protected _describe(): LeafSchemaDescription;
99
114
  protected validateBound(value: number): void;
100
115
  }
101
116
  export declare class BooleanSchema extends NullableSchema<boolean> {
102
117
  readonly kind: "boolean";
103
118
  constructor();
104
119
  protected _parseValue(input: unknown, path: string[]): boolean;
105
- protected _describe(): SchemaDescription;
120
+ protected _describe(): LeafSchemaDescription;
106
121
  }
107
- /**
108
- * 字面量只支持 string / number / boolean。
109
- *
110
- * null 由 `s.null()` 表达;需要「该字面量或 null」时,对字面量调用
111
- * `.nullable()`。`literal(null)` 会抛 TypeError。
112
- */
113
122
  export type LiteralValue = string | number | boolean;
114
123
  export declare class LiteralSchema<const T extends LiteralValue> extends NullableSchema<T> {
115
124
  private readonly expected;
116
125
  readonly kind: "literal";
117
126
  constructor(expected: T);
118
127
  protected _parseValue(input: unknown, path: string[]): T;
119
- protected _describe(): SchemaDescription;
128
+ protected _describe(): LeafSchemaDescription;
120
129
  }
121
130
  export declare class ArraySchema<T> extends NullableSchema<T[]> {
122
131
  private readonly itemSchema;
@@ -127,28 +136,25 @@ export declare class ArraySchema<T> extends NullableSchema<T[]> {
127
136
  min(value: number): this;
128
137
  max(value: number): this;
129
138
  protected _parseValue(input: unknown, path: string[]): T[];
130
- protected _describe(): SchemaDescription;
139
+ protected _describe(): ArraySchemaDescription;
131
140
  protected validateBound(value: number): void;
132
141
  }
133
142
  export type ObjectShape = Record<string, Schema<unknown>>;
134
143
  type SchemaValue<S> = S extends Schema<infer T> ? T : never;
135
- type ShapeOutput<S extends ObjectShape> = {
136
- [K in keyof S]: SchemaValue<S[K]>;
137
- };
138
- type OptionalShapeOutput<S extends ObjectShape> = {
144
+ export type ObjectOutput<S extends ObjectShape> = {
139
145
  [K in keyof S]?: SchemaValue<S[K]>;
140
146
  };
141
- export declare class ObjectSchema<S extends ObjectShape, Strict extends boolean = false> extends NullableSchema<Strict extends true ? ShapeOutput<S> : OptionalShapeOutput<S>> {
147
+ export declare class ObjectSchema<S extends ObjectShape> extends NullableSchema<ObjectOutput<S>> {
142
148
  private readonly shape;
143
149
  readonly kind: "object";
144
- private isStrict;
145
- constructor(shape: S, strict?: Strict, description?: string);
146
- /**
147
- * strict() 要求所有声明属性存在,并拒绝未声明属性。
148
- */
149
- strict(): ObjectSchema<S, true>;
150
- protected _parseValue(input: unknown, path: string[]): Strict extends true ? ShapeOutput<S> : OptionalShapeOutput<S>;
151
- protected _describe(): SchemaDescription;
150
+ private optionalProps;
151
+ private allowUnknownProps;
152
+ constructor(shape: S);
153
+ optionalProperties(keys: string[]): this;
154
+ allowUnknownProperties(value?: boolean): this;
155
+ strict(value?: boolean): this;
156
+ protected _parseValue(input: unknown, path: string[]): ObjectOutput<S>;
157
+ protected _describe(): ObjectSchemaDescription;
152
158
  }
153
159
  export declare class RecordSchema<T> extends NullableSchema<Record<string, T>> {
154
160
  private readonly valueSchema;
@@ -159,68 +165,42 @@ export declare class RecordSchema<T> extends NullableSchema<Record<string, T>> {
159
165
  min(value: number): this;
160
166
  max(value: number): this;
161
167
  protected _parseValue(input: unknown, path: string[]): Record<string, T>;
162
- protected _describe(): SchemaDescription;
168
+ protected _describe(): RecordSchemaDescription;
163
169
  protected validateBound(value: number): void;
164
170
  }
165
- /**
166
- * 联合。
167
- *
168
- * 传入的 member schemas 会被 clone 并 `nullable(false)`——因为「某个
169
- * 分支允许 null」这件事在 union 层面没有意义:null 是否允许应通过
170
- * `union(...).nullable()` 统一表达。
171
- */
172
171
  export declare class UnionSchema<const S extends readonly [Schema<unknown>, ...Schema<unknown>[]]> extends NullableSchema<SchemaValue<S[number]>> {
173
172
  readonly kind: "union";
174
173
  private readonly options;
175
174
  constructor(schemas: S);
176
175
  protected _parseValue(input: unknown, path: string[]): SchemaValue<S[number]>;
177
- protected _describe(): SchemaDescription;
176
+ protected _describe(): UnionSchemaDescription;
178
177
  }
179
178
  export declare class TupleSchema<const S extends readonly [Schema<unknown>, ...Schema<unknown>[]]> extends NullableSchema<SchemaValue<S[number]>[]> {
180
179
  private readonly schemas;
181
180
  readonly kind: "tuple";
182
181
  constructor(schemas: S);
183
182
  protected _parseValue(input: unknown, path: string[]): SchemaValue<S[number]>[];
184
- protected _describe(): SchemaDescription;
183
+ protected _describe(): TupleSchemaDescription;
185
184
  }
186
- /**
187
- * 字符串枚举。
188
- *
189
- * 继承 `NullableSchema`,因此可以 `s.enum([...]).nullable()`;
190
- * 它不包含嵌套 schema,所以不需要像 union 那样处理成员 nullability。
191
- */
192
185
  export declare class EnumSchema<const T extends readonly [string, ...string[]]> extends NullableSchema<T[number]> {
193
186
  private readonly values;
194
187
  readonly kind: "enum";
195
188
  private readonly allowedValues;
196
189
  constructor(values: T);
197
190
  protected _parseValue(input: unknown, path: string[]): T[number];
198
- protected _describe(): SchemaDescription;
191
+ protected _describe(): LeafSchemaDescription;
199
192
  }
200
- /**
201
- * 校验任意 JSON 值。
202
- *
203
- * 不允许 undefined、非有限数字、循环引用等非 JSON 数据。
204
- * null 本身就在接受范围内,因此不继承 `NullableSchema`,也不提供
205
- * `.nullable()`——那是冗余的。
206
- */
207
193
  export declare class UnknownSchema extends Schema<JSONValue> {
208
194
  readonly kind: "unknown";
209
195
  constructor();
210
196
  protected _parse(input: unknown, path: string[]): JSONValue;
211
- protected _describe(): SchemaDescription;
197
+ protected _describe(): LeafSchemaDescription;
212
198
  }
213
- /**
214
- * 精确的 null 值。
215
- *
216
- * 与 `UnknownSchema` 一样天然表达 null,不需要 `.nullable()`。
217
- * 想表达「某类型或 null」用 `.nullable()`;想表达「就是 null」用 `s.null()`。
218
- */
219
199
  export declare class NullSchema extends Schema<null> {
220
200
  readonly kind: "null";
221
201
  constructor();
222
202
  protected _parse(input: unknown, path: string[]): null;
223
- protected _describe(): SchemaDescription;
203
+ protected _describe(): LeafSchemaDescription;
224
204
  }
225
205
  export type Infer<T extends Schema<unknown>> = T extends Schema<infer U> ? U : never;
226
206
  export declare const primitives: {
@@ -229,7 +209,7 @@ export declare const primitives: {
229
209
  boolean: () => BooleanSchema;
230
210
  literal: <const T extends LiteralValue>(value: T) => LiteralSchema<T>;
231
211
  array: <T>(item: Schema<T>) => ArraySchema<T>;
232
- object: <S extends ObjectShape>(shape: S) => ObjectSchema<S, false>;
212
+ object: <S extends ObjectShape>(shape: S) => ObjectSchema<S>;
233
213
  record: <T>(value: Schema<T>) => RecordSchema<T>;
234
214
  union: <const S extends readonly [Schema<unknown>, ...Schema<unknown>[]]>(schemas: S) => UnionSchema<S>;
235
215
  tuple: <const S extends readonly [Schema<unknown>, ...Schema<unknown>[]]>(schemas: S) => TupleSchema<S>;
@@ -238,4 +218,3 @@ export declare const primitives: {
238
218
  null: () => NullSchema;
239
219
  };
240
220
  export {};
241
- //# sourceMappingURL=primitives.d.ts.map