@coralai/sps-plugin-api 0.8.0 → 0.10.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/dist/index.d.ts +35 -3
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -121,12 +121,18 @@ export interface SpsCapabilityBase {
|
|
|
121
121
|
mode: 'sync' | 'async';
|
|
122
122
|
/**
|
|
123
123
|
* 参数形状由**能力**定,不是卡片里的自由 JSON。
|
|
124
|
-
*
|
|
125
|
-
*
|
|
124
|
+
*
|
|
125
|
+
* ✅ **两种都收**:Zod schema,或**标准 JSON Schema**
|
|
126
|
+
* (`{type:'object', properties, required}` —— 和 `sps.tools.inputSchema` 同形)。
|
|
127
|
+
* 注册时归一成 Zod;两种都不是**当场抛**,插件挂不上。
|
|
128
|
+
*
|
|
129
|
+
* 🔴 **为什么要收两种**:`sps.tools.inputSchema` 是 JSON Schema,而这里原本只收 Zod ——
|
|
130
|
+
* 同一个 API 面上同名字段两种含义,两种插件都写的作者必然会混
|
|
131
|
+
* (实测有人 5 个能力全传了 JSON Schema)。而如果他写的是 `.mjs`,类型也拦不住。
|
|
126
132
|
*/
|
|
127
133
|
inputSchema: {
|
|
128
134
|
parse(value: unknown): unknown;
|
|
129
|
-
}
|
|
135
|
+
} | Record<string, unknown>;
|
|
130
136
|
/**
|
|
131
137
|
* 这个能力会写什么(相对项目根的路径模式)。
|
|
132
138
|
* 🔴 **可审计性的来源**:不读代码就知道这张卡会写什么。
|
|
@@ -248,6 +254,30 @@ export interface SpsNotifier {
|
|
|
248
254
|
send(message: string, level?: 'info' | 'success' | 'warning' | 'error'): Promise<void>;
|
|
249
255
|
};
|
|
250
256
|
}
|
|
257
|
+
export interface SpsStorageObject {
|
|
258
|
+
key: string;
|
|
259
|
+
/** **内容判据**(单段上传时等于 md5)。不看时间。 */
|
|
260
|
+
etag: string;
|
|
261
|
+
size: number;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* 对象存储(读 / 列 / 写)。桶是共享面 —— 多节点下 studio 和工作区不在同一台机器上。
|
|
265
|
+
*
|
|
266
|
+
* 🔴 **它只搬字节,不做账。** id / 索引 / 缩略图 / 分类 / 配额 / 计费都在平台侧。
|
|
267
|
+
*
|
|
268
|
+
* ⚠️ **权限按前缀分,而且很紧**(单写方规则)。
|
|
269
|
+
* 读不了的前缀会**抛**,不会回空 —— "库是空的"和"我没权限"混成一个,
|
|
270
|
+
* 人会去补素材而不是去补策略。
|
|
271
|
+
* ⚠️ 桶没配时三个方法都抛 ⇒ **先用 `configured()` 问一句**,别拿异常当分支。
|
|
272
|
+
*/
|
|
273
|
+
export interface SpsStorage {
|
|
274
|
+
configured(): boolean;
|
|
275
|
+
/** 不存在 ⇒ `null`;连不上/没权限 ⇒ **抛**。 */
|
|
276
|
+
get(key: string): Promise<Buffer | null>;
|
|
277
|
+
list(prefix: string): Promise<SpsStorageObject[]>;
|
|
278
|
+
/** ⚠️ `contentType` 自己决定 —— 桶是直连的,缺省会让预览变成一次下载。 */
|
|
279
|
+
put(key: string, bytes: Buffer, contentType?: string): Promise<void>;
|
|
280
|
+
}
|
|
251
281
|
/** 与 `SpsAsyncPoll` 同形 —— async 能力的 `poll` 可以**直接透传**。 */
|
|
252
282
|
export type SpsJobStatus = SpsAsyncPoll;
|
|
253
283
|
/**
|
|
@@ -473,6 +503,7 @@ export declare const SPS_SERVICES: {
|
|
|
473
503
|
readonly projects: "sps.projects";
|
|
474
504
|
readonly cards: "sps.cards";
|
|
475
505
|
readonly jobs: "sps.jobs";
|
|
506
|
+
readonly storage: "sps.storage";
|
|
476
507
|
readonly subprocess: "sps.subprocess";
|
|
477
508
|
readonly attachments: "sps.attachments";
|
|
478
509
|
readonly media: "sps.media";
|
|
@@ -495,6 +526,7 @@ export interface SpsPluginContext {
|
|
|
495
526
|
'sps.projects': SpsProjects;
|
|
496
527
|
'sps.cards': SpsCards;
|
|
497
528
|
'sps.jobs': SpsJobs;
|
|
529
|
+
'sps.storage': SpsStorage;
|
|
498
530
|
'sps.capabilities': SpsCapabilities;
|
|
499
531
|
'sps.media': SpsMedia;
|
|
500
532
|
'sps.im': SpsRegistryByKey;
|
package/dist/index.js
CHANGED