@easyai-canvas/canvas-plugin-sdk 0.1.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/LICENSE +5 -0
- package/README.md +22 -0
- package/bin/easyai-plugin.mjs +267 -0
- package/dist/customer-main.d.ts +1 -0
- package/dist/customer-main.js +256 -0
- package/dist/protocol/index.d.ts +295 -0
- package/dist/protocol/index.js +454 -0
- package/dist/runtime/auth.d.ts +1 -0
- package/dist/runtime/auth.js +68 -0
- package/dist/runtime/engine.d.ts +49 -0
- package/dist/runtime/engine.js +296 -0
- package/dist/runtime/host-files.d.ts +16 -0
- package/dist/runtime/host-files.js +208 -0
- package/dist/runtime/instance-lock.d.ts +1 -0
- package/dist/runtime/instance-lock.js +52 -0
- package/dist/runtime/package-runtime.d.ts +44 -0
- package/dist/runtime/package-runtime.js +361 -0
- package/dist/runtime/packaged-plugins.d.ts +14 -0
- package/dist/runtime/packaged-plugins.js +58 -0
- package/dist/runtime/plugin-config.d.ts +4 -0
- package/dist/runtime/plugin-config.js +31 -0
- package/dist/runtime/store.d.ts +48 -0
- package/dist/runtime/store.js +151 -0
- package/dist/runtime/worker.d.ts +1 -0
- package/dist/runtime/worker.js +38 -0
- package/dist/sdk/frontend.d.ts +62 -0
- package/dist/sdk/frontend.js +40 -0
- package/dist/sdk/index.d.ts +38 -0
- package/dist/sdk/index.js +10 -0
- package/dist/studio/index.html +649 -0
- package/dist/studio/remote-connector.d.ts +60 -0
- package/dist/studio/remote-connector.js +295 -0
- package/package.json +45 -0
- package/tools/build-plugin-package.mjs +99 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/** Public, dependency-free contract. Host copies are generated by protocol:sync. */
|
|
2
|
+
export declare const PROTOCOL: "easyai.plugin/v1";
|
|
3
|
+
/** Host-provided theme for plugin nodes; plugins cannot publish native UI configuration. */
|
|
4
|
+
export type CanvasColorTokens = Partial<Record<'primary' | 'canvasBackground' | 'panelBackground' | 'textPrimary' | 'textSecondary' | 'borderColor', string>>;
|
|
5
|
+
export type PluginNodeTheme = {
|
|
6
|
+
mode?: 'light' | 'dark';
|
|
7
|
+
theme?: {
|
|
8
|
+
typography?: {
|
|
9
|
+
fontFamily?: 'system' | 'sans' | 'serif' | 'mono';
|
|
10
|
+
fontSize?: number;
|
|
11
|
+
};
|
|
12
|
+
shape?: {
|
|
13
|
+
controlRadius?: number;
|
|
14
|
+
panelRadius?: number;
|
|
15
|
+
nodeRadius?: number;
|
|
16
|
+
};
|
|
17
|
+
light?: CanvasColorTokens;
|
|
18
|
+
dark?: CanvasColorTokens;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type PortType = 'text' | 'json' | 'image' | 'video' | 'audio' | 'file' | 'any';
|
|
22
|
+
export type DataPacket = {
|
|
23
|
+
type: PortType;
|
|
24
|
+
payload: Record<string, unknown>;
|
|
25
|
+
source?: {
|
|
26
|
+
nodeId: string;
|
|
27
|
+
portId: string;
|
|
28
|
+
timestamp: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export type Port = {
|
|
32
|
+
id: string;
|
|
33
|
+
type: PortType;
|
|
34
|
+
required?: boolean;
|
|
35
|
+
multiple?: boolean;
|
|
36
|
+
};
|
|
37
|
+
export type ConfigField = {
|
|
38
|
+
key: string;
|
|
39
|
+
label: string;
|
|
40
|
+
type: 'string' | 'number' | 'boolean' | 'select' | 'secret';
|
|
41
|
+
default?: unknown;
|
|
42
|
+
options?: {
|
|
43
|
+
label: string;
|
|
44
|
+
value: string;
|
|
45
|
+
}[];
|
|
46
|
+
required?: boolean;
|
|
47
|
+
};
|
|
48
|
+
export type PluginMenuContribution = {
|
|
49
|
+
group: 'basic' | 'storyboard' | 'tools' | 'resources';
|
|
50
|
+
order?: number;
|
|
51
|
+
icon?: string;
|
|
52
|
+
};
|
|
53
|
+
export type PluginRuntimeContext = {
|
|
54
|
+
user: {
|
|
55
|
+
id: string;
|
|
56
|
+
username?: string;
|
|
57
|
+
ssoId?: string;
|
|
58
|
+
tenantId?: string;
|
|
59
|
+
};
|
|
60
|
+
projectId?: string;
|
|
61
|
+
nodeId?: string;
|
|
62
|
+
environment: 'canvas';
|
|
63
|
+
};
|
|
64
|
+
export type PluginDocumentStateCapability = {
|
|
65
|
+
key: string;
|
|
66
|
+
schema?: string;
|
|
67
|
+
maxBytes?: number;
|
|
68
|
+
/** Optional legacy host fields updated after a result is durably delivered. */
|
|
69
|
+
renderedRevisionKey?: string;
|
|
70
|
+
resultKey?: string;
|
|
71
|
+
subtitleResultKey?: string;
|
|
72
|
+
};
|
|
73
|
+
export type PluginNodeCapabilities = {
|
|
74
|
+
documentState?: PluginDocumentStateCapability;
|
|
75
|
+
workspace?: boolean;
|
|
76
|
+
mediaUpload?: boolean;
|
|
77
|
+
inputManagement?: boolean;
|
|
78
|
+
outputToCanvas?: boolean;
|
|
79
|
+
};
|
|
80
|
+
export type PluginNodeRuntimePolicy = {
|
|
81
|
+
safeRetry?: boolean;
|
|
82
|
+
maxAttempts?: number;
|
|
83
|
+
maxQueuedPerUser?: number;
|
|
84
|
+
maxQueued?: number;
|
|
85
|
+
};
|
|
86
|
+
export type NodeDefinition = {
|
|
87
|
+
type: string;
|
|
88
|
+
name: string;
|
|
89
|
+
description?: string;
|
|
90
|
+
inputs: Port[];
|
|
91
|
+
outputs: Port[];
|
|
92
|
+
parameters?: ConfigField[];
|
|
93
|
+
execution: 'remote' | 'source' | 'display' | 'confirmed';
|
|
94
|
+
ui?: {
|
|
95
|
+
preview?: string;
|
|
96
|
+
panel?: string;
|
|
97
|
+
actions?: string;
|
|
98
|
+
};
|
|
99
|
+
defaults?: Record<string, unknown>;
|
|
100
|
+
timeoutMs?: number;
|
|
101
|
+
menu?: PluginMenuContribution;
|
|
102
|
+
capabilities?: PluginNodeCapabilities;
|
|
103
|
+
runtime?: PluginNodeRuntimePolicy;
|
|
104
|
+
};
|
|
105
|
+
export type AssetSource = {
|
|
106
|
+
id: string;
|
|
107
|
+
name: string;
|
|
108
|
+
description?: string;
|
|
109
|
+
url?: string;
|
|
110
|
+
origin?: string;
|
|
111
|
+
mediaTypes: PortType[];
|
|
112
|
+
ui?: {
|
|
113
|
+
selector: string;
|
|
114
|
+
};
|
|
115
|
+
menu?: PluginMenuContribution;
|
|
116
|
+
};
|
|
117
|
+
export type PluginAction = {
|
|
118
|
+
id: string;
|
|
119
|
+
name: string;
|
|
120
|
+
description?: string;
|
|
121
|
+
action: 'asset-selection';
|
|
122
|
+
presentation: 'dialog';
|
|
123
|
+
mediaTypes: Array<'image' | 'video' | 'audio' | 'file'>;
|
|
124
|
+
maxCount?: number;
|
|
125
|
+
ui: {
|
|
126
|
+
component?: string;
|
|
127
|
+
url?: string;
|
|
128
|
+
origin?: string;
|
|
129
|
+
};
|
|
130
|
+
menu: PluginMenuContribution;
|
|
131
|
+
/** Set only on the normalized view returned by listPluginActions(). */
|
|
132
|
+
legacyAssetSource?: boolean;
|
|
133
|
+
};
|
|
134
|
+
export type PluginManifest = {
|
|
135
|
+
protocol: typeof PROTOCOL;
|
|
136
|
+
id: string;
|
|
137
|
+
name: string;
|
|
138
|
+
release: string;
|
|
139
|
+
configFields?: ConfigField[];
|
|
140
|
+
contributes: {
|
|
141
|
+
nodes?: NodeDefinition[];
|
|
142
|
+
actions?: PluginAction[];
|
|
143
|
+
assetSources?: AssetSource[];
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
export type PluginUiBundle = {
|
|
147
|
+
url: string;
|
|
148
|
+
digest: string;
|
|
149
|
+
globalName: string;
|
|
150
|
+
cssUrl?: string;
|
|
151
|
+
cssDigest?: string;
|
|
152
|
+
};
|
|
153
|
+
export type CatalogEntry = {
|
|
154
|
+
packageDigest?: string;
|
|
155
|
+
uiBundle?: PluginUiBundle;
|
|
156
|
+
manifest: PluginManifest;
|
|
157
|
+
enabled: boolean;
|
|
158
|
+
config: Record<string, unknown>;
|
|
159
|
+
/** Optimistic-lock version for this service instance's plugin configuration. */
|
|
160
|
+
configVersion?: number;
|
|
161
|
+
/** Secret values are never returned; only their configured state is exposed. */
|
|
162
|
+
secretConfigured?: Record<string, boolean>;
|
|
163
|
+
configCheckAvailable?: boolean;
|
|
164
|
+
};
|
|
165
|
+
export type Catalog = {
|
|
166
|
+
protocol: typeof PROTOCOL;
|
|
167
|
+
revision: number;
|
|
168
|
+
/** Stable identity for the currently running plugin-service data directory. */
|
|
169
|
+
instanceId?: string;
|
|
170
|
+
plugins: CatalogEntry[];
|
|
171
|
+
};
|
|
172
|
+
export type HostFilesCapability = {
|
|
173
|
+
/** Trusted host endpoint. The plugin service rejects non-HTTPS remote capabilities. */
|
|
174
|
+
baseUrl: string;
|
|
175
|
+
/** Short-lived, task-bound bearer grant. It must never be written to execution records. */
|
|
176
|
+
grant: string;
|
|
177
|
+
expiresAt: number;
|
|
178
|
+
/** Optional explicit route for the host file capability. */
|
|
179
|
+
path?: '/v1/plugin-artifacts';
|
|
180
|
+
};
|
|
181
|
+
export type ExecutionRequest = {
|
|
182
|
+
executionId: string;
|
|
183
|
+
pluginId: string;
|
|
184
|
+
nodeType: string;
|
|
185
|
+
parameters: Record<string, unknown>;
|
|
186
|
+
inputsByPort: Record<string, DataPacket[]>;
|
|
187
|
+
document?: {
|
|
188
|
+
key: string;
|
|
189
|
+
schema?: string;
|
|
190
|
+
revision: string;
|
|
191
|
+
value: unknown;
|
|
192
|
+
};
|
|
193
|
+
context: {
|
|
194
|
+
nodeId: string;
|
|
195
|
+
taskId?: string;
|
|
196
|
+
userId: string;
|
|
197
|
+
projectId?: string;
|
|
198
|
+
runtime?: PluginRuntimeContext;
|
|
199
|
+
};
|
|
200
|
+
host?: {
|
|
201
|
+
files?: HostFilesCapability;
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
export type PluginQueryRequest = {
|
|
205
|
+
input: Record<string, unknown>;
|
|
206
|
+
context: PluginRuntimeContext;
|
|
207
|
+
};
|
|
208
|
+
export type ExecutionResult = {
|
|
209
|
+
outputs: Record<string, DataPacket>;
|
|
210
|
+
parameters?: Record<string, unknown>;
|
|
211
|
+
documentRevision?: string;
|
|
212
|
+
phase?: string;
|
|
213
|
+
};
|
|
214
|
+
export type ExecutionStatus = 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled' | 'interrupted';
|
|
215
|
+
export type ExecutionRecord = {
|
|
216
|
+
executionId: string;
|
|
217
|
+
pluginId: string;
|
|
218
|
+
nodeType: string;
|
|
219
|
+
status: ExecutionStatus;
|
|
220
|
+
progress: number;
|
|
221
|
+
phase?: string;
|
|
222
|
+
attempt: number;
|
|
223
|
+
maxAttempts: number;
|
|
224
|
+
cancelRequested: boolean;
|
|
225
|
+
result?: ExecutionResult;
|
|
226
|
+
error?: {
|
|
227
|
+
code: string;
|
|
228
|
+
message: string;
|
|
229
|
+
};
|
|
230
|
+
createdAt: string;
|
|
231
|
+
updatedAt: string;
|
|
232
|
+
};
|
|
233
|
+
export type SelectedResource = {
|
|
234
|
+
url: string;
|
|
235
|
+
type: 'image' | 'video' | 'audio' | 'file';
|
|
236
|
+
name?: string;
|
|
237
|
+
mimeType?: string;
|
|
238
|
+
size?: number;
|
|
239
|
+
width?: number;
|
|
240
|
+
height?: number;
|
|
241
|
+
duration?: number;
|
|
242
|
+
sourceId?: string;
|
|
243
|
+
};
|
|
244
|
+
export type HostSnapshot = {
|
|
245
|
+
revision: number;
|
|
246
|
+
plugins: Array<{
|
|
247
|
+
installationId?: string;
|
|
248
|
+
installationRevision?: number;
|
|
249
|
+
deployment?: 'hosted' | 'remote';
|
|
250
|
+
serviceId: string;
|
|
251
|
+
entry: CatalogEntry;
|
|
252
|
+
enabled: boolean;
|
|
253
|
+
uiBundle?: {
|
|
254
|
+
url: string;
|
|
255
|
+
digest: string;
|
|
256
|
+
globalName: string;
|
|
257
|
+
cssUrl?: string;
|
|
258
|
+
cssDigest?: string;
|
|
259
|
+
};
|
|
260
|
+
}>;
|
|
261
|
+
};
|
|
262
|
+
export declare class ContractError extends Error {
|
|
263
|
+
readonly status: number;
|
|
264
|
+
readonly code: string;
|
|
265
|
+
constructor(message: string, status?: number, code?: string);
|
|
266
|
+
}
|
|
267
|
+
export declare function object(value: unknown, path?: string): Record<string, unknown>;
|
|
268
|
+
export declare function validatePluginRuntimeContext(value: unknown): PluginRuntimeContext;
|
|
269
|
+
export declare function identifier(value: unknown, path: string): string;
|
|
270
|
+
export declare function validateParameters(fields: ConfigField[], input: Record<string, unknown>): Record<string, unknown>;
|
|
271
|
+
/** Returns the interaction-oriented view while preserving legacy asset source manifests. */
|
|
272
|
+
export declare function listPluginActions(manifest: PluginManifest): PluginAction[];
|
|
273
|
+
export declare function validateManifest(value: unknown): PluginManifest;
|
|
274
|
+
export declare function validatePacket(value: unknown, expected?: PortType): DataPacket;
|
|
275
|
+
export declare function validateExecution(value: unknown, node: NodeDefinition): ExecutionRequest;
|
|
276
|
+
export declare function validateResult(value: unknown, node: NodeDefinition): ExecutionResult;
|
|
277
|
+
export declare function validateSelectedResources(resources: unknown, allowedTypes: string[], limit: number): SelectedResource[];
|
|
278
|
+
/** One outstanding iframe selection. A caller must cancel on close/unmount. */
|
|
279
|
+
export declare class AssetSelectionSession {
|
|
280
|
+
readonly requestId: string;
|
|
281
|
+
private origin;
|
|
282
|
+
private source;
|
|
283
|
+
private allowedTypes;
|
|
284
|
+
private limit;
|
|
285
|
+
private closed;
|
|
286
|
+
constructor(requestId: string, origin: string, source: unknown, allowedTypes: string[], limit: number);
|
|
287
|
+
cancel(): void;
|
|
288
|
+
receive(event: {
|
|
289
|
+
origin: string;
|
|
290
|
+
source: unknown;
|
|
291
|
+
data: unknown;
|
|
292
|
+
}): SelectedResource[] | undefined;
|
|
293
|
+
}
|
|
294
|
+
/** Confirmation binds semantic input content, not transport timestamps or object key order. */
|
|
295
|
+
export declare function confirmationPayload(parameters: Record<string, unknown>, inputs: Record<string, DataPacket[]>): string;
|