@h-ai/kit 1.0.0-beta.18 → 1.0.0-beta.19

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 (43) hide show
  1. package/README.en.md +53 -33
  2. package/README.ja.md +53 -33
  3. package/README.md +54 -33
  4. package/dist/adapter/index.d.ts +8 -7
  5. package/dist/adapter/index.js.map +1 -1
  6. package/dist/browser.d.ts +9 -26
  7. package/dist/browser.js +4 -4
  8. package/dist/browser.js.map +1 -1
  9. package/dist/{chunk-JRQPMPQC.js → chunk-BCEBXG4X.js} +2 -2
  10. package/dist/chunk-BCEBXG4X.js.map +1 -0
  11. package/dist/{chunk-7EH47MTW.js → chunk-BVGXHIXR.js} +30 -9
  12. package/dist/chunk-BVGXHIXR.js.map +1 -0
  13. package/dist/{chunk-WCMEGLBL.js → chunk-GQZCU6PC.js} +11 -5
  14. package/dist/chunk-GQZCU6PC.js.map +1 -0
  15. package/dist/{chunk-5JW3VW4Q.js → chunk-JL2C5ZGQ.js} +38 -11
  16. package/dist/chunk-JL2C5ZGQ.js.map +1 -0
  17. package/dist/{chunk-6KS67QUS.js → chunk-WYGIKXHE.js} +20 -7
  18. package/dist/chunk-WYGIKXHE.js.map +1 -0
  19. package/dist/client/index.d.ts +6 -5
  20. package/dist/client/index.js +5 -5
  21. package/dist/client/index.js.map +1 -1
  22. package/dist/index.d.ts +18 -711
  23. package/dist/index.js +264 -149
  24. package/dist/index.js.map +1 -1
  25. package/dist/{kit-a2a-types-ikgvWS3T.d.ts → kit-a2a-types-CeDikRAX.d.ts} +3 -2
  26. package/dist/kit-config-CCksTmi5.d.ts +182 -0
  27. package/dist/kit-crypto-types-CqFENBqm.d.ts +47 -0
  28. package/dist/kit-types-BUDaKGB0.d.ts +2057 -0
  29. package/dist/modules/a2a/index.d.ts +9 -5
  30. package/dist/modules/a2a/index.js +1 -1
  31. package/dist/modules/crypto/index.d.ts +8 -105
  32. package/dist/modules/crypto/index.js +3 -149
  33. package/dist/modules/crypto/index.js.map +1 -1
  34. package/package.json +22 -22
  35. package/dist/chunk-5JW3VW4Q.js.map +0 -1
  36. package/dist/chunk-6KS67QUS.js.map +0 -1
  37. package/dist/chunk-7EH47MTW.js.map +0 -1
  38. package/dist/chunk-JRQPMPQC.js.map +0 -1
  39. package/dist/chunk-WCMEGLBL.js.map +0 -1
  40. package/dist/kit-client-auth-DeWmc-1u.d.ts +0 -406
  41. package/dist/kit-crypto-types-Brd0l8Hv.d.ts +0 -204
  42. package/dist/kit-i18n-CjwdGeKY.d.ts +0 -506
  43. package/dist/kit-types-CnfBC89D.d.ts +0 -832
@@ -1,5 +1,5 @@
1
1
  import { RequestEvent } from '@sveltejs/kit';
2
- import { f as HandleA2AOperations, h as HandleConfig } from './kit-types-CnfBC89D.js';
2
+ import { g as HandleA2AOperations, i as HandleConfig } from './kit-types-BUDaKGB0.js';
3
3
 
4
4
  /**
5
5
  * @h-ai/kit — A2A API Key 认证器
@@ -133,4 +133,5 @@ interface KitA2AHandlerConfig {
133
133
  authenticate?: 'apiKey' | ((event: RequestEvent) => Promise<Record<string, unknown> | null | undefined>);
134
134
  }
135
135
 
136
- export { type A2AApiKeyAuthConfig as A, type KitA2AHandlerConfig as K, type ResolvedA2AConfig as R, createA2AApiKeyAuthenticator as c, handleA2ARequest as h, resolveA2AConfig as r };
136
+ export { createA2AApiKeyAuthenticator as c, handleA2ARequest as h, resolveA2AConfig as r };
137
+ export type { A2AApiKeyAuthConfig as A, KitA2AHandlerConfig as K, ResolvedA2AConfig as R };
@@ -0,0 +1,182 @@
1
+ import { o as KitServerConfig, q as KitTransportConfig, m as KitConfigInput, l as KitConfig, r as KitTransportConfigInput } from './kit-types-BUDaKGB0.js';
2
+ import { z } from 'zod';
3
+
4
+ /**
5
+ * @h-ai/kit — 宿主配置
6
+ *
7
+ * 为 `config/_kit.yml` 提供监听、传输与请求策略的默认值和校验。
8
+ * 服务端消费完整配置;浏览器仅接收显式投影的 transport 公共字段。
9
+ * @module kit-config
10
+ */
11
+
12
+ /**
13
+ * `config/_kit.yml` 对应的配置 Schema。
14
+ * @example
15
+ * ```ts
16
+ * import { KitConfigSchema } from '@h-ai/kit'
17
+ *
18
+ * const config = KitConfigSchema.parse({ server: { port: 3000 }, transport: false })
19
+ * void config
20
+ * ```
21
+ */
22
+ declare const KitConfigSchema: z.ZodPipe<z.ZodObject<{
23
+ server: z.ZodOptional<z.ZodObject<{
24
+ host: z.ZodDefault<z.ZodString>;
25
+ port: z.ZodDefault<z.ZodNumber>;
26
+ }, z.core.$strip>>;
27
+ transport: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{
28
+ maxPlaintextBytes: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"auto">]>, z.ZodTransform<number | undefined, number | "auto">>>;
29
+ maxFutureSkewSeconds: z.ZodOptional<z.ZodNumber>;
30
+ maxRequestAgeSeconds: z.ZodOptional<z.ZodNumber>;
31
+ routePlaintextBytes: z.ZodOptional<z.ZodRecord<z.ZodCustom<`/${string}`, `/${string}`>, z.ZodNumber>>;
32
+ keyExchangePath: z.ZodDefault<z.ZodCustom<`/${string}`, `/${string}`>>;
33
+ excludePaths: z.ZodDefault<z.ZodArray<z.ZodCustom<`/${string}`, `/${string}`>>>;
34
+ }, z.core.$strip>]>>;
35
+ trustedProxies: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodArray<z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6, z.ZodCIDRv4, z.ZodCIDRv6]>>]>>;
36
+ access: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{
37
+ file: z.ZodString;
38
+ }, z.core.$strict>, z.ZodObject<{
39
+ global: z.ZodOptional<z.ZodObject<{
40
+ allowIps: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6, z.ZodCIDRv4, z.ZodCIDRv6]>>>;
41
+ denyIps: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6, z.ZodCIDRv4, z.ZodCIDRv6]>>>;
42
+ timezone: z.ZodDefault<z.ZodString>;
43
+ windows: z.ZodDefault<z.ZodArray<z.ZodObject<{
44
+ days: z.ZodArray<z.ZodNumber>;
45
+ start: z.ZodString;
46
+ end: z.ZodString;
47
+ }, z.core.$strict>>>;
48
+ }, z.core.$strict>>;
49
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
50
+ allowIps: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6, z.ZodCIDRv4, z.ZodCIDRv6]>>>;
51
+ denyIps: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6, z.ZodCIDRv4, z.ZodCIDRv6]>>>;
52
+ timezone: z.ZodDefault<z.ZodString>;
53
+ windows: z.ZodDefault<z.ZodArray<z.ZodObject<{
54
+ days: z.ZodArray<z.ZodNumber>;
55
+ start: z.ZodString;
56
+ end: z.ZodString;
57
+ }, z.core.$strict>>>;
58
+ id: z.ZodString;
59
+ paths: z.ZodArray<z.ZodString>;
60
+ methods: z.ZodDefault<z.ZodArray<z.ZodEnum<{
61
+ GET: "GET";
62
+ HEAD: "HEAD";
63
+ POST: "POST";
64
+ PUT: "PUT";
65
+ PATCH: "PATCH";
66
+ DELETE: "DELETE";
67
+ OPTIONS: "OPTIONS";
68
+ CONNECT: "CONNECT";
69
+ TRACE: "TRACE";
70
+ }>>>;
71
+ encryption: z.ZodOptional<z.ZodEnum<{
72
+ required: "required";
73
+ disabled: "disabled";
74
+ }>>;
75
+ }, z.core.$strict>>>;
76
+ }, z.core.$strict>]>>;
77
+ }, z.core.$strip>, z.ZodTransform<{
78
+ server: KitServerConfig;
79
+ transport: false | KitTransportConfig;
80
+ trustedProxies: "auto" | string[];
81
+ access: false | {
82
+ file: string;
83
+ } | {
84
+ rules: {
85
+ allowIps: string[];
86
+ denyIps: string[];
87
+ timezone: string;
88
+ windows: {
89
+ days: number[];
90
+ start: string;
91
+ end: string;
92
+ }[];
93
+ id: string;
94
+ paths: string[];
95
+ methods: ("GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "CONNECT" | "TRACE")[];
96
+ encryption?: "required" | "disabled" | undefined;
97
+ }[];
98
+ global?: {
99
+ allowIps: string[];
100
+ denyIps: string[];
101
+ timezone: string;
102
+ windows: {
103
+ days: number[];
104
+ start: string;
105
+ end: string;
106
+ }[];
107
+ } | undefined;
108
+ };
109
+ }, {
110
+ trustedProxies: "auto" | string[];
111
+ access: false | {
112
+ file: string;
113
+ } | {
114
+ rules: {
115
+ allowIps: string[];
116
+ denyIps: string[];
117
+ timezone: string;
118
+ windows: {
119
+ days: number[];
120
+ start: string;
121
+ end: string;
122
+ }[];
123
+ id: string;
124
+ paths: string[];
125
+ methods: ("GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "CONNECT" | "TRACE")[];
126
+ encryption?: "required" | "disabled" | undefined;
127
+ }[];
128
+ global?: {
129
+ allowIps: string[];
130
+ denyIps: string[];
131
+ timezone: string;
132
+ windows: {
133
+ days: number[];
134
+ start: string;
135
+ end: string;
136
+ }[];
137
+ } | undefined;
138
+ };
139
+ server?: {
140
+ host: string;
141
+ port: number;
142
+ } | undefined;
143
+ transport?: false | {
144
+ keyExchangePath: `/${string}`;
145
+ excludePaths: `/${string}`[];
146
+ maxPlaintextBytes?: number | undefined;
147
+ maxFutureSkewSeconds?: number | undefined;
148
+ maxRequestAgeSeconds?: number | undefined;
149
+ routePlaintextBytes?: Record<`/${string}`, number> | undefined;
150
+ } | undefined;
151
+ }>>;
152
+ /**
153
+ * 解析 transport 配置并补齐默认值。
154
+ *
155
+ * @param input - `config/_kit.yml` 中的 transport 配置
156
+ * @returns 完整 transport 配置;`false` 表示关闭
157
+ * @example
158
+ * ```ts
159
+ * import { resolveKitTransportConfig } from '@h-ai/kit'
160
+ *
161
+ * const transport = resolveKitTransportConfig({ excludePaths: ['/api/health'] })
162
+ * if (transport) void transport.keyExchangePath
163
+ * ```
164
+ */
165
+ declare function resolveKitTransportConfig(input?: false | KitTransportConfigInput): false | KitTransportConfig;
166
+ /**
167
+ * 解析 `config/_kit.yml` 顶层配置并补齐默认值。
168
+ *
169
+ * 适合同一份配置同时供 SvelteKit 服务端 hook 与浏览器端 client 读取。
170
+ * @param input - Kit 监听和公开 transport 输入;省略字段按 Schema 补默认值。
171
+ * @returns 已补齐默认值的配置;不合法输入抛出 ZodError。
172
+ * @example
173
+ * ```ts
174
+ * import { resolveKitConfig } from '@h-ai/kit'
175
+ *
176
+ * const config = resolveKitConfig({ transport: false })
177
+ * void config.server.port
178
+ * ```
179
+ */
180
+ declare function resolveKitConfig(input?: KitConfigInput): KitConfig;
181
+
182
+ export { KitConfigSchema as K, resolveKitTransportConfig as a, resolveKitConfig as r };
@@ -0,0 +1,47 @@
1
+ import { TransportServerKeyRing, CryptoFunctions, TransportKeyStore } from '@h-ai/crypto';
2
+
3
+ /**
4
+ * @h-ai/kit — 传输加密类型定义
5
+ *
6
+ * 仅复用 @h-ai/crypto 的真实公开能力。
7
+ * @module kit-crypto-types
8
+ */
9
+
10
+ /**
11
+ * 传输加密配置。
12
+ *
13
+ * kit 不再维护本地加解密实现;服务端管理器由 `crypto.transport.createServer()` 创建,
14
+ * 协议常量与载荷类型统一来自 `@h-ai/crypto`。
15
+ * @example
16
+ * ```ts
17
+ * import type { TransportEncryptionConfig } from '@h-ai/kit'
18
+ *
19
+ * function publicPaths(config: TransportEncryptionConfig) { return config.excludePaths ?? [] }
20
+ * ```
21
+ */
22
+ interface TransportEncryptionConfig {
23
+ /** 宿主构建挂载目录,默认空字符串;仅作用于 API/data 保护范围。 */
24
+ basePath?: string;
25
+ /** 双向业务明文 UTF-8 字节上限;默认 1 MiB,整数范围 1 KiB~64 MiB。 */
26
+ maxPlaintextBytes?: number;
27
+ /** 请求时间允许领先服务器的秒数,默认 30,整数范围 0~300。 */
28
+ maxFutureSkewSeconds?: number;
29
+ /** 请求从签发起的有效秒数,默认 300,整数范围 1~600。 */
30
+ maxRequestAgeSeconds?: number;
31
+ /** 路由明文容量;* 匹配一个完整路径段。 */
32
+ routePlaintextBytes?: Readonly<Record<string, number>>;
33
+ /** 受管服务端密钥环,仅从服务端 Secret 注入,不放公开 kit 配置。 */
34
+ serverKeyRing: TransportServerKeyRing;
35
+ /** 是否启用传输加密(默认 false) */
36
+ enabled: boolean;
37
+ /** @h-ai/crypto 服务实例 */
38
+ crypto: CryptoFunctions;
39
+ /** 密钥交换端点路径(默认 `/api/_hai/key-exchange`) */
40
+ keyExchangePath?: string;
41
+ /** 排除路径(不加密),支持精确匹配和前缀匹配 */
42
+ excludePaths?: readonly string[];
43
+ /** 显式客户端公钥存储;生产使用共享 Redis/reldb,内存仅供开发/测试。 */
44
+ keyStore: TransportKeyStore;
45
+ }
46
+
47
+ export type { TransportEncryptionConfig as T };