@h-ai/cli 0.1.0-alpha.48 → 0.1.0-alpha.49
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.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-ai/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.0-alpha.
|
|
4
|
+
"version": "0.1.0-alpha.49",
|
|
5
5
|
"description": "Hai Framework CLI for project scaffolding and code generation.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"keywords": [
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"ora": "^9.1.0",
|
|
35
35
|
"prompts": "^2.4.2",
|
|
36
36
|
"yaml": "^2.7.0",
|
|
37
|
-
"@h-ai/core": "0.1.0-alpha.
|
|
37
|
+
"@h-ai/core": "0.1.0-alpha.49"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "{{projectName}}",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.49",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "{{#if_eq appType 'admin'}}Enterprise management system built with hai Agent Framework{{/if_eq}}{{#if_eq appType 'website'}}Enterprise website built with hai Agent Framework{{/if_eq}}{{#if_eq appType 'h5'}}Mobile H5 app built with hai Agent Framework{{/if_eq}}{{#if_eq appType 'api'}}REST API service built with hai Agent Framework{{/if_eq}}{{#if_eq appType 'mobile-app'}}Mobile app built with hai Agent Framework{{/if_eq}}",
|
|
6
6
|
"keywords": ["hai", {{#unless isSvelteOnlyApp}}"sveltekit", {{/unless}}"svelte5", "{{appType}}"],
|
|
@@ -202,6 +202,7 @@ await ai.llm.ask('翻译这段话', { tempModel: { model: 'gpt-4o', apiKey: 'sk-
|
|
|
202
202
|
|
|
203
203
|
```ts
|
|
204
204
|
import { createMcpServer, StreamableHTTPServerTransport } from '@h-ai/ai'
|
|
205
|
+
import { core } from '@h-ai/core'
|
|
205
206
|
|
|
206
207
|
const server = createMcpServer({ name: 'my-server', version: '1.0.0' })
|
|
207
208
|
server.registerTool('search', {
|
|
@@ -211,7 +212,7 @@ server.registerTool('search', {
|
|
|
211
212
|
content: [{ type: 'text', text: `Results for ${query}` }],
|
|
212
213
|
}))
|
|
213
214
|
|
|
214
|
-
await server.connect(new StreamableHTTPServerTransport({ sessionIdGenerator:
|
|
215
|
+
await server.connect(new StreamableHTTPServerTransport({ sessionIdGenerator: core.id.uuid }))
|
|
215
216
|
```
|
|
216
217
|
|
|
217
218
|
## 记忆、RAG 与知识库
|
|
@@ -233,7 +233,7 @@ export async function createArticle(input: CreateArticleInput): Promise<HaiResul
|
|
|
233
233
|
logger.debug('Creating article', { title: input.title })
|
|
234
234
|
|
|
235
235
|
const result = await reldb.crud.create('articles', {
|
|
236
|
-
id:
|
|
236
|
+
id: core.id.uuid(),
|
|
237
237
|
...input,
|
|
238
238
|
created_at: new Date().toISOString(),
|
|
239
239
|
})
|
|
@@ -316,6 +316,14 @@ core.id.isValidUUID('f47ac10b-...') // true/false
|
|
|
316
316
|
core.id.isValidNanoId('abc123', 6) // true/false
|
|
317
317
|
```
|
|
318
318
|
|
|
319
|
+
#### UUID 生成规范(强制)
|
|
320
|
+
|
|
321
|
+
- 生成 UUID **一律用 `core.id.uuid()`**,禁止裸调 `crypto.randomUUID()`。
|
|
322
|
+
- 原因:`crypto.randomUUID` 仅在**安全上下文(HTTPS / localhost)**下可用,生产 http 环境会抛
|
|
323
|
+
`crypto.randomUUID is not a function`;`core.id.uuid()` 已做 `randomUUID → getRandomValues → Math.random` 三级兜底,Node.js 与浏览器通用。
|
|
324
|
+
- 需要不带横线的 compact 形式:`core.id.uuid().replaceAll('-', '')`。
|
|
325
|
+
- 代码评审与新建代码时以此为准,发现裸调 `crypto.randomUUID()` 一律改走 `core.id.uuid()`。
|
|
326
|
+
|
|
319
327
|
### 工具函数
|
|
320
328
|
|
|
321
329
|
#### 类型检查 — `core.typeUtils`
|
|
@@ -307,7 +307,7 @@ class UserRepository extends BaseReldbCrudRepository<User> {
|
|
|
307
307
|
**自动能力**:
|
|
308
308
|
|
|
309
309
|
- `createdAt` / `updatedAt` 字段自动填充时间戳
|
|
310
|
-
- 主键生成(非 autoIncrement
|
|
310
|
+
- 主键生成(非 autoIncrement 主键默认使用随机 UUID,底层带安全上下文守卫,不可用时回退;业务侧手动生成 UUID 一律用 `core.id.uuid()`)
|
|
311
311
|
- BOOLEAN → 1/0(SQLite/MySQL)或 true/false(PostgreSQL)
|
|
312
312
|
- TIMESTAMP → 毫秒时间戳(SQLite)或 Date(PG/MySQL)
|
|
313
313
|
- JSON → 字符串序列化(SQLite/MySQL)或原生 JSONB(PG)
|