@coralai/sps-plugin-api 0.5.1 → 0.6.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 +85 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -94,6 +94,84 @@ export interface SpsPromptSection {
|
|
|
94
94
|
export interface SpsSystemPrompt {
|
|
95
95
|
section(section: SpsPromptSection): () => void;
|
|
96
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* 一个**工具卡能力** —— 由编排驱动、不占 worker 槽位的那类执行体。
|
|
99
|
+
*
|
|
100
|
+
* 🔴 和 `sps.tools`(MCP 工具)的区别不是形状,是**谁触发、多久**:
|
|
101
|
+
* MCP 工具是 **agent 主动调**,agent 阻塞等它 —— 适合秒级。
|
|
102
|
+
* 能力是**编排调度的一张卡**,和 worker 并行、可以跑分钟级,
|
|
103
|
+
* `mode:'async'` 的甚至返回后任务仍在跑(由 join 卡等终态)。
|
|
104
|
+
* 要做"生成一批图"这种事,选能力,别选工具。
|
|
105
|
+
*/
|
|
106
|
+
export interface SpsCapability {
|
|
107
|
+
/** 能力 id,卡片用它引用。命名 `<域>.<动作>`,如 `art.chromaKey`。 */
|
|
108
|
+
id: string;
|
|
109
|
+
mode: 'sync' | 'async';
|
|
110
|
+
/**
|
|
111
|
+
* 参数形状由**能力**定,不是卡片里的自由 JSON。
|
|
112
|
+
* ⚠️ 运行时必须是一个 **Zod schema**(能力表拿它校验卡片参数)——
|
|
113
|
+
* 这里只声明结构最小面,免得契约包为此依赖 zod。
|
|
114
|
+
*/
|
|
115
|
+
inputSchema: {
|
|
116
|
+
parse(value: unknown): unknown;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* 这个能力会写什么(相对项目根的路径模式)。
|
|
120
|
+
* 🔴 **可审计性的来源**:不读代码就知道这张卡会写什么。
|
|
121
|
+
* ⚠️ 你声明了不等于 sps 会拦 —— 越界靠围栏兜(realpath + 项目根内),不靠这条声明。
|
|
122
|
+
*/
|
|
123
|
+
produces: string[];
|
|
124
|
+
/** 可信度来源。卡片不看这一格,**审计要看**。 */
|
|
125
|
+
source: {
|
|
126
|
+
kind: 'built-in';
|
|
127
|
+
} | {
|
|
128
|
+
kind: 'script';
|
|
129
|
+
template: string;
|
|
130
|
+
script: string;
|
|
131
|
+
};
|
|
132
|
+
/** 一句话说明,给编排页展示。 */
|
|
133
|
+
summary: string;
|
|
134
|
+
/** 执行体。`async` 能力返回后**任务仍在跑**。 */
|
|
135
|
+
run(input: unknown, ctx: {
|
|
136
|
+
/** 项目在共享树下的相对路径(`t<租户>/<产品>/<项目>`)。 */
|
|
137
|
+
project: string;
|
|
138
|
+
/** 项目工作区绝对路径。**能力不从卡片收路径**,只从这里取根。 */
|
|
139
|
+
projectDir: string;
|
|
140
|
+
}): Promise<Record<string, unknown>>;
|
|
141
|
+
}
|
|
142
|
+
export interface SpsCapabilities {
|
|
143
|
+
register(cap: SpsCapability): () => void;
|
|
144
|
+
get(id: string): SpsCapability | undefined;
|
|
145
|
+
list(): SpsCapability[];
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* ⚠️ 下面四个的**载荷形状**(adapter / factory)住在 sps 里,还没有真实的第三方消费方,
|
|
149
|
+
* 所以这里只声明**注册表本身**,载荷留 `unknown`。
|
|
150
|
+
* 要写这四类插件时告诉我们,按真实需求把形状定出来 ——
|
|
151
|
+
* 凭空定一个大接口,大概率定错位置和粒度。
|
|
152
|
+
*/
|
|
153
|
+
export interface SpsRegistryByKey<T = unknown> {
|
|
154
|
+
register(key: string, value: T): () => void;
|
|
155
|
+
get(key: string): T | undefined;
|
|
156
|
+
list(): string[];
|
|
157
|
+
}
|
|
158
|
+
/** 工厂自带 id,注册时不另给 key。 */
|
|
159
|
+
export interface SpsRegistryByFactory<T = unknown> {
|
|
160
|
+
register(factory: T): () => void;
|
|
161
|
+
list(): string[];
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* ⚠️ 同上:这两个是**甲·工厂型**(换实现,不是收一组),
|
|
165
|
+
* 今天没有第三方在换它们。声明方法名,形状留 `unknown`。
|
|
166
|
+
*/
|
|
167
|
+
export interface SpsMemory {
|
|
168
|
+
buildInjection(refs: unknown[]): string;
|
|
169
|
+
}
|
|
170
|
+
export interface SpsNotifier {
|
|
171
|
+
open(config: unknown): {
|
|
172
|
+
send(message: string, level?: 'info' | 'success' | 'warning' | 'error'): Promise<void>;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
97
175
|
/** 建一张卡。形状照 MCP 面上的 `add_card`,不另发明。 */
|
|
98
176
|
export interface SpsNewCard {
|
|
99
177
|
title: string;
|
|
@@ -318,6 +396,13 @@ export interface SpsPluginContext {
|
|
|
318
396
|
'sps.events': SpsEvents;
|
|
319
397
|
'sps.projects': SpsProjects;
|
|
320
398
|
'sps.cards': SpsCards;
|
|
399
|
+
'sps.capabilities': SpsCapabilities;
|
|
400
|
+
'sps.media': SpsRegistryByKey;
|
|
401
|
+
'sps.im': SpsRegistryByKey;
|
|
402
|
+
'sps.agents': SpsRegistryByFactory;
|
|
403
|
+
'sps.repo': SpsRegistryByFactory;
|
|
404
|
+
'sps.memory': SpsMemory;
|
|
405
|
+
'sps.notifier': SpsNotifier;
|
|
321
406
|
'sps.subprocess': SpsSubprocess;
|
|
322
407
|
'sps.attachments': SpsAttachments;
|
|
323
408
|
}
|