@digiwin-aimk/agent-market 0.0.0-stage → 0.1.1

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 CHANGED
@@ -1,3 +1,57 @@
1
- # Temporary Holding Version
1
+ # @digiwin-aimk/agent-market
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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
+ token: '<外层鉴权 token>', // 可选
23
+ mode: 'forward',
24
+ marketBridgeUrl: 'https://<云市场中间层地址>', // 必填,购买/咨询/试用经此地址 postMessage 通行
25
+ });
26
+
27
+ // 方式二(等价):通过 props 注入
28
+ <AimkMain
29
+ forwardConfig={{ forwardBaseUrl: '...', appId: '...', mode: 'forward' }}
30
+ locale="zh-CN" // 可选:'zh-CN'(默认)| 'zh-TW' | 'en-US'
31
+ initialAgent={null} // 可选:进入时直接打开某智能体详情
32
+ onSelectAgent={(agent) => {}} // 可选:点击智能体回调
33
+ />
34
+ ```
35
+
36
+ ### new 实例形式(非 React 宿主 / 动态挂载)
37
+
38
+ ```js
39
+ import { AimkSDK } from '@digiwin-aimk/agent-market';
40
+
41
+ const sdk = new AimkSDK({
42
+ container: '#app', // DOM 元素或 CSS 选择器,缺省 document.body
43
+ forwardConfig: { forwardBaseUrl: '...', appId: '...', mode: 'forward' },
44
+ locale: 'zh-TW', // UI 文案语言:'zh-CN'(默认)| 'zh-TW' | 'en-US'
45
+ initialAgent: null, // 可选:首次挂载时直接打开的智能体详情
46
+ onSelectAgent: (agent) => console.log('选中:', agent.name),
47
+ });
48
+
49
+ sdk.mount(); // 挂载渲染
50
+ sdk.update({ forwardConfig: { ... } }); // 更新配置并重渲染
51
+ sdk.destroy(); // 卸载并释放资源(可再次 mount)
52
+ ```
53
+
54
+ ## 中转模式说明
55
+
56
+ - `mode: 'forward'`(默认/生产):所有接口经座舱中转接口代理调用(座舱约定的固定 POST 路径),座舱按 `appId` 查环境变量中的 host 后代理到真实接口;`token` / `extraHeaders` 会随中转请求头透传。
57
+ - `mode: 'direct'`(联调):直连目标网关,需提供 `directBaseUrl`,`token` 会作为约定的鉴权请求头透传。
@@ -0,0 +1,5 @@
1
+ import { Agent } from './agents';
2
+ export default function AimkDetail({ agent, onBack }: {
3
+ agent: Agent;
4
+ onBack: () => void;
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { Agent } from './agents';
2
+ export interface AimkIndexProps {
3
+ /** 點擊智能體卡片時回調(由 Main 層決定詳情切換) */
4
+ onSelectAgent: (agent: Agent) => void;
5
+ }
6
+ export default function AimkIndex({ onSelectAgent }: AimkIndexProps): import("react/jsx-runtime").JSX.Element;
@@ -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;
@@ -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;
@@ -0,0 +1,3 @@
1
+ import { AgentCategoryNode } from '../repository';
2
+ /** 攤平分類子孫節點,作為篩選選項 */
3
+ export declare function flattenCategory(node: AgentCategoryNode): AgentCategoryNode[];
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;
@@ -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';