@manycore/aholo-sdk-mcp 1.0.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 ADDED
@@ -0,0 +1,160 @@
1
+ # @manycore/aholo-sdk-mcp
2
+
3
+ Aholo OpenAPI 的本地 MCP Server,供 [Cursor](https://cursor.com)、[Claude Desktop](https://claude.ai/download) 等 Agent Studio 通过 stdio 调用 Aholo 能力。
4
+
5
+ 底层封装公网 npm SDK(`@manycore/aholo-sdk-*`),支持:
6
+
7
+ - 文件上传(Asset)
8
+ - 3DGS 世界重建 / 生成(World)
9
+ - 图生 3D、文生 3D(Lux3D)
10
+
11
+ ## 前置要求
12
+
13
+ - **Node.js** ≥ 18
14
+ - **Aholo API Key**
15
+ - 中国区:[https://labs.aholo3d.cn/api-keys](https://labs.aholo3d.cn/api-keys)
16
+ - 海外:[https://labs.aholo3d.com/api-keys](https://labs.aholo3d.com/api-keys)
17
+
18
+ ## 快速开始
19
+
20
+ ### 1. 配置 MCP
21
+
22
+ **Cursor** — 编辑 `~/.cursor/mcp.json`:
23
+
24
+ ```json
25
+ {
26
+ "mcpServers": {
27
+ "aholo-sdk-mcp": {
28
+ "type": "stdio",
29
+ "command": "npx",
30
+ "args": ["-y", "@manycore/aholo-sdk-mcp"],
31
+ "env": {
32
+ "AHOLO_API_KEY": "your_api_key_here",
33
+ "AHOLO_REGION": "cn"
34
+ }
35
+ }
36
+ }
37
+ }
38
+ ```
39
+
40
+ **Claude Desktop** — 编辑配置文件(macOS:`~/Library/Application Support/Claude/claude_desktop_config.json`):
41
+
42
+ ```json
43
+ {
44
+ "mcpServers": {
45
+ "aholo-sdk-mcp": {
46
+ "command": "npx",
47
+ "args": ["-y", "@manycore/aholo-sdk-mcp"],
48
+ "env": {
49
+ "AHOLO_API_KEY": "your_api_key_here",
50
+ "AHOLO_REGION": "cn"
51
+ }
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ 保存后重启 Agent / Studio,即可在对话中使用 Aholo 相关 tool。
58
+
59
+ ### 2. 验证安装
60
+
61
+ ```bash
62
+ AHOLO_API_KEY=your_key npx -y @manycore/aholo-sdk-mcp
63
+ ```
64
+
65
+ 未设置 `AHOLO_API_KEY` 时会提示并退出,属正常行为。
66
+
67
+ ## 环境变量
68
+
69
+ | 变量 | 必填 | 说明 |
70
+ |------|------|------|
71
+ | `AHOLO_API_KEY` | 是 | Aholo API Key。中国区在 [labs.aholo3d.cn/api-keys](https://labs.aholo3d.cn/api-keys) 申请;海外在 [labs.aholo3d.com/api-keys](https://labs.aholo3d.com/api-keys) 申请 |
72
+ | `AHOLO_REGION` | 否 | `cn`(中国区,默认)或 `com`(海外);也可在 tool 参数里传 |
73
+
74
+ ## 使用说明
75
+
76
+ ### 文件上传
77
+
78
+ 本地文件通过 `localPath` 传入,由 SDK 直接读磁盘上传至 CDN,**二进制不经过 MCP 协议**。
79
+
80
+ ### World 重建(scene)
81
+
82
+ | 场景 | 选用 Tool |
83
+ |------|-----------|
84
+ | 单个物体 / 产品 / 手办 | `world_reconstruct_object_from_files` 或 `world_reconstruct_object` |
85
+ | 室内 / 房间环拍 | `world_reconstruct_space_from_files` 或 `world_reconstruct_space` |
86
+
87
+ - 图片重建须 **≥ 20 张**;纯视频请设 `resourceType=video`
88
+ - `useMask=true` 表示抠图(主体分割)
89
+ - `taskQuality` 默认 `normal`;用户说「快速预览」→ `low`,「高质量/专业」→ `high`
90
+
91
+ ### 长任务
92
+
93
+ 提交类 tool 默认 `wait=false`,立即返回 `worldId` / `taskId`:
94
+
95
+ 1. 查进度:`world_get` / `lux3d_get_task`(推荐,非阻塞)
96
+ 2. 等到完成:`world_wait_for` / `lux3d_wait_for_task`(阻塞,可能占用连接数分钟)
97
+
98
+ ## Tools
99
+
100
+ **推荐(scene 已固定):**
101
+
102
+ | Tool | 说明 |
103
+ |------|------|
104
+ | `world_inspect_local_media` | 只读:分析本地图片/视频,可选抽帧预览 |
105
+ | `world_reconstruct_object_from_files` | 本地文件 → 物体(model)重建 |
106
+ | `world_reconstruct_space_from_files` | 本地文件 → 室内(space)重建 |
107
+ | `world_reconstruct_object` | URL → 物体(model)重建 |
108
+ | `world_reconstruct_space` | URL → 室内(space)重建 |
109
+
110
+ **兼容(须自行指定 scene 并确认):**
111
+
112
+ | Tool | 说明 |
113
+ |------|------|
114
+ | `world_reconstruct` | URL 重建 |
115
+ | `world_reconstruct_from_files` | 本地文件重建 |
116
+
117
+ **通用:**
118
+
119
+ | Tool | 说明 |
120
+ |------|------|
121
+ | `upload_asset` | 上传本地文件,返回 CDN URL |
122
+ | `world_generate` | 文字生成 3D 世界(Spatial Gen) |
123
+ | `world_get` | 查询 world 详情(只读) |
124
+ | `world_wait_for` | 轮询 world 直至终态 |
125
+ | `world_list` | 分页列出 world(只读) |
126
+ | `lux3d_img_to_3d_from_file` | 本地图片 → Lux3D 3D |
127
+ | `lux3d_img_to_3d` | 图片 URL → Lux3D 3D |
128
+ | `lux3d_text_to_3d` | 文字 → Lux3D 3D |
129
+ | `lux3d_get_task` | 查询 Lux3D 任务(只读) |
130
+ | `lux3d_wait_for_task` | 轮询 Lux3D 任务 |
131
+
132
+ ## 相关文档
133
+
134
+ - [Aholo API 文档](https://labs.aholo3d.cn/api-docs)
135
+ - [TypeScript SDK 指南](https://labs.aholo3d.cn/api-docs/sdk/typescript)
136
+ - [World 重建 Skill(参考工作流)](https://labs.aholo3d.cn/api-docs/skills/aholo-3dgs-reconstruction)
137
+
138
+ ## 从源码运行(可选)
139
+
140
+ ```bash
141
+ git clone https://github.com/manycoretech/aholo-spatial-sdk.git
142
+ cd aholo-spatial-sdk/typescript/mcp # 以仓库实际目录为准
143
+ npm install
144
+ npm run build
145
+ AHOLO_API_KEY=your_key npm start
146
+ ```
147
+
148
+ 本地调试时,将 Cursor 配置中的 `command` / `args` 改为指向构建产物:
149
+
150
+ ```json
151
+ "aholo-sdk-mcp": {
152
+ "type": "stdio",
153
+ "command": "node",
154
+ "args": ["/absolute/path/to/dist/index.js"],
155
+ "env": {
156
+ "AHOLO_API_KEY": "your_api_key_here",
157
+ "AHOLO_REGION": "cn"
158
+ }
159
+ }
160
+ ```
@@ -0,0 +1,3 @@
1
+ import type { AholoClientConfig, AholoRegion } from '@manycore/aholo-sdk-core';
2
+ export declare function resolveRegion(region?: string): AholoRegion;
3
+ export declare function buildClientConfig(region?: string): AholoClientConfig;
package/dist/config.js ADDED
@@ -0,0 +1,11 @@
1
+ export function resolveRegion(region) {
2
+ const value = region ?? process.env.AHOLO_REGION ?? 'cn';
3
+ if (value !== 'cn' && value !== 'com') {
4
+ throw new Error(`Invalid region "${value}". Use "cn" or "com".`);
5
+ }
6
+ return value;
7
+ }
8
+ export function buildClientConfig(region) {
9
+ return { region: resolveRegion(region) };
10
+ }
11
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,aAAa,CAAC,MAAe;IAC3C,MAAM,KAAK,GAAG,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,IAAI,CAAC;IACzD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,mBAAmB,KAAK,uBAAuB,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAe;IAC/C,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { z } from 'zod';
2
+ export declare const SERVER_VERSION = "1.0.0";
3
+ export declare const regionSchema: z.ZodOptional<z.ZodEnum<{
4
+ cn: "cn";
5
+ com: "com";
6
+ }>>;
7
+ export declare const useMaskSchema: z.ZodOptional<z.ZodBoolean>;
8
+ export declare const waitSchema: z.ZodOptional<z.ZodBoolean>;
9
+ /** 重建质量说明(tool description / instructions 共用) */
10
+ export declare const TASK_QUALITY_HINT: string;
11
+ export declare const taskQualitySchema: z.ZodDefault<z.ZodEnum<{
12
+ low: "low";
13
+ normal: "normal";
14
+ high: "high";
15
+ }>>;
16
+ export declare const sceneSchema: z.ZodEnum<{
17
+ model: "model";
18
+ space: "space";
19
+ }>;
20
+ export declare const sceneSourceSchema: z.ZodEnum<{
21
+ user_explicit: "user_explicit";
22
+ inspect: "inspect";
23
+ }>;
24
+ export declare const READONLY_ANNOTATIONS: {
25
+ readonly readOnlyHint: true;
26
+ readonly destructiveHint: false;
27
+ readonly idempotentHint: true;
28
+ };
29
+ export declare const DESTRUCTIVE_ANNOTATIONS: {
30
+ readonly readOnlyHint: false;
31
+ readonly destructiveHint: true;
32
+ readonly idempotentHint: false;
33
+ };
34
+ export declare const SERVER_INSTRUCTIONS: string;
35
+ export declare const RECONSTRUCT_OBJECT_DESC: string;
36
+ export declare const RECONSTRUCT_SPACE_DESC: string;
37
+ /** 提交类 tool 共用的长任务提示(index.ts 内联 description 可引用) */
38
+ export declare const LONG_TASK_SUBMIT_HINT = "\u9ED8\u8BA4 wait=false\uFF0C\u7ACB\u5373\u8FD4\u56DE ID\uFF1B\u67E5\u8FDB\u5EA6\u7528 world_get / lux3d_get_task\uFF08\u975E\u963B\u585E\uFF09\u3002";
39
+ /** world_wait_for / lux3d_wait_for_task 的 description */
40
+ export declare const LONG_TASK_BLOCKING_WAIT_DESC = "\u963B\u585E\u5F0F\u8F6E\u8BE2\u76F4\u81F3 SUCCEEDED \u6216\u7EC8\u6001\u5931\u8D25\u3002stdio \u4E0B\u4F1A\u5360\u7528\u8FDE\u63A5\u6570\u5206\u949F\uFF5E\u6570\u5341\u5206\u949F\uFF1B\u5E38\u89C4\u67E5\u8FDB\u5EA6\u8BF7\u7528 world_get / lux3d_get_task\u3002\u4EC5\u5F53\u7528\u6237\u660E\u786E\u8981\u6C42\u300C\u7B49\u5230\u5B8C\u6210\u300D\u65F6\u8C03\u7528\u3002";
@@ -0,0 +1,94 @@
1
+ import { z } from 'zod';
2
+ export const SERVER_VERSION = '1.0.0';
3
+ export const regionSchema = z
4
+ .enum(['cn', 'com'])
5
+ .optional()
6
+ .describe('API 区域:cn 中国区 / com 海外。默认 AHOLO_REGION 或 cn。');
7
+ export const useMaskSchema = z
8
+ .boolean()
9
+ .optional()
10
+ .describe('是否对上传资源抠图(useMask)。true 开启主体分割;省略或 false 不抠图。');
11
+ export const waitSchema = z
12
+ .boolean()
13
+ .optional()
14
+ .describe('是否在本 tool 内轮询至终态。默认 false(仅返回 worldId/taskId,立即释放连接)。查进度请用 world_get / lux3d_get_task(非阻塞);仅当用户明确要求「等到完成」时再设 true 或调 world_wait_for / lux3d_wait_for_task(阻塞,stdio 下可能占用数分钟~数十分钟)。');
15
+ /** 重建质量说明(tool description / instructions 共用) */
16
+ export const TASK_QUALITY_HINT = [
17
+ 'taskQuality 默认 normal(标准质量,可省略)。',
18
+ 'low = 极速预览:用户说「快速预览/先看看/试效果/低质量/快点」;',
19
+ 'high = 专业质量:用户说「高质量/专业/商用/精细/最好效果」。',
20
+ ].join(' ');
21
+ export const taskQualitySchema = z
22
+ .enum(['low', 'normal', 'high'])
23
+ .default('normal')
24
+ .describe([
25
+ '重建质量,默认 normal(省略即用标准)。',
26
+ 'low = 极速预览(触发词:快速预览、先看看、试效果、快点);',
27
+ 'normal = 标准(默认);',
28
+ 'high = 专业(触发词:高质量、专业、商用、精细、最好效果)。',
29
+ ].join(' '));
30
+ export const sceneSchema = z.enum(['model', 'space']).describe([
31
+ '场景类型(创建后不可改,选错会导致任务作废):',
32
+ 'model = 单个物体/产品/手办,相机绕物体拍摄;',
33
+ 'space = 室内/房间环拍,重建整个空间。',
34
+ '用户已明确说「模型/物体/室内/空间」时可填;不确定时不要猜,先追问用户或使用 world_inspect_local_media。',
35
+ ].join(' '));
36
+ export const sceneSourceSchema = z.enum(['user_explicit', 'inspect']).describe([
37
+ 'scene 依据:',
38
+ 'user_explicit = 用户原话已明确 model/space(须同时 userConfirmedScene=true);',
39
+ 'inspect = 已调用 world_inspect_local_media 辅助判断。',
40
+ '禁止在无依据时 silent 默认 scene。',
41
+ ].join(' '));
42
+ export const READONLY_ANNOTATIONS = {
43
+ readOnlyHint: true,
44
+ destructiveHint: false,
45
+ idempotentHint: true,
46
+ };
47
+ export const DESTRUCTIVE_ANNOTATIONS = {
48
+ readOnlyHint: false,
49
+ destructiveHint: true,
50
+ idempotentHint: false,
51
+ };
52
+ export const SERVER_INSTRUCTIONS = [
53
+ 'Aholo OpenAPI local MCP(@manycore/aholo-sdk-*)。需要 AHOLO_API_KEY。',
54
+ '文件上传走 localPath,二进制不经过 MCP 协议。',
55
+ '',
56
+ 'World 重建 scene 规则(禁止猜测):',
57
+ '- 用户说「模型/物体/产品/手办/模型视频」→ model',
58
+ '- 用户说「室内/房间/空间/环拍」→ space',
59
+ '- 仅说「重建/做3D」等模糊说法 → 追问 model 或 space,或可选 world_inspect_local_media',
60
+ '- 优先使用 world_reconstruct_object_* / world_reconstruct_space_*(scene 已固定)',
61
+ '',
62
+ '长任务工作流(stdio 禁止长时间阻塞):',
63
+ '- 提交:wait=false(默认),立即返回 worldId / taskId',
64
+ '- 查进度:优先 world_get / lux3d_get_task(秒回,非阻塞)',
65
+ '- 等到完成:仅当用户明确要求时,才用 world_wait_for / lux3d_wait_for_task',
66
+ '图片重建:resources 中图片类须 ≥20 条;纯视频每条 type=video。',
67
+ 'useMask=true 表示抠图/主体分割。',
68
+ '',
69
+ '重建质量 taskQuality(默认 normal,不必每次问用户):',
70
+ '- 未提及质量 → normal',
71
+ '- 「快速预览/先看看/试效果/快点」→ low',
72
+ '- 「高质量/专业/商用/精细」→ high',
73
+ ].join('\n');
74
+ export const RECONSTRUCT_OBJECT_DESC = [
75
+ '从本地文件创建 **物体场景(model)** 3DGS 重建:先上传再提交任务。',
76
+ '适用:单个物体/产品/手办/模型视频,相机绕物体拍摄。',
77
+ '不适用:室内房间环拍(请用 world_reconstruct_space_from_files)。',
78
+ '图片重建须 ≥20 张;纯视频会自动设 type=video。',
79
+ '提交后不可改 scene;默认 wait=false,查进度用 world_get(非阻塞)。',
80
+ TASK_QUALITY_HINT,
81
+ ].join(' ');
82
+ export const RECONSTRUCT_SPACE_DESC = [
83
+ '从本地文件创建 **室内空间(space)** 3DGS 重建:先上传再提交任务。',
84
+ '适用:室内/房间 walkthrough、空间环拍。',
85
+ '不适用:桌面单品/手办(请用 world_reconstruct_object_from_files)。',
86
+ '图片重建须 ≥20 张;纯视频会自动设 type=video。',
87
+ '默认 wait=false,查进度用 world_get(非阻塞)。',
88
+ TASK_QUALITY_HINT,
89
+ ].join(' ');
90
+ /** 提交类 tool 共用的长任务提示(index.ts 内联 description 可引用) */
91
+ export const LONG_TASK_SUBMIT_HINT = '默认 wait=false,立即返回 ID;查进度用 world_get / lux3d_get_task(非阻塞)。';
92
+ /** world_wait_for / lux3d_wait_for_task 的 description */
93
+ export const LONG_TASK_BLOCKING_WAIT_DESC = '阻塞式轮询直至 SUCCEEDED 或终态失败。stdio 下会占用连接数分钟~数十分钟;常规查进度请用 world_get / lux3d_get_task。仅当用户明确要求「等到完成」时调用。';
94
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAEtC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC;KAC1B,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;KACnB,QAAQ,EAAE;KACV,QAAQ,CAAC,8CAA8C,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC;KAC3B,OAAO,EAAE;KACT,QAAQ,EAAE;KACV,QAAQ,CAAC,+CAA+C,CAAC,CAAC;AAE7D,MAA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BAAmB,GAAG;IACjC,kEAAkE;IAClE,gCAAgC;IAChC,EAAE;IACF,0BAA0B;IAC1B,gCAAgC;IAChC,2BAA2B;IAC3B,oEAAoE;IACpE,0EAA0E;IAC1E,EAAE;IACF,wBAAwB;IACxB,2CAA2C;IAC3C,6CAA6C;IAC7C,0DAA0D;IAC1D,8CAA8C;IAC9C,yBAAyB;IACzB,EAAE;IACF,sCAAsC;IACtC,kBAAkB;IAClB,0BAA0B;IAC1B,wBAAwB;CACzB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,2CAA2C;IAC3C,6BAA6B;IAC7B,oDAAoD;IACpD,iCAAiC;IACjC,iDAAiD;IACjD,iBAAiB;CAClB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,2CAA2C;IAC3C,4BAA4B;IAC5B,sDAAsD;IACtD,iCAAiC;IACjC,oCAAoC;IACpC,iBAAiB;CAClB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ,qDAAqD;AACrD,MAAM,CAAC,MAAM,qBAAqB,GAChC,6DAA6D,CAAC;AAEhE,yDAAyD;AACzD,MAAM,CAAC,MAAM,4BAA4B,GACvC,oGAAoG,CAAC"}
@@ -0,0 +1,194 @@
1
+ export declare function toolError(toolName: string, error: unknown): {
2
+ [x: string]: unknown;
3
+ content: ({
4
+ type: "text";
5
+ text: string;
6
+ annotations?: {
7
+ audience?: ("user" | "assistant")[] | undefined;
8
+ priority?: number | undefined;
9
+ lastModified?: string | undefined;
10
+ } | undefined;
11
+ _meta?: {
12
+ [x: string]: unknown;
13
+ } | undefined;
14
+ } | {
15
+ type: "image";
16
+ data: string;
17
+ mimeType: string;
18
+ annotations?: {
19
+ audience?: ("user" | "assistant")[] | undefined;
20
+ priority?: number | undefined;
21
+ lastModified?: string | undefined;
22
+ } | undefined;
23
+ _meta?: {
24
+ [x: string]: unknown;
25
+ } | undefined;
26
+ } | {
27
+ type: "audio";
28
+ data: string;
29
+ mimeType: string;
30
+ annotations?: {
31
+ audience?: ("user" | "assistant")[] | undefined;
32
+ priority?: number | undefined;
33
+ lastModified?: string | undefined;
34
+ } | undefined;
35
+ _meta?: {
36
+ [x: string]: unknown;
37
+ } | undefined;
38
+ } | {
39
+ uri: string;
40
+ name: string;
41
+ type: "resource_link";
42
+ description?: string | undefined;
43
+ mimeType?: string | undefined;
44
+ size?: number | undefined;
45
+ annotations?: {
46
+ audience?: ("user" | "assistant")[] | undefined;
47
+ priority?: number | undefined;
48
+ lastModified?: string | undefined;
49
+ } | undefined;
50
+ _meta?: {
51
+ [x: string]: unknown;
52
+ } | undefined;
53
+ icons?: {
54
+ src: string;
55
+ mimeType?: string | undefined;
56
+ sizes?: string[] | undefined;
57
+ theme?: "light" | "dark" | undefined;
58
+ }[] | undefined;
59
+ title?: string | undefined;
60
+ } | {
61
+ type: "resource";
62
+ resource: {
63
+ uri: string;
64
+ text: string;
65
+ mimeType?: string | undefined;
66
+ _meta?: {
67
+ [x: string]: unknown;
68
+ } | undefined;
69
+ } | {
70
+ uri: string;
71
+ blob: string;
72
+ mimeType?: string | undefined;
73
+ _meta?: {
74
+ [x: string]: unknown;
75
+ } | undefined;
76
+ };
77
+ annotations?: {
78
+ audience?: ("user" | "assistant")[] | undefined;
79
+ priority?: number | undefined;
80
+ lastModified?: string | undefined;
81
+ } | undefined;
82
+ _meta?: {
83
+ [x: string]: unknown;
84
+ } | undefined;
85
+ })[];
86
+ _meta?: {
87
+ [x: string]: unknown;
88
+ progressToken?: string | number | undefined;
89
+ "io.modelcontextprotocol/related-task"?: {
90
+ taskId: string;
91
+ } | undefined;
92
+ } | undefined;
93
+ structuredContent?: {
94
+ [x: string]: unknown;
95
+ } | undefined;
96
+ isError?: boolean | undefined;
97
+ };
98
+ export declare function sceneNotConfirmedError(): {
99
+ [x: string]: unknown;
100
+ content: ({
101
+ type: "text";
102
+ text: string;
103
+ annotations?: {
104
+ audience?: ("user" | "assistant")[] | undefined;
105
+ priority?: number | undefined;
106
+ lastModified?: string | undefined;
107
+ } | undefined;
108
+ _meta?: {
109
+ [x: string]: unknown;
110
+ } | undefined;
111
+ } | {
112
+ type: "image";
113
+ data: string;
114
+ mimeType: string;
115
+ annotations?: {
116
+ audience?: ("user" | "assistant")[] | undefined;
117
+ priority?: number | undefined;
118
+ lastModified?: string | undefined;
119
+ } | undefined;
120
+ _meta?: {
121
+ [x: string]: unknown;
122
+ } | undefined;
123
+ } | {
124
+ type: "audio";
125
+ data: string;
126
+ mimeType: string;
127
+ annotations?: {
128
+ audience?: ("user" | "assistant")[] | undefined;
129
+ priority?: number | undefined;
130
+ lastModified?: string | undefined;
131
+ } | undefined;
132
+ _meta?: {
133
+ [x: string]: unknown;
134
+ } | undefined;
135
+ } | {
136
+ uri: string;
137
+ name: string;
138
+ type: "resource_link";
139
+ description?: string | undefined;
140
+ mimeType?: string | undefined;
141
+ size?: number | undefined;
142
+ annotations?: {
143
+ audience?: ("user" | "assistant")[] | undefined;
144
+ priority?: number | undefined;
145
+ lastModified?: string | undefined;
146
+ } | undefined;
147
+ _meta?: {
148
+ [x: string]: unknown;
149
+ } | undefined;
150
+ icons?: {
151
+ src: string;
152
+ mimeType?: string | undefined;
153
+ sizes?: string[] | undefined;
154
+ theme?: "light" | "dark" | undefined;
155
+ }[] | undefined;
156
+ title?: string | undefined;
157
+ } | {
158
+ type: "resource";
159
+ resource: {
160
+ uri: string;
161
+ text: string;
162
+ mimeType?: string | undefined;
163
+ _meta?: {
164
+ [x: string]: unknown;
165
+ } | undefined;
166
+ } | {
167
+ uri: string;
168
+ blob: string;
169
+ mimeType?: string | undefined;
170
+ _meta?: {
171
+ [x: string]: unknown;
172
+ } | undefined;
173
+ };
174
+ annotations?: {
175
+ audience?: ("user" | "assistant")[] | undefined;
176
+ priority?: number | undefined;
177
+ lastModified?: string | undefined;
178
+ } | undefined;
179
+ _meta?: {
180
+ [x: string]: unknown;
181
+ } | undefined;
182
+ })[];
183
+ _meta?: {
184
+ [x: string]: unknown;
185
+ progressToken?: string | number | undefined;
186
+ "io.modelcontextprotocol/related-task"?: {
187
+ taskId: string;
188
+ } | undefined;
189
+ } | undefined;
190
+ structuredContent?: {
191
+ [x: string]: unknown;
192
+ } | undefined;
193
+ isError?: boolean | undefined;
194
+ };
package/dist/errors.js ADDED
@@ -0,0 +1,48 @@
1
+ import { AuthenticationError, BusinessError, PollingFailedError, PollingTimeoutError, RateLimitError, } from '@manycore/aholo-sdk-core';
2
+ import { errorResult } from './response.js';
3
+ const BIZ_CODE_HINTS = {
4
+ '11004': '任务处理失败,请检查素材格式与数量是否符合要求(图片 ≥20 张或视频 type=video)。',
5
+ };
6
+ export function toolError(toolName, error) {
7
+ if (error instanceof AuthenticationError) {
8
+ return errorResult(`${toolName}: API Key 无效或未设置`, {
9
+ code: 'authentication_error',
10
+ hint: '检查 mcp.json 中 AHOLO_API_KEY;中国区申请 https://labs.aholo3d.cn/api-keys ,海外 https://labs.aholo3d.com/api-keys',
11
+ });
12
+ }
13
+ if (error instanceof RateLimitError) {
14
+ return errorResult(`${toolName}: 请求频率超限`, {
15
+ code: 'rate_limit',
16
+ hint: '稍后重试',
17
+ });
18
+ }
19
+ if (error instanceof BusinessError) {
20
+ const bizCode = error.bizCode ?? error.cmdCode;
21
+ return errorResult(`${toolName}: 业务错误`, {
22
+ code: 'business_error',
23
+ bizCode,
24
+ message: error.message,
25
+ hint: bizCode ? BIZ_CODE_HINTS[bizCode] : undefined,
26
+ });
27
+ }
28
+ if (error instanceof PollingTimeoutError) {
29
+ return errorResult(`${toolName}: 轮询超时`, {
30
+ code: 'polling_timeout',
31
+ timeoutMs: error.timeoutMs,
32
+ hint: '用 world_get / lux3d_get_task 继续查询',
33
+ });
34
+ }
35
+ if (error instanceof PollingFailedError) {
36
+ return errorResult(`${toolName}: 任务失败`, {
37
+ code: 'polling_failed',
38
+ message: error.message,
39
+ });
40
+ }
41
+ return errorResult(`${toolName} failed`, error);
42
+ }
43
+ export function sceneNotConfirmedError() {
44
+ return errorResult('scene_not_confirmed', {
45
+ message: 'scene 未确认。用户已明确 model/space 时请设 sceneSource=user_explicit 且 userConfirmedScene=true;不确定时请追问用户,或先调用 world_inspect_local_media 再设 sceneSource=inspect。',
46
+ });
47
+ }
48
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,GACf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,cAAc,GAA2B;IAC7C,OAAO,EAAE,kDAAkD;CAC5D,CAAC;AAEF,MAAM,UAAU,SAAS,CAAC,QAAgB,EAAE,KAAc;IACxD,IAAI,KAAK,YAAY,mBAAmB,EAAE,CAAC;QACzC,OAAO,WAAW,CAAC,GAAG,QAAQ,kBAAkB,EAAE;YAChD,IAAI,EAAE,sBAAsB;YAC5B,IAAI,EAAE,0GAA0G;SACjH,CAAC,CAAC;IACL,CAAC;IACD,IAAI,KAAK,YAAY,cAAc,EAAE,CAAC;QACpC,OAAO,WAAW,CAAC,GAAG,QAAQ,UAAU,EAAE;YACxC,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,MAAM;SACb,CAAC,CAAC;IACL,CAAC;IACD,IAAI,KAAK,YAAY,aAAa,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC;QAC/C,OAAO,WAAW,CAAC,GAAG,QAAQ,QAAQ,EAAE;YACtC,IAAI,EAAE,gBAAgB;YACtB,OAAO;YACP,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,C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