@plume-canvas/server 0.1.31 → 0.1.32
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/dist/cli.js +41 -40
- package/dist/index.d.ts +188 -3
- package/dist/index.js +29 -28
- package/package.json +1 -1
- package/providers/seed-audio-volc.js +389 -150
package/dist/index.d.ts
CHANGED
|
@@ -498,12 +498,22 @@ export declare class CanvasDocument {
|
|
|
498
498
|
private readonly store;
|
|
499
499
|
private readonly resources?;
|
|
500
500
|
private readonly canvasId;
|
|
501
|
+
/**
|
|
502
|
+
* 节点类型 → 中文名。由装配方从插件清单注进来(插件自己声明的 label);
|
|
503
|
+
* 不注入时默认名就是类型名本身,不编造中文(用户 2026-12-03:不允许硬编码名字表)。
|
|
504
|
+
*/
|
|
505
|
+
private readonly typeLabelOf?;
|
|
501
506
|
/**
|
|
502
507
|
* @param store 画布文件夹(canvas.json / view.json)
|
|
503
508
|
* @param resources 本画布资源(节点里存逻辑 ID `<画布id>/<hash>`;迁移期旧同源 URL 仍可读)
|
|
504
509
|
* @param canvasId 画布 id(前端界面当前只有一张,默认 default)
|
|
505
510
|
*/
|
|
506
|
-
constructor(store: CanvasStore, resources?: CanvasResourceStore | undefined, canvasId?: string
|
|
511
|
+
constructor(store: CanvasStore, resources?: CanvasResourceStore | undefined, canvasId?: string,
|
|
512
|
+
/**
|
|
513
|
+
* 节点类型 → 中文名。由装配方从插件清单注进来(插件自己声明的 label);
|
|
514
|
+
* 不注入时默认名就是类型名本身,不编造中文(用户 2026-12-03:不允许硬编码名字表)。
|
|
515
|
+
*/
|
|
516
|
+
typeLabelOf?: NodeTypeLabelOf | undefined);
|
|
507
517
|
/**
|
|
508
518
|
* 写操作串行链(见 runExclusive 的说明)。
|
|
509
519
|
*
|
|
@@ -1432,10 +1442,20 @@ dataRoot?: () => string | undefined,
|
|
|
1432
1442
|
* 所以取回字节时另存一份到工作目录下,返回 `agentLocalPath` 给它。
|
|
1433
1443
|
* 不传就不落盘,只回 base64。
|
|
1434
1444
|
*/
|
|
1435
|
-
agentFilesDir?: (canvasId: string) => string | undefined
|
|
1445
|
+
agentFilesDir?: (canvasId: string) => string | undefined,
|
|
1446
|
+
/**
|
|
1447
|
+
* 平台只读视图(Agent 的 `generation_providers` 用)。
|
|
1448
|
+
*
|
|
1449
|
+
* 由宿主注入:这里不该知道「配置存在哪个 JSON、密钥怎么掩码」。宿主只交出**已经脱敏**的
|
|
1450
|
+
* 平台清单(配置项只说明「有没有填」),MCP 层负责拼成 AI 好读的形状。
|
|
1451
|
+
*/
|
|
1452
|
+
providerView?: () => Promise<ProviderReadonlyView[]> | ProviderReadonlyView[]): McpServer;
|
|
1436
1453
|
|
|
1437
1454
|
export declare function createCloudServer(opts?: CloudServerOptions): Promise<CloudServer>;
|
|
1438
1455
|
|
|
1456
|
+
/** 插件 package.json 里声明的 provider 文件(相对插件根);没声明返回 undefined = 按目录扫 */
|
|
1457
|
+
export declare function declaredPluginProviders(pluginDir: string): Promise<string[] | undefined>;
|
|
1458
|
+
|
|
1439
1459
|
/** 默认画布 id(前端界面当前只有一张画布) */
|
|
1440
1460
|
export declare const DEFAULT_CANVAS_ID = "default";
|
|
1441
1461
|
|
|
@@ -2141,6 +2161,22 @@ export declare function loadProvidersFromDir(dir: string, opts?: {
|
|
|
2141
2161
|
config?: ProviderConfigFile;
|
|
2142
2162
|
}): Promise<LoadResult>;
|
|
2143
2163
|
|
|
2164
|
+
/**
|
|
2165
|
+
* 多来源装载(用户 2026-12-03):数据目录 + 每个插件的自带平台 + 随包内置平台。
|
|
2166
|
+
*
|
|
2167
|
+
* 优先级:**用户数据目录 > 插件自带 > 随包内置**。同一个平台 id 只装第一个,
|
|
2168
|
+
* 其余记进 conflicts(管理页与日志都据此说明「谁被忽略了」),而不是悄悄覆盖。
|
|
2169
|
+
*
|
|
2170
|
+
* 停用按平台 id 记(`disabledPlatforms`);老配置里只有文件名(`disabledFiles`),
|
|
2171
|
+
* 这里按文件名映射回 id,保证老用户升级后开关状态不丢。
|
|
2172
|
+
*/
|
|
2173
|
+
export declare function loadProvidersFromSources(opts: {
|
|
2174
|
+
userDir: string;
|
|
2175
|
+
pluginRoots?: PluginRoots;
|
|
2176
|
+
builtinDir?: string;
|
|
2177
|
+
config?: ProviderConfigFile;
|
|
2178
|
+
}): Promise<ProviderSourcesResult>;
|
|
2179
|
+
|
|
2144
2180
|
declare interface LoadResult {
|
|
2145
2181
|
providers: Provider[];
|
|
2146
2182
|
/** 逐个文件的加载情况(诊断用:哪个文件坏了、为什么) */
|
|
@@ -2180,7 +2216,9 @@ listCanvases?: () => Promise<Array<{
|
|
|
2180
2216
|
/** 数据根(`resource_local_path` / `withLocalPath` 把同源地址翻成磁盘路径用) */
|
|
2181
2217
|
dataRoot?: () => string | undefined,
|
|
2182
2218
|
/** 某个画布的 Agent 工作目录(`canvas_resource_fetch` 取回字节后落一份给文件工具读) */
|
|
2183
|
-
agentFilesDir?: (canvasId: string) => string | undefined
|
|
2219
|
+
agentFilesDir?: (canvasId: string) => string | undefined,
|
|
2220
|
+
/** 平台只读视图(`generation_providers` 用;缺省 = 不提供这个工具的数据) */
|
|
2221
|
+
providerView?: () => Promise<ProviderReadonlyView[]> | ProviderReadonlyView[]): Hono;
|
|
2184
2222
|
|
|
2185
2223
|
/** 工具清单(给 `--list-tools` 与诊断用;与实际注册保持一致) */
|
|
2186
2224
|
export declare interface McpTool {
|
|
@@ -2264,6 +2302,18 @@ export declare interface NodeBatchInput {
|
|
|
2264
2302
|
}[];
|
|
2265
2303
|
}
|
|
2266
2304
|
|
|
2305
|
+
/**
|
|
2306
|
+
* 节点类型 → 中文名(**由调用方注入**,不在这里写表)。
|
|
2307
|
+
*
|
|
2308
|
+
* MCP 建出来的节点是**没有名字**的(以前 data 直接是 {}),而前端把「节点名」统一成
|
|
2309
|
+
* 只看 data.label —— MCP 建的节点在 @ 菜单 / 左侧树里就没名字。这里补默认名时需要
|
|
2310
|
+
* 类型中文名;名字来自插件自己 \`ctx.nodes.register({ type, label })\` 的声明,
|
|
2311
|
+
* 服务端从插件清单的 nodeTypes 里取(见 pluginNodeTypes.ts)。
|
|
2312
|
+
*
|
|
2313
|
+
* 类型名取不到时回落 type 本身(不猜、也不报错)。
|
|
2314
|
+
*/
|
|
2315
|
+
declare type NodeTypeLabelOf = (type: string) => string | undefined;
|
|
2316
|
+
|
|
2267
2317
|
/**
|
|
2268
2318
|
/**
|
|
2269
2319
|
* 找「随包插件目录」(只读兜底)。全局目录由 pluginRoots 按数据根算,不走这里。
|
|
@@ -2364,6 +2414,13 @@ export declare interface PluginCatalogEntry {
|
|
|
2364
2414
|
id: string;
|
|
2365
2415
|
/** 插件在画布里的**真实名字**(源码 export 的 name;可用 package.json 的 plume.pluginName 声明) */
|
|
2366
2416
|
name: string;
|
|
2417
|
+
/**
|
|
2418
|
+
* 插件**真实的 npm 包名**(package.json 的 name,如 `@plume-canvas/plugin-node-image`)。
|
|
2419
|
+
*
|
|
2420
|
+
* 为什么单列:目录名不等于包名 —— 第三方可能发 `plume-canvas-xxx` 或自定义 scope。
|
|
2421
|
+
* 前端更新 / 卸载要按真实包名找来源记录,不能再拿目录名拼 `@plume-canvas/`。
|
|
2422
|
+
*/
|
|
2423
|
+
pkg?: string;
|
|
2367
2424
|
/** 面板上显示的名字(package.json 的 plume.title,缺省用 id) */
|
|
2368
2425
|
title: string;
|
|
2369
2426
|
description?: string;
|
|
@@ -2429,6 +2486,16 @@ export declare interface PluginCatalogEntry {
|
|
|
2429
2486
|
permissions?: string[];
|
|
2430
2487
|
};
|
|
2431
2488
|
version?: string;
|
|
2489
|
+
/**
|
|
2490
|
+
* 该插件注册的节点类型(插件在 \`ctx.nodes.register({ type, label })\` 里声明的)。
|
|
2491
|
+
*
|
|
2492
|
+
* 用途:MCP 建节点要补中文默认名(「图片 1」),名字从**插件自己的声明**取,
|
|
2493
|
+
* 不再在服务端维护「类型 → 中文」的表(用户 2026-12-03 复查硬编码)。
|
|
2494
|
+
*/
|
|
2495
|
+
nodeTypes?: Array<{
|
|
2496
|
+
type: string;
|
|
2497
|
+
label: string;
|
|
2498
|
+
}>;
|
|
2432
2499
|
}
|
|
2433
2500
|
|
|
2434
2501
|
/**
|
|
@@ -2742,6 +2809,13 @@ declare interface ProviderConfigField {
|
|
|
2742
2809
|
/** providers-config.json 的完整形状 */
|
|
2743
2810
|
declare interface ProviderConfigFile {
|
|
2744
2811
|
version: 2;
|
|
2812
|
+
/**
|
|
2813
|
+
* 按**平台 id** 停用(用户 2026-12-03:provider 现在可能来自数据目录 / 插件 / 发布包,
|
|
2814
|
+
* 文件名不再唯一,停用必须按 id 记)。
|
|
2815
|
+
*
|
|
2816
|
+
* 旧字段 `disabledFiles` 仍然读:老配置里只能拿到文件名,装载时按文件名映射回 id。
|
|
2817
|
+
*/
|
|
2818
|
+
disabledPlatforms?: string[];
|
|
2745
2819
|
disabledFiles: string[];
|
|
2746
2820
|
deletedFiles: string[];
|
|
2747
2821
|
files: Record<string, ProviderFileConfig>;
|
|
@@ -2776,6 +2850,9 @@ declare interface ProviderFileConfig {
|
|
|
2776
2850
|
/** 节点类型(动作服务哪几种节点) */
|
|
2777
2851
|
export declare type ProviderNodeType = 'image' | 'video' | 'audio' | 'text';
|
|
2778
2852
|
|
|
2853
|
+
/** provider 的来源(用户 2026-12-03:从好几个目录一起扫,得说清「它是谁带来的」) */
|
|
2854
|
+
export declare type ProviderOrigin = 'user' | 'plugin' | 'builtin';
|
|
2855
|
+
|
|
2779
2856
|
/**
|
|
2780
2857
|
* 新版「点分隔 key」配置:一个平铺对象,key 就是 `providerId.field` 或 `providerId.field.[n]`。
|
|
2781
2858
|
*
|
|
@@ -2852,6 +2929,47 @@ export declare interface ProviderPollResult {
|
|
|
2852
2929
|
waiting?: boolean;
|
|
2853
2930
|
}
|
|
2854
2931
|
|
|
2932
|
+
/**
|
|
2933
|
+
* 给 AI 看的平台只读视图。
|
|
2934
|
+
*
|
|
2935
|
+
* **绝不带密钥**:配置项只给「有没有值」,值本身由宿主在生成这个视图时丢掉。
|
|
2936
|
+
*/
|
|
2937
|
+
declare interface ProviderReadonlyView {
|
|
2938
|
+
id: string;
|
|
2939
|
+
title?: string;
|
|
2940
|
+
description?: string;
|
|
2941
|
+
origin: 'user' | 'plugin' | 'builtin';
|
|
2942
|
+
owner?: {
|
|
2943
|
+
kind: 'plugin';
|
|
2944
|
+
id: string;
|
|
2945
|
+
title?: string;
|
|
2946
|
+
};
|
|
2947
|
+
enabled: boolean;
|
|
2948
|
+
deletable: boolean;
|
|
2949
|
+
configFields: Array<{
|
|
2950
|
+
key: string;
|
|
2951
|
+
label?: string;
|
|
2952
|
+
description?: string;
|
|
2953
|
+
type: string;
|
|
2954
|
+
required?: boolean;
|
|
2955
|
+
/** 这个字段有没有填值(secret 也只看这个) */
|
|
2956
|
+
hasValue: boolean;
|
|
2957
|
+
}>;
|
|
2958
|
+
accounts: Array<{
|
|
2959
|
+
id: string;
|
|
2960
|
+
name?: string;
|
|
2961
|
+
default?: boolean;
|
|
2962
|
+
filledFields: string[];
|
|
2963
|
+
}>;
|
|
2964
|
+
models: Array<{
|
|
2965
|
+
id: string;
|
|
2966
|
+
title: string;
|
|
2967
|
+
description?: string;
|
|
2968
|
+
nodeTypes: string[];
|
|
2969
|
+
enabled: boolean;
|
|
2970
|
+
}>;
|
|
2971
|
+
}
|
|
2972
|
+
|
|
2855
2973
|
export declare class ProviderRegistry {
|
|
2856
2974
|
/** providerId → provider */
|
|
2857
2975
|
private readonly providers;
|
|
@@ -2882,6 +3000,41 @@ export declare class ProviderRegistry {
|
|
|
2882
3000
|
get contentVersion(): number;
|
|
2883
3001
|
}
|
|
2884
3002
|
|
|
3003
|
+
/** 一个被扫到的 provider 文件(不管最后有没有装载成功) */
|
|
3004
|
+
export declare interface ProviderSourceInfo {
|
|
3005
|
+
/** 平台 id(装载前按源码静态读,读不出就用文件名) */
|
|
3006
|
+
id: string;
|
|
3007
|
+
/** 文件名(basename) */
|
|
3008
|
+
file: string;
|
|
3009
|
+
/** 绝对路径 */
|
|
3010
|
+
absPath: string;
|
|
3011
|
+
origin: ProviderOrigin;
|
|
3012
|
+
/** 插件自带的:属于哪个插件 */
|
|
3013
|
+
owner?: {
|
|
3014
|
+
kind: 'plugin';
|
|
3015
|
+
id: string;
|
|
3016
|
+
title?: string;
|
|
3017
|
+
};
|
|
3018
|
+
/** 用户数据目录里的才能删;插件与随包自带只允许停用 */
|
|
3019
|
+
deletable: boolean;
|
|
3020
|
+
/** 被停用(配置里记着)—— 不装载,但管理页要列出来 */
|
|
3021
|
+
disabled?: boolean;
|
|
3022
|
+
}
|
|
3023
|
+
|
|
3024
|
+
export declare interface ProviderSourcesResult extends LoadResult {
|
|
3025
|
+
/** 每个成功装载的平台来自哪里(按 id) */
|
|
3026
|
+
sources: ProviderSourceInfo[];
|
|
3027
|
+
/** 扫到但被停用的(管理页要显示) */
|
|
3028
|
+
disabledSources: ProviderSourceInfo[];
|
|
3029
|
+
/** 同 id 冲突被跳过的 */
|
|
3030
|
+
conflicts: Array<{
|
|
3031
|
+
id: string;
|
|
3032
|
+
file: string;
|
|
3033
|
+
origin: ProviderOrigin;
|
|
3034
|
+
kept: ProviderOrigin;
|
|
3035
|
+
}>;
|
|
3036
|
+
}
|
|
3037
|
+
|
|
2885
3038
|
/** 提交结果:要么给了 taskId(异步,要轮询),要么直接完成,要么直接失败 */
|
|
2886
3039
|
export declare type ProviderSubmitResult = {
|
|
2887
3040
|
taskId: string;
|
|
@@ -2901,6 +3054,26 @@ export declare interface ProviderWatcher {
|
|
|
2901
3054
|
stop(): void;
|
|
2902
3055
|
}
|
|
2903
3056
|
|
|
3057
|
+
/**
|
|
3058
|
+
* 从源码里静态读平台 id(装载前就要知道它,才能应用「按 id 停用」与「同 id 冲突取谁」)。
|
|
3059
|
+
*
|
|
3060
|
+
* 读不出来返回 undefined,调用方回落成文件名 —— 那本来就是历史约定(token01.js → token01)。
|
|
3061
|
+
*
|
|
3062
|
+
* ## 为什么要多一层过滤(2026-12-03 的真事故)
|
|
3063
|
+
*
|
|
3064
|
+
* provider 里 id: 不止一处:动作有 id: 'seed-audio-volc:generate'、
|
|
3065
|
+
* 提示词模板有 id: 'seed-audio-volc:tpl-ref'。早先只取「第一个 id:」——
|
|
3066
|
+
* 正好落在 actions 里,于是静态读到 seed-audio-volc:generate,
|
|
3067
|
+
* 装载器拿这个假 id 去注入账号配置:用户填的 Key 注进了不存在的平台,
|
|
3068
|
+
* provider 运行期读到的账号是空的,界面一直报「还没填 Key」,设置页却明明有值。
|
|
3069
|
+
*
|
|
3070
|
+
* 过滤规则(按可信度从高到低):
|
|
3071
|
+
* 1. export default { id: 'x' } —— 平台对象本体;
|
|
3072
|
+
* 2. export const id = 'x' —— 具名导出;
|
|
3073
|
+
* 3. 顶层对象里的 id: 'x',跳过 * 与「带冒号的动作 id」。
|
|
3074
|
+
*/
|
|
3075
|
+
export declare function readProviderIdFromText(text: string): string | undefined;
|
|
3076
|
+
|
|
2904
3077
|
/**
|
|
2905
3078
|
* 注册场(设计文档 §2.1 逐字对齐)。
|
|
2906
3079
|
*
|
|
@@ -3147,6 +3320,18 @@ declare interface Registry<T> {
|
|
|
3147
3320
|
*/
|
|
3148
3321
|
providerCalls?: ProviderCallLog;
|
|
3149
3322
|
onError?: (message: string, err?: unknown) => void;
|
|
3323
|
+
/**
|
|
3324
|
+
* 下单前最后一道开关检查(用户 2026-12-03)。
|
|
3325
|
+
*
|
|
3326
|
+
* 平台被停用、或某个模型被用户关掉时,底栏不会显示它们;但 Agent 的 MCP 工具、
|
|
3327
|
+
* 手写脚本、旧页面缓存都可能绕过菜单直接下单。这里是**权威拦截**:
|
|
3328
|
+
* 返回错误就拒绝建任务,并说清是「平台停了」还是「模型关了」。
|
|
3329
|
+
*/
|
|
3330
|
+
canRun?: (actionId: string) => {
|
|
3331
|
+
ok: true;
|
|
3332
|
+
} | {
|
|
3333
|
+
error: string;
|
|
3334
|
+
};
|
|
3150
3335
|
}
|
|
3151
3336
|
|
|
3152
3337
|
export declare class TaskManager {
|