@coralai/sps-plugin-api 0.13.0 → 0.15.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 +56 -0
- package/dist/index.js +11 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -382,6 +382,29 @@ export interface SpsWorkspace {
|
|
|
382
382
|
discover(): Promise<SpsWorkspaceProject[]>;
|
|
383
383
|
/** 某产品的用户资产范围。没有声明时回落窄兜底,并把 `usedDefault` 置真。 */
|
|
384
384
|
assetScope(product: string): SpsAssetScope;
|
|
385
|
+
/**
|
|
386
|
+
* 构建方声明的产物目录(`<repoDir>/.sps/build.json` 的 `outDir`)。
|
|
387
|
+
*
|
|
388
|
+
* 🔴 **三态,别塌成两态**:
|
|
389
|
+
* ```
|
|
390
|
+
* undefined 没声明(文件不在 / 没这个字段 / 坏 JSON)
|
|
391
|
+
* null 声明了「这个项目没有产物目录」
|
|
392
|
+
* string 声明的相对目录
|
|
393
|
+
* ```
|
|
394
|
+
* 把 `null` 和 `undefined` 合成一个,就分不出「构建方说没有」和「构建方没说」——
|
|
395
|
+
* 而前者该照做,后者只能去猜。
|
|
396
|
+
*
|
|
397
|
+
* 🔴 **别自己读 `.sps/build.json`。** 它取代的正是"三方各自猜"那个形状:
|
|
398
|
+
* sps 的 play.ts、插件的 publish.mjs 曾各写一份
|
|
399
|
+
* `exists(dist/index.html) ? dist : repoDir` 的三元(逐字相同)。
|
|
400
|
+
* 现有项目全是 vite(默认 `dist`)所以一直没露;webpack 默认 `build`、Next 是 `.next`
|
|
401
|
+
* ⇒ 只要有一个项目的打包器输出不是 dist,猜的那份当场就错,而表现是
|
|
402
|
+
* "预览到未构建的源码",**零报错**。
|
|
403
|
+
*
|
|
404
|
+
* ⚠️ 它在 `sps.workspace` 而不是别处,是因为这是**读工作区里的一个约定文件** ——
|
|
405
|
+
* 和 `assetScope` 同类:约定由宿主定,插件问宿主要答案,而不是自己拼路径。
|
|
406
|
+
*/
|
|
407
|
+
declaredOutDir(repoDir: string): string | null | undefined;
|
|
385
408
|
}
|
|
386
409
|
/**
|
|
387
410
|
* `p` 是否在 `root` 之内(含 root 自身)。
|
|
@@ -418,6 +441,27 @@ export interface SpsNotifier {
|
|
|
418
441
|
send(message: string, level?: 'info' | 'success' | 'warning' | 'error'): Promise<void>;
|
|
419
442
|
};
|
|
420
443
|
}
|
|
444
|
+
export interface SpsStorageObject {
|
|
445
|
+
key: string;
|
|
446
|
+
/** **内容判据**(单段上传时等于 md5)。不看时间。 */
|
|
447
|
+
etag: string;
|
|
448
|
+
size: number;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* 对象存储(读 / 列 / 写)。**由插件提供** —— 没装桶插件时这个服务不存在,
|
|
452
|
+
* inject 它的插件会 PENDING。
|
|
453
|
+
*
|
|
454
|
+
* ⚠️ 桶没配时三个方法都抛 ⇒ **先用 `configured()` 问一句**,别拿异常当分支。
|
|
455
|
+
* 🔴 读不了的前缀会**抛**,不会回空 —— "库是空的"和"我没权限"混成一个,
|
|
456
|
+
* 人会去补素材而不是去补策略。
|
|
457
|
+
*/
|
|
458
|
+
export interface SpsStorage {
|
|
459
|
+
configured(): boolean;
|
|
460
|
+
/** 不存在 ⇒ `null`;连不上/没权限 ⇒ **抛**。 */
|
|
461
|
+
get(key: string): Promise<Buffer | null>;
|
|
462
|
+
list(prefix: string): Promise<SpsStorageObject[]>;
|
|
463
|
+
put(key: string, bytes: Buffer, contentType?: string): Promise<void>;
|
|
464
|
+
}
|
|
421
465
|
/** 与 `SpsAsyncPoll` 同形 —— async 能力的 `poll` 可以**直接透传**。 */
|
|
422
466
|
export type SpsJobStatus = SpsAsyncPoll;
|
|
423
467
|
/**
|
|
@@ -632,6 +676,16 @@ export interface SpsAttachments {
|
|
|
632
676
|
}>;
|
|
633
677
|
}
|
|
634
678
|
/** 插件 `inject` 里写的名字。 */
|
|
679
|
+
/**
|
|
680
|
+
* **由插件提供**的服务 —— 宿主装配后它们**不一定在**。
|
|
681
|
+
*
|
|
682
|
+
* 🔴 inject 它们的插件要接受"没装那个插件就 PENDING"这件事。
|
|
683
|
+
* ⚠️ 这张表是给门禁用的单一真源:宿主的 conformance 判据据此
|
|
684
|
+
* 豁免这些名字("契约里列的服务装配后都在"对它们不成立)。
|
|
685
|
+
* 2026-08-28 加,起因是把 `sps.storage` 从宿主挪进插件后,
|
|
686
|
+
* 那条判据把"实现搬家了"报成了"契约说谎"。
|
|
687
|
+
*/
|
|
688
|
+
export declare const PLUGIN_PROVIDED_SERVICES: readonly ["sps.storage", "sps.memory"];
|
|
635
689
|
export declare const SPS_SERVICES: {
|
|
636
690
|
readonly tools: "sps.tools";
|
|
637
691
|
readonly credentials: "sps.credentials";
|
|
@@ -651,6 +705,7 @@ export declare const SPS_SERVICES: {
|
|
|
651
705
|
readonly agents: "sps.agents";
|
|
652
706
|
readonly repo: "sps.repo";
|
|
653
707
|
readonly memory: "sps.memory";
|
|
708
|
+
readonly storage: "sps.storage";
|
|
654
709
|
readonly workspace: "sps.workspace";
|
|
655
710
|
readonly notifier: "sps.notifier";
|
|
656
711
|
};
|
|
@@ -672,6 +727,7 @@ export interface SpsPluginContext {
|
|
|
672
727
|
'sps.agents': SpsRegistryByFactory;
|
|
673
728
|
'sps.repo': SpsRegistryByFactory;
|
|
674
729
|
'sps.memory': SpsMemory;
|
|
730
|
+
'sps.storage': SpsStorage;
|
|
675
731
|
'sps.workspace': SpsWorkspace;
|
|
676
732
|
'sps.notifier': SpsNotifier;
|
|
677
733
|
'sps.subprocess': SpsSubprocess;
|
package/dist/index.js
CHANGED
|
@@ -117,6 +117,16 @@ export function buildMemoryDigest(entries, opts = {}) {
|
|
|
117
117
|
}
|
|
118
118
|
// ── 服务名 ───────────────────────────────────────────────────────────────
|
|
119
119
|
/** 插件 `inject` 里写的名字。 */
|
|
120
|
+
/**
|
|
121
|
+
* **由插件提供**的服务 —— 宿主装配后它们**不一定在**。
|
|
122
|
+
*
|
|
123
|
+
* 🔴 inject 它们的插件要接受"没装那个插件就 PENDING"这件事。
|
|
124
|
+
* ⚠️ 这张表是给门禁用的单一真源:宿主的 conformance 判据据此
|
|
125
|
+
* 豁免这些名字("契约里列的服务装配后都在"对它们不成立)。
|
|
126
|
+
* 2026-08-28 加,起因是把 `sps.storage` 从宿主挪进插件后,
|
|
127
|
+
* 那条判据把"实现搬家了"报成了"契约说谎"。
|
|
128
|
+
*/
|
|
129
|
+
export const PLUGIN_PROVIDED_SERVICES = ['sps.storage', 'sps.memory'];
|
|
120
130
|
export const SPS_SERVICES = {
|
|
121
131
|
tools: 'sps.tools',
|
|
122
132
|
credentials: 'sps.credentials',
|
|
@@ -136,6 +146,7 @@ export const SPS_SERVICES = {
|
|
|
136
146
|
agents: 'sps.agents',
|
|
137
147
|
repo: 'sps.repo',
|
|
138
148
|
memory: 'sps.memory',
|
|
149
|
+
storage: 'sps.storage',
|
|
139
150
|
workspace: 'sps.workspace',
|
|
140
151
|
notifier: 'sps.notifier',
|
|
141
152
|
};
|