@h-ai/cli 0.1.0-alpha.24 → 0.1.0-alpha.26
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.26",
|
|
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.26"
|
|
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.26",
|
|
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}}"],
|
|
@@ -50,6 +50,7 @@ llm:
|
|
|
50
50
|
baseUrl: ${HAI_AI_LLM_BASE_URL:https://api.openai.com/v1}
|
|
51
51
|
model: ${HAI_AI_LLM_MODEL:gpt-4o-mini}
|
|
52
52
|
timeout: 60000
|
|
53
|
+
tempModelCacheTtl: 600000 # 临时模型客户端缓存 TTL(毫秒,默认 10 分钟)
|
|
53
54
|
scenarios:
|
|
54
55
|
chat: fast
|
|
55
56
|
reasoning: strong
|
|
@@ -76,6 +77,7 @@ knowledge:
|
|
|
76
77
|
| --- | --- | --- |
|
|
77
78
|
| 非流式对话 | `ai.llm.chat({ messages })` | OpenAI 兼容 Chat Completion |
|
|
78
79
|
| 流式对话 | `ai.llm.chatStream({ messages })` | 返回 `AsyncIterable` |
|
|
80
|
+
| 临时模型 | `ai.llm.chat({ messages, tempModel })` | 单次请求级临时端点,客户端按 TTL 缓存 |
|
|
79
81
|
| 工具定义 | `ai.tools.define(...)` | Zod schema 转 JSON Schema |
|
|
80
82
|
| 工具执行 | `registry.executeAll(toolCalls)` | 支持并行执行 |
|
|
81
83
|
| MCP 服务 | `createMcpServer(...)` | 按需连接 HTTP/SSE/Stdio transport |
|
|
@@ -124,6 +126,30 @@ for await (const chunk of ai.llm.chatStream({ messages })) {
|
|
|
124
126
|
const message = processor.toAssistantMessage()
|
|
125
127
|
```
|
|
126
128
|
|
|
129
|
+
## 临时模型(tempModel)
|
|
130
|
+
|
|
131
|
+
单次请求级别绕过配置注册模型,直接指定端点与凭据;适用于运行时动态切换模型、多租户各带凭据。
|
|
132
|
+
`chat` / `chatStream` / `ask` / `askStream` 均支持。未指定字段回退全局 LLM 配置 / 环境变量;
|
|
133
|
+
请求显式 `max_tokens` / `temperature` 优先于 `tempModel.maxTokens` / `temperature`。
|
|
134
|
+
临时客户端按 `apiKey+baseUrl+timeout` 缓存,TTL 默认 10 分钟(`llm.tempModelCacheTtl` 毫秒,可配置),与常驻模型客户端隔离。
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
const result = await ai.llm.chat({
|
|
138
|
+
messages: [{ role: 'user', content: '你好' }],
|
|
139
|
+
tempModel: {
|
|
140
|
+
model: 'claude-3-5-sonnet',
|
|
141
|
+
apiKey: 'sk-temp-xxx',
|
|
142
|
+
baseUrl: 'https://temp.endpoint/v1',
|
|
143
|
+
maxTokens: 2048, // 可选
|
|
144
|
+
temperature: 0.3, // 可选
|
|
145
|
+
timeout: 30000, // 可选
|
|
146
|
+
},
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
// ask 便捷方法同样支持
|
|
150
|
+
await ai.llm.ask('翻译这段话', { tempModel: { model: 'gpt-4o', apiKey: 'sk-xxx' } })
|
|
151
|
+
```
|
|
152
|
+
|
|
127
153
|
## MCP 服务器
|
|
128
154
|
|
|
129
155
|
```ts
|
|
@@ -73,7 +73,10 @@ description: 使用 @h-ai/ui 构建多端应用界面,包含三层组件架构
|
|
|
73
73
|
| 后台列表页 | `PageHeader` + `Card` + `DataTable` + `Pagination` | 分页、筛选、批量操作优先复用 compounds |
|
|
74
74
|
| 表单页/弹层表单 | `Form` + `FormField` + `Input/Select/...` | 表单字段布局统一交给 `FormField` |
|
|
75
75
|
| 简单确认/详情弹层 | `Modal` / `Drawer` / `Confirm` | 根据桌面/移动端交互选择弹窗或抽屉 |
|
|
76
|
-
| 完整 CRUD 页面 | `CrudPage` | 优先通过 `form` / `pagination` / `density`
|
|
76
|
+
| 完整 CRUD 页面 | `CrudPage` | 优先通过 `form` / `pagination` / `density` 配置,不要拆开重写;列头默认可排序、筛选栏自带「重置」 |
|
|
77
|
+
| 错误页(401/403/404/500/503) | `ErrorPage` | SvelteKit `+error.svelte` 中按 `page.status` 使用,`onhome`/`onback` 接管跳转 |
|
|
78
|
+
| 设置页 | `SettingsLayout` | 分区导航 + 内容区;`sections` + `active` + `onselect`,内容放入 children |
|
|
79
|
+
| 登录/注册页布局 | `AuthShell` + `LoginForm` / `RegisterForm` | `variant='card'` 或 `'split'`;split 可通过 `illustration`/`description`/`highlights` 放大图与重点说明 |
|
|
77
80
|
| 登录/注册/资料页 | `LoginForm` / `RegisterForm` / `UserProfile` | 页面只负责路由和提交逻辑 |
|
|
78
81
|
| 文件/图片上传 | `FileUpload` / `ImageUpload` / `AvatarUpload` | 上传 URL、限制和业务状态由应用层提供 |
|
|
79
82
|
| 移动端页面骨架 | `SafeArea` + `AppBar` + `BottomNav` | 原生壳页面优先这一套 |
|
|
@@ -267,12 +270,12 @@ const p = usePlatform()
|
|
|
267
270
|
| `FormField` | `label`, `name`, `error`, `hint`, `required` | 表单字段 |
|
|
268
271
|
| `Modal` | `open`, `title`, `size`, `closeOnBackdrop` | 模态框 |
|
|
269
272
|
| `Drawer` | `open`, `position`, `size` | 抽屉 |
|
|
270
|
-
| `DataTable` | `data`, `columns`, `keyField`, snippet slots
|
|
273
|
+
| `DataTable` | `data`, `columns`, `keyField`, `sortKey`, `sortDir`, `onsort`, snippet slots | 数据表格(列定义 `sortable` 可排序) |
|
|
271
274
|
| `Combobox` | `options`, `value`, `multiple`, `placeholder`, `error`, `onchange` | 可搜索选择 |
|
|
272
275
|
| `Calendar` | `value`, `minValue`, `maxValue` | 独立日历 |
|
|
273
276
|
| `DatePicker` | `value`, `minValue`, `maxValue`, `error` | 日期输入+弹出 |
|
|
274
277
|
| `Tabs` | `items: TabItem[]`, `active`, `type` | 标签页 |
|
|
275
|
-
| `Pagination` | `page`, `total`, `pageSize`, `onchange`
|
|
278
|
+
| `Pagination` | `page`, `total`, `pageSize`, `showTotal`, `showJumper`, `showSizeChanger`, `onchange` | 分页(统一为 shadcn table 风格) |
|
|
276
279
|
| `Dropdown` | `items: DropdownItem[]`, `trigger` | 下拉菜单 |
|
|
277
280
|
| `Accordion` | `items: AccordionItem[]` | 折叠面板 |
|
|
278
281
|
| `Skeleton` | `variant`, `count`, `animation` | 骨架屏 |
|
|
@@ -356,10 +359,18 @@ const p = usePlatform()
|
|
|
356
359
|
|
|
357
360
|
| 组件 | Props 要点 | 说明 |
|
|
358
361
|
| -------------- | ----------------------------------------------- | -------- |
|
|
362
|
+
| `AuthShell` | `variant`('card'/'split'), `title`, `brandTitle`, `brandText`, `illustration`, `description`, `highlights` | 认证页布局(包裹登录/注册表单) |
|
|
359
363
|
| `LoginForm` | `showRememberMe`, `showRegisterLink`, `errors` | 登录表单 |
|
|
360
364
|
| `RegisterForm` | `fields`, `minPasswordLength`, `errors` | 注册表单 |
|
|
361
365
|
| `UserProfile` | `user`, `editable`, `fields`, `avatarUploadUrl` | 用户资料 |
|
|
362
366
|
|
|
367
|
+
#### 错误页 / 设置场景组件
|
|
368
|
+
|
|
369
|
+
| 组件 | Props 要点 | 说明 |
|
|
370
|
+
| ---------------- | ------------------------------------------- | -------- |
|
|
371
|
+
| `ErrorPage` | `status`, `code`, `title`, `description`, `homeUrl`, `onhome`, `onback` | 通用错误页(内置 401/403/404/500/503) |
|
|
372
|
+
| `SettingsLayout` | `title`, `description`, `sections`, `active`, `onselect` | 设置页分区导航布局 |
|
|
373
|
+
|
|
363
374
|
#### Storage 场景组件
|
|
364
375
|
|
|
365
376
|
| 组件 | Props 要点 | 说明 |
|