@picteus/extension-sdk 0.18.0 → 0.19.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/generated/backEndIntents.d.ts +216 -0
- package/dist/generated/backEndIntents.js +12 -0
- package/dist/generated/frontEndIntents.d.ts +1112 -0
- package/dist/generated/frontEndIntents.js +97 -0
- package/dist/generated/intentValidator.d.ts +49 -0
- package/dist/generated/intentValidator.js +363 -0
- package/dist/generated/viewKit.d.ts +1689 -366
- package/dist/generated/viewKit.js +994 -290
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/picteusExtension.d.ts +13 -4
- package/dist/picteusExtension.js +45 -24
- package/package.json +4 -6
- package/dist/featureViewGrammar.d.ts +0 -2814
- package/dist/featureViewGrammar.js +0 -2612
- package/dist/generated/featureViewGrammar.d.ts +0 -3913
- package/dist/generated/featureViewGrammar.js +0 -4099
- package/dist/intents.d.ts +0 -188
- package/dist/intents.js +0 -26
- package/dist/picteus-ws-client/models/ExtensionActivityKind.d.ts +0 -26
- package/dist/picteus-ws-client/models/ExtensionActivityKind.js +0 -44
- package/dist/picteus-ws-client/models/ExtensionStatus.d.ts +0 -25
- package/dist/picteus-ws-client/models/ExtensionStatus.js +0 -43
- package/dist/picteus-ws-client/models/ImageEmbeddings.d.ts +0 -32
- package/dist/picteus-ws-client/models/ImageEmbeddings.js +0 -43
- package/dist/picteus-ws-client/models/RepositoryStatus.d.ts +0 -27
- package/dist/picteus-ws-client/models/RepositoryStatus.js +0 -45
- package/dist/picteus-ws-client/models/Settings.d.ts +0 -32
- package/dist/picteus-ws-client/models/Settings.js +0 -41
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export * from "./intents.js";
|
|
2
|
-
export * from "./picteusExtension.js";
|
|
3
1
|
export * from "./picteus-ws-client/index.js";
|
|
2
|
+
export * from "./generated/backEndIntents.js";
|
|
3
|
+
export * from "./generated/frontEndIntents.js";
|
|
4
4
|
export * from "./generated/viewKit.js";
|
|
5
|
+
export * from "./picteusExtension.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export * from "./intents.js";
|
|
2
|
-
export * from "./picteusExtension.js";
|
|
3
1
|
export * from "./picteus-ws-client/index.js";
|
|
2
|
+
export * from "./generated/backEndIntents.js";
|
|
3
|
+
export * from "./generated/frontEndIntents.js";
|
|
4
4
|
export * from "./generated/viewKit.js";
|
|
5
|
+
export * from "./picteusExtension.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Socket } from "socket.io-client";
|
|
2
|
-
import { ApiSecretApi, CollectionApi, Configuration, ExtensionApi, ImageApi, ImageAttachmentApi, Manifest, MiscellaneousApi, RepositoryApi } from "./index.js";
|
|
3
|
-
|
|
2
|
+
import { ApiSecretApi, BackIntent, CollectionApi, Configuration, ExtensionApi, FrontIntent, ImageApi, ImageAttachmentApi, Manifest, MiscellaneousApi, RepositoryApi } from "./index.js";
|
|
3
|
+
export type Intent = FrontIntent | BackIntent;
|
|
4
4
|
export type EventValue = Record<string, any>;
|
|
5
5
|
export declare const InstructionReturnedErrorCause: {
|
|
6
6
|
readonly Cancel: 0;
|
|
@@ -30,6 +30,10 @@ export declare const EventName: {
|
|
|
30
30
|
readonly TextComputeEmbeddings: "text.computeEmbeddings";
|
|
31
31
|
};
|
|
32
32
|
export type EventName = (typeof EventName)[keyof typeof EventName];
|
|
33
|
+
export type Entity = {
|
|
34
|
+
type: "image" | "repository" | "collection";
|
|
35
|
+
id: string | number;
|
|
36
|
+
};
|
|
33
37
|
export declare class Helper {
|
|
34
38
|
static readonly GENERATION_RECIPE_SCHEMA_VERSION = 2;
|
|
35
39
|
}
|
|
@@ -73,8 +77,10 @@ declare class MessageSender {
|
|
|
73
77
|
export declare class Communicator {
|
|
74
78
|
private readonly logger;
|
|
75
79
|
private readonly sender;
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
private entity;
|
|
81
|
+
constructor(logger: Logger, sender: MessageSender, entity?: Entity);
|
|
82
|
+
forEntity(entity: Entity): this;
|
|
83
|
+
sendLog(message: string, level: "debug" | "info" | "warn" | "error", entity?: Entity): void;
|
|
78
84
|
sendNotification(value: Record<string, any>): void;
|
|
79
85
|
launchIntent<T>(intent: Intent): Promise<T>;
|
|
80
86
|
private sendMessage;
|
|
@@ -130,5 +136,8 @@ export declare class PicteusExtension {
|
|
|
130
136
|
private disconnectSocket;
|
|
131
137
|
private exit;
|
|
132
138
|
private getApiConfiguration;
|
|
139
|
+
private computeEventEntity;
|
|
140
|
+
private extractEventValueId;
|
|
141
|
+
private extractEventCommandId;
|
|
133
142
|
}
|
|
134
143
|
export {};
|
package/dist/picteusExtension.js
CHANGED
|
@@ -136,13 +136,21 @@ const instructionsEvent = "instructions";
|
|
|
136
136
|
export class Communicator {
|
|
137
137
|
logger;
|
|
138
138
|
sender;
|
|
139
|
-
|
|
139
|
+
entity;
|
|
140
|
+
constructor(logger, sender, entity) {
|
|
140
141
|
this.logger = logger;
|
|
141
142
|
this.sender = sender;
|
|
143
|
+
this.entity = entity;
|
|
142
144
|
}
|
|
143
|
-
|
|
145
|
+
forEntity(entity) {
|
|
146
|
+
this.entity = entity;
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
sendLog(message, level, entity) {
|
|
144
150
|
this.logger[level](message);
|
|
145
|
-
|
|
151
|
+
const actualEntity = entity ?? this.entity;
|
|
152
|
+
const log = actualEntity === undefined ? { message, level } : { message, level, entity: actualEntity };
|
|
153
|
+
this.sendMessage(instructionsEvent, { log });
|
|
146
154
|
}
|
|
147
155
|
// noinspection JSUnusedGlobalSymbols
|
|
148
156
|
sendNotification(value) {
|
|
@@ -246,47 +254,37 @@ export class PicteusExtension {
|
|
|
246
254
|
}
|
|
247
255
|
async onEvent(communicator, event, value) {
|
|
248
256
|
if (event === EventName.ImageCreated) {
|
|
249
|
-
|
|
250
|
-
return await this.onImageCreated(communicator, imageId);
|
|
257
|
+
return await this.onImageCreated(communicator, this.extractEventValueId(value));
|
|
251
258
|
}
|
|
252
259
|
else if (event === EventName.ImageUpdated) {
|
|
253
|
-
|
|
254
|
-
return await this.onImageUpdated(communicator, imageId);
|
|
260
|
+
return await this.onImageUpdated(communicator, this.extractEventValueId(value));
|
|
255
261
|
}
|
|
256
262
|
else if (event === EventName.ImageDeleted) {
|
|
257
|
-
|
|
258
|
-
return await this.onImageDeleted(communicator, imageId);
|
|
263
|
+
return await this.onImageDeleted(communicator, this.extractEventValueId(value));
|
|
259
264
|
}
|
|
260
265
|
else if (event === EventName.ImageTagsUpdated) {
|
|
261
|
-
|
|
262
|
-
return await this.onImageTagsUpdated(communicator, imageId);
|
|
266
|
+
return await this.onImageTagsUpdated(communicator, this.extractEventValueId(value));
|
|
263
267
|
}
|
|
264
268
|
else if (event === EventName.ImageFeaturesUpdated) {
|
|
265
|
-
|
|
266
|
-
return await this.onImageFeaturesUpdated(communicator, imageId);
|
|
269
|
+
return await this.onImageFeaturesUpdated(communicator, this.extractEventValueId(value));
|
|
267
270
|
}
|
|
268
271
|
else if (event === EventName.ImageComputeTags) {
|
|
269
|
-
|
|
270
|
-
return await this.onComputeImageTags(communicator, imageId);
|
|
272
|
+
return await this.onComputeImageTags(communicator, this.extractEventValueId(value));
|
|
271
273
|
}
|
|
272
274
|
else if (event === EventName.ImageComputeFeatures) {
|
|
273
|
-
|
|
274
|
-
return await this.onComputeImageFeatures(communicator, imageId);
|
|
275
|
+
return await this.onComputeImageFeatures(communicator, this.extractEventValueId(value));
|
|
275
276
|
}
|
|
276
277
|
else if (event === EventName.ImageComputeEmbeddings) {
|
|
277
|
-
|
|
278
|
-
return await this.onComputeImageEmbeddings(communicator, imageId);
|
|
278
|
+
return await this.onComputeImageEmbeddings(communicator, this.extractEventValueId(value));
|
|
279
279
|
}
|
|
280
280
|
else if (event === EventName.ImageRunCommand) {
|
|
281
|
-
const commandId = value["commandId"];
|
|
282
281
|
const imageIds = value["imageIds"];
|
|
283
282
|
const parameters = value["parameters"] ?? {};
|
|
284
|
-
return await this.onImagesCommand(communicator,
|
|
283
|
+
return await this.onImagesCommand(communicator, this.extractEventCommandId(value), imageIds, parameters);
|
|
285
284
|
}
|
|
286
285
|
else if (event === EventName.ProcessRunCommand) {
|
|
287
|
-
const commandId = value["commandId"];
|
|
288
286
|
const parameters = value["parameters"] ?? {};
|
|
289
|
-
return await this.onProcessCommand(communicator,
|
|
287
|
+
return await this.onProcessCommand(communicator, this.extractEventCommandId(value), parameters);
|
|
290
288
|
}
|
|
291
289
|
else if (event === EventName.TextComputeEmbeddings) {
|
|
292
290
|
const text = value["text"];
|
|
@@ -386,7 +384,8 @@ export class PicteusExtension {
|
|
|
386
384
|
return this.toString();
|
|
387
385
|
}, contextId);
|
|
388
386
|
sender.maximumPayloadSizeInBytes = globalSender.maximumPayloadSizeInBytes;
|
|
389
|
-
const
|
|
387
|
+
const entity = this.computeEventEntity(channel, value);
|
|
388
|
+
const communicator = new Communicator(this.logger, sender, entity);
|
|
390
389
|
const requiresResult = channel !== extensionSettingsChannel;
|
|
391
390
|
let result;
|
|
392
391
|
let success = false;
|
|
@@ -486,4 +485,26 @@ export class PicteusExtension {
|
|
|
486
485
|
]
|
|
487
486
|
});
|
|
488
487
|
}
|
|
488
|
+
computeEventEntity(channel, value) {
|
|
489
|
+
const imageComputationEvents = new Set([
|
|
490
|
+
EventName.ImageCreated,
|
|
491
|
+
EventName.ImageUpdated,
|
|
492
|
+
EventName.ImageTagsUpdated,
|
|
493
|
+
EventName.ImageFeaturesUpdated,
|
|
494
|
+
EventName.ImageDeleted,
|
|
495
|
+
EventName.ImageComputeTags,
|
|
496
|
+
EventName.ImageComputeFeatures,
|
|
497
|
+
EventName.ImageComputeEmbeddings
|
|
498
|
+
]);
|
|
499
|
+
if (imageComputationEvents.has(channel) === false) {
|
|
500
|
+
return undefined;
|
|
501
|
+
}
|
|
502
|
+
return { type: "image", id: this.extractEventValueId(value) };
|
|
503
|
+
}
|
|
504
|
+
extractEventValueId(value) {
|
|
505
|
+
return value["id"];
|
|
506
|
+
}
|
|
507
|
+
extractEventCommandId(value) {
|
|
508
|
+
return value["commandId"];
|
|
509
|
+
}
|
|
489
510
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picteus/extension-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"productName": "Picteus TypeScript SDK",
|
|
5
5
|
"description": "The Picteus extension TypeScript SDK.",
|
|
6
6
|
"keywords": [
|
|
@@ -38,14 +38,12 @@
|
|
|
38
38
|
"./dist"
|
|
39
39
|
],
|
|
40
40
|
"scripts": {
|
|
41
|
-
"compile": "tsc && tsc-alias --resolve-full-paths"
|
|
42
|
-
"compileWithTsup": "tsup src/index.ts --tsconfig tsconfig.json --format cjs,esm --dts --clean --minify-whitespace --minify-identifiers --minify-syntax"
|
|
41
|
+
"compile": "tsc && tsc-alias --resolve-full-paths"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
44
|
"typescript": "5.9.2",
|
|
46
|
-
"@types/node": "
|
|
47
|
-
"tsc-alias": "1.8.17"
|
|
48
|
-
"tsup": "8.5.1"
|
|
45
|
+
"@types/node": "22.17.1",
|
|
46
|
+
"tsc-alias": "1.8.17"
|
|
49
47
|
},
|
|
50
48
|
"dependencies": {
|
|
51
49
|
"socket.io-client": "4.8.3"
|