@digiwin-aimk/agent-market 0.0.0-stage → 0.1.0
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/README.md +79 -2
- package/dist/AimkDetail.d.ts +5 -0
- package/dist/AimkIndex.d.ts +6 -0
- package/dist/AimkMain.d.ts +17 -0
- package/dist/agents.d.ts +34 -0
- package/dist/components/AgentCard.d.ts +9 -0
- package/dist/components/AgentFilter.d.ts +15 -0
- package/dist/components/FeaturedCarousel.d.ts +8 -0
- package/dist/components/SortBar.d.ts +9 -0
- package/dist/components/category.d.ts +3 -0
- package/dist/i18n.d.ts +7 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +1034 -0
- package/dist/locales.d.ts +8 -0
- package/dist/repository/aimk-agent-repository.d.ts +175 -0
- package/dist/repository/forward-http.d.ts +49 -0
- package/dist/repository/index.d.ts +2 -0
- package/dist/sdk.d.ts +36 -0
- package/dist/use-aimk-t.d.ts +7 -0
- package/package.json +43 -4
package/README.md
CHANGED
|
@@ -1,3 +1,80 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @digiwin-aimk/agent-market
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
AIMK 智能体市场 SDK:提供智能体列表与详情视图,可嵌入任意 React 宿主应用。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @digiwin-aimk/agent-market
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 使用
|
|
12
|
+
|
|
13
|
+
### 组件形式(React 宿主)
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import AimkMain, { setForwardConfig } from '@digiwin-aimk/agent-market';
|
|
17
|
+
|
|
18
|
+
// 方式一:渲染前全局注入中转配置
|
|
19
|
+
setForwardConfig({
|
|
20
|
+
forwardBaseUrl: 'https://<座舱中转网关>',
|
|
21
|
+
appId: '<应用 id>',
|
|
22
|
+
mode: 'forward',
|
|
23
|
+
marketBridgeUrl: 'https://<云市场中间层地址>', // 必填,购买/咨询/试用依赖此地址
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// 方式二(等价):通过 props 注入
|
|
27
|
+
<AimkMain forwardConfig={{ forwardBaseUrl: '...', appId: '...', mode: 'forward' }} />
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### new 实例形式(非 React 宿主 / 动态挂载)
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
import { AimkSDK } from '@digiwin-aimk/agent-market';
|
|
34
|
+
|
|
35
|
+
const sdk = new AimkSDK({
|
|
36
|
+
container: '#app', // DOM 元素或 CSS 选择器,缺省 document.body
|
|
37
|
+
forwardConfig: { forwardBaseUrl: '...', appId: '...', mode: 'forward' },
|
|
38
|
+
locale: 'zh-TW', // UI 文案语言:'zh-CN'(默认)| 'zh-TW' | 'en-US'
|
|
39
|
+
onSelectAgent: (agent) => console.log('选中:', agent.name),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
sdk.mount(); // 挂载渲染
|
|
43
|
+
sdk.update({ forwardConfig: { ... } }); // 更新配置并重渲染
|
|
44
|
+
sdk.destroy(); // 卸载并释放资源(可再次 mount)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 中转模式说明
|
|
48
|
+
|
|
49
|
+
- `mode: 'forward'`(默认/生产):所有接口经座舱中转接口
|
|
50
|
+
`POST /restful/standard/digiSpace/v1/isv/curl/forward` 代理调用,座舱按 `appId` 查环境变量中的 host。
|
|
51
|
+
- `mode: 'direct'`(联调):直连目标网关,需提供 `directBaseUrl`,`token` 会作为 `digi-middleware-auth-user` 请求头透传。
|
|
52
|
+
|
|
53
|
+
## API 导出
|
|
54
|
+
|
|
55
|
+
| 导出 | 说明 |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| `AimkMain`(默认) | React 组件入口,内部管理列表/详情切换 |
|
|
58
|
+
| `AimkSDK` | 命令式实例类:`new AimkSDK(options).mount()`,非 React 宿主使用 |
|
|
59
|
+
| `AimkIndex` | 仅智能体列表,需传入 `onSelectAgent` 回调 |
|
|
60
|
+
| `AimkDetail` | 智能体详情视图 |
|
|
61
|
+
| `setForwardConfig` / `getForwardConfig` | 注入/读取中转配置(须在首次接口调用前完成注入) |
|
|
62
|
+
| `ForwardConfig` | 中转配置类型 |
|
|
63
|
+
| `AimkLocale` | 语言类型(`'zh-CN' \| 'zh-TW' \| 'en-US'`) |
|
|
64
|
+
| `AimkLocaleProvider` / `useAimkT` | SDK 内部文案作用域/翻译函数(高级用法,宿主自定义语言环境) |
|
|
65
|
+
| `Agent` / `SortKey` | 业务类型 |
|
|
66
|
+
|
|
67
|
+
## 本地构建
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pnpm install # 或 npm install
|
|
71
|
+
pnpm build # 产出 dist/index.js(样式已内联注入)+ dist/index.d.ts
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 发布
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm publish --access public --registry https://registry.npmjs.com
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
> 注意:包发布在 `@digiwin-aimk` scope 下,需先在 npmjs 注册同名 org(public 包免费):`npm org create digiwin-aimk`,或在 npmjs 网页端创建后将维护者账号加入成员。后续 aimk 系列功能包统一放在 `@digiwin-aimk/*`。
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Agent } from './agents';
|
|
2
|
+
import { AimkLocale } from './locales';
|
|
3
|
+
import { ForwardConfig } from './repository/forward-http';
|
|
4
|
+
export interface AimkMainProps {
|
|
5
|
+
/** 中转配置(可选):传入后挂载时注入,等价于外部先调 setForwardConfig() */
|
|
6
|
+
forwardConfig?: ForwardConfig;
|
|
7
|
+
/** UI 文案语言(可选):'zh-CN'(默认)| 'zh-TW' | 'en-US' */
|
|
8
|
+
locale?: AimkLocale;
|
|
9
|
+
/** 默认选中的智能体(可选,进入时直接打开详情) */
|
|
10
|
+
initialAgent?: Agent | null;
|
|
11
|
+
/** 点击智能体时的回调(可选,SDK 仅通知,列表/详情切换仍由内部管理) */
|
|
12
|
+
onSelectAgent?: (agent: Agent) => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 主層:模擬路由入口,分發 index(列表)與 detail(詳情)
|
|
16
|
+
*/
|
|
17
|
+
export default function AimkMain({ forwardConfig, locale, initialAgent, onSelectAgent }: AimkMainProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/agents.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type SortKey = 'default' | 'hot' | 'latest';
|
|
2
|
+
export interface SortOption {
|
|
3
|
+
key: SortKey;
|
|
4
|
+
/** UI 顯示文案 */
|
|
5
|
+
label: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const SORTS: SortOption[];
|
|
8
|
+
export interface AgentTag {
|
|
9
|
+
label: string;
|
|
10
|
+
tone: 'expert' | 'industry' | 'other';
|
|
11
|
+
}
|
|
12
|
+
export interface Agent {
|
|
13
|
+
id: string;
|
|
14
|
+
/** 智能體編碼(詳情等介面的入參) */
|
|
15
|
+
code: string;
|
|
16
|
+
name: string;
|
|
17
|
+
supplier: string;
|
|
18
|
+
/** 服务商 id(详情页查询服务商信息入参) */
|
|
19
|
+
servicerId?: string;
|
|
20
|
+
description: string;
|
|
21
|
+
/** 智能體 logo 圖片 URL */
|
|
22
|
+
logo?: string;
|
|
23
|
+
tags: AgentTag[];
|
|
24
|
+
/** 熱門標記 */
|
|
25
|
+
hot: boolean;
|
|
26
|
+
/** 熱門度排序值(目前取 useCount) */
|
|
27
|
+
hotScore: number;
|
|
28
|
+
/** 使用次數 */
|
|
29
|
+
useCount?: number;
|
|
30
|
+
/** 價格 */
|
|
31
|
+
price?: number;
|
|
32
|
+
/** 計價單位名稱 */
|
|
33
|
+
paymentTypeName?: string;
|
|
34
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Agent } from '../agents';
|
|
2
|
+
export interface AgentCardProps {
|
|
3
|
+
agent: Agent;
|
|
4
|
+
selected?: boolean;
|
|
5
|
+
onSelect?: () => void;
|
|
6
|
+
/** 是否顯示熱門角標 */
|
|
7
|
+
showHot?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export default function AgentCard({ agent, selected, onSelect, showHot }: AgentCardProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AgentCategoryNode } from '../repository';
|
|
2
|
+
export interface AgentFilterProps {
|
|
3
|
+
categoryTree: AgentCategoryNode[];
|
|
4
|
+
/** 分類樹載入中 */
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
/** 選中的分類節點 key */
|
|
7
|
+
selectedKeys: number[];
|
|
8
|
+
onToggleKey: (key: number) => void;
|
|
9
|
+
/** 清除指定的分類 key(「全部」按鈕傳該行全部選項 key,清空按鈕傳全部已選 key) */
|
|
10
|
+
onClearKeys: (keys: number[]) => void;
|
|
11
|
+
keyword: string;
|
|
12
|
+
onKeywordChange: (keyword: string) => void;
|
|
13
|
+
}
|
|
14
|
+
/** 智能體篩選卡:關鍵字搜尋 + 分類篩選 + 已選條件 */
|
|
15
|
+
export default function AgentFilter({ categoryTree, loading, selectedKeys, onToggleKey, onClearKeys, keyword, onKeywordChange }: AgentFilterProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Agent } from '../agents';
|
|
2
|
+
export interface FeaturedCarouselProps {
|
|
3
|
+
agents: Agent[];
|
|
4
|
+
loading?: boolean;
|
|
5
|
+
onSelectAgent: (agent: Agent) => void;
|
|
6
|
+
}
|
|
7
|
+
/** 精選智能體輪播(內部維護翻頁索引) */
|
|
8
|
+
export default function FeaturedCarousel({ agents, loading, onSelectAgent }: FeaturedCarouselProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SortKey } from '../agents';
|
|
2
|
+
export interface SortBarProps {
|
|
3
|
+
/** 智能體總數(服務端統計) */
|
|
4
|
+
total: number;
|
|
5
|
+
sortKey: SortKey;
|
|
6
|
+
onSortChange: (key: SortKey) => void;
|
|
7
|
+
}
|
|
8
|
+
/** 結果列:總數 + 排序切換 */
|
|
9
|
+
export default function SortBar({ total, sortKey, onSortChange }: SortBarProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AimkLocale } from './locales';
|
|
3
|
+
/** 语言作用域:包住 SDK 视图,为内部组件提供文案语言 */
|
|
4
|
+
export declare function AimkLocaleProvider({ locale, children }: {
|
|
5
|
+
locale?: AimkLocale;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @digiwin-aimk/agent-market 公共 API
|
|
3
|
+
*
|
|
4
|
+
* 样式已随 JS 运行时注入,无需单独引入 CSS。
|
|
5
|
+
*
|
|
6
|
+
* 组件形式:
|
|
7
|
+
* import AimkMain, { setForwardConfig, type ForwardConfig } from '@digiwin-aimk/agent-market';
|
|
8
|
+
*
|
|
9
|
+
* new 实例形式(非 React 宿主):
|
|
10
|
+
* import { AimkSDK } from '@digiwin-aimk/agent-market';
|
|
11
|
+
* const sdk = new AimkSDK({ container: '#app', forwardConfig }).mount();
|
|
12
|
+
*/
|
|
13
|
+
export { default } from './AimkMain';
|
|
14
|
+
export { AimkSDK, type AimkSDKOptions } from './sdk';
|
|
15
|
+
export { default as AimkIndex } from './AimkIndex';
|
|
16
|
+
export { default as AimkDetail } from './AimkDetail';
|
|
17
|
+
export { setForwardConfig, getForwardConfig } from './repository/forward-http';
|
|
18
|
+
export type { ForwardConfig } from './repository/forward-http';
|
|
19
|
+
export type { Agent, SortKey } from './agents';
|
|
20
|
+
export type { AimkLocale } from './locales';
|
|
21
|
+
export { AimkLocaleProvider } from './i18n';
|
|
22
|
+
export { useAimkT } from './use-aimk-t';
|
|
23
|
+
export type { AimkTFunc } from './use-aimk-t';
|