@picteus/extension-sdk 0.13.1 → 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/intents.d.ts +64 -1
- package/dist/intents.js +6 -0
- package/dist/picteus-ws-client/apis/AdministrationApi.d.ts +1 -1
- package/dist/picteus-ws-client/apis/AdministrationApi.js +1 -1
- package/dist/picteus-ws-client/apis/ApiSecretApi.d.ts +1 -1
- package/dist/picteus-ws-client/apis/ApiSecretApi.js +1 -1
- package/dist/picteus-ws-client/apis/CollectionApi.d.ts +1 -1
- package/dist/picteus-ws-client/apis/CollectionApi.js +1 -1
- package/dist/picteus-ws-client/apis/ExtensionApi.d.ts +35 -10
- package/dist/picteus-ws-client/apis/ExtensionApi.js +38 -10
- package/dist/picteus-ws-client/apis/ImageApi.d.ts +108 -50
- package/dist/picteus-ws-client/apis/ImageApi.js +123 -44
- package/dist/picteus-ws-client/apis/ImageAttachmentApi.d.ts +1 -1
- package/dist/picteus-ws-client/apis/ImageAttachmentApi.js +1 -1
- package/dist/picteus-ws-client/apis/MiscellaneousApi.d.ts +24 -23
- package/dist/picteus-ws-client/apis/MiscellaneousApi.js +19 -23
- package/dist/picteus-ws-client/apis/RepositoryApi.d.ts +25 -2
- package/dist/picteus-ws-client/apis/RepositoryApi.js +29 -2
- package/dist/picteus-ws-client/apis/SettingsApi.d.ts +12 -12
- package/dist/picteus-ws-client/apis/SettingsApi.js +7 -7
- package/dist/picteus-ws-client/models/ApiSecret.d.ts +1 -1
- package/dist/picteus-ws-client/models/ApiSecret.js +1 -1
- package/dist/picteus-ws-client/models/ApiSecretSummary.d.ts +1 -1
- package/dist/picteus-ws-client/models/ApiSecretSummary.js +1 -1
- package/dist/picteus-ws-client/models/ApiSecretType.d.ts +1 -1
- package/dist/picteus-ws-client/models/ApiSecretType.js +1 -1
- package/dist/picteus-ws-client/models/ApplicationConfiguration.d.ts +32 -0
- package/dist/picteus-ws-client/models/ApplicationConfiguration.js +41 -0
- package/dist/picteus-ws-client/models/ApplicationMetadata.d.ts +1 -1
- package/dist/picteus-ws-client/models/ApplicationMetadata.js +1 -1
- package/dist/picteus-ws-client/models/ApplicationMetadataItem.d.ts +1 -1
- package/dist/picteus-ws-client/models/ApplicationMetadataItem.js +1 -1
- package/dist/picteus-ws-client/models/ApplicationMetadataItemValue.d.ts +1 -1
- package/dist/picteus-ws-client/models/ApplicationMetadataItemValue.js +1 -1
- package/dist/picteus-ws-client/models/ApplicationSettings.d.ts +32 -0
- package/dist/picteus-ws-client/models/ApplicationSettings.js +41 -0
- package/dist/picteus-ws-client/models/Collection.d.ts +1 -1
- package/dist/picteus-ws-client/models/Collection.js +1 -1
- package/dist/picteus-ws-client/models/CommandEntity.d.ts +1 -1
- package/dist/picteus-ws-client/models/CommandEntity.js +1 -1
- package/dist/picteus-ws-client/models/ComputedImageFormat.d.ts +1 -1
- package/dist/picteus-ws-client/models/ComputedImageFormat.js +1 -1
- package/dist/picteus-ws-client/models/ConfigurationCapability.d.ts +1 -1
- package/dist/picteus-ws-client/models/ConfigurationCapability.js +1 -1
- package/dist/picteus-ws-client/models/ConfigurationExtensionCommand.d.ts +1 -1
- package/dist/picteus-ws-client/models/ConfigurationExtensionCommand.js +1 -1
- package/dist/picteus-ws-client/models/ConstantsRegistry.d.ts +1 -1
- package/dist/picteus-ws-client/models/ConstantsRegistry.js +1 -1
- package/dist/picteus-ws-client/models/Dates.d.ts +1 -1
- package/dist/picteus-ws-client/models/Dates.js +1 -1
- package/dist/picteus-ws-client/models/Extension.d.ts +1 -1
- package/dist/picteus-ws-client/models/Extension.js +1 -1
- package/dist/picteus-ws-client/models/ExtensionActivity.d.ts +1 -1
- package/dist/picteus-ws-client/models/ExtensionActivity.js +1 -1
- package/dist/picteus-ws-client/models/ExtensionActivityKind.d.ts +1 -1
- package/dist/picteus-ws-client/models/ExtensionActivityKind.js +1 -1
- package/dist/picteus-ws-client/models/ExtensionAndManual.d.ts +1 -1
- package/dist/picteus-ws-client/models/ExtensionAndManual.js +1 -1
- package/dist/picteus-ws-client/models/ExtensionCategory.d.ts +29 -0
- package/dist/picteus-ws-client/models/ExtensionCategory.js +47 -0
- package/dist/picteus-ws-client/models/ExtensionGenerationOptions.d.ts +14 -1
- package/dist/picteus-ws-client/models/ExtensionGenerationOptions.js +8 -1
- package/dist/picteus-ws-client/models/ExtensionIdImageEmbeddingName.d.ts +38 -0
- package/dist/picteus-ws-client/models/ExtensionIdImageEmbeddingName.js +47 -0
- package/dist/picteus-ws-client/models/ExtensionImageEmbeddings.d.ts +8 -7
- package/dist/picteus-ws-client/models/ExtensionImageEmbeddings.js +6 -5
- package/dist/picteus-ws-client/models/ExtensionImageFeature.d.ts +1 -1
- package/dist/picteus-ws-client/models/ExtensionImageFeature.js +1 -1
- package/dist/picteus-ws-client/models/ExtensionImageFeatureName.d.ts +1 -1
- package/dist/picteus-ws-client/models/ExtensionImageFeatureName.js +1 -1
- package/dist/picteus-ws-client/models/ExtensionImageFeaturesAttribute.d.ts +1 -1
- package/dist/picteus-ws-client/models/ExtensionImageFeaturesAttribute.js +1 -1
- package/dist/picteus-ws-client/models/ExtensionImageTag.d.ts +1 -1
- package/dist/picteus-ws-client/models/ExtensionImageTag.js +1 -1
- package/dist/picteus-ws-client/models/ExtensionImageTagsAttribute.d.ts +1 -1
- package/dist/picteus-ws-client/models/ExtensionImageTagsAttribute.js +1 -1
- package/dist/picteus-ws-client/models/ExtensionManual.d.ts +1 -1
- package/dist/picteus-ws-client/models/ExtensionManual.js +1 -1
- package/dist/picteus-ws-client/models/ExtensionSettings.d.ts +1 -1
- package/dist/picteus-ws-client/models/ExtensionSettings.js +1 -1
- package/dist/picteus-ws-client/models/ExtensionStatus.d.ts +1 -1
- package/dist/picteus-ws-client/models/ExtensionStatus.js +1 -1
- package/dist/picteus-ws-client/models/ExtensionsConfiguration.d.ts +1 -1
- package/dist/picteus-ws-client/models/ExtensionsConfiguration.js +1 -1
- package/dist/picteus-ws-client/models/GenerationRecipe.d.ts +1 -1
- package/dist/picteus-ws-client/models/GenerationRecipe.js +1 -1
- package/dist/picteus-ws-client/models/GenerationRecipePrompt.d.ts +1 -1
- package/dist/picteus-ws-client/models/GenerationRecipePrompt.js +1 -1
- package/dist/picteus-ws-client/models/Image.d.ts +1 -1
- package/dist/picteus-ws-client/models/Image.js +1 -1
- package/dist/picteus-ws-client/models/ImageDimensions.d.ts +1 -1
- package/dist/picteus-ws-client/models/ImageDimensions.js +1 -1
- package/dist/picteus-ws-client/models/ImageDistance.d.ts +1 -1
- package/dist/picteus-ws-client/models/ImageDistance.js +1 -1
- package/dist/picteus-ws-client/models/ImageEmbedding.d.ts +38 -0
- package/dist/picteus-ws-client/models/ImageEmbedding.js +47 -0
- package/dist/picteus-ws-client/models/ImageEmbeddings.d.ts +1 -1
- package/dist/picteus-ws-client/models/ImageEmbeddings.js +1 -1
- package/dist/picteus-ws-client/models/ImageFeature.d.ts +1 -1
- package/dist/picteus-ws-client/models/ImageFeature.js +1 -1
- package/dist/picteus-ws-client/models/ImageFeatureFormat.d.ts +1 -1
- package/dist/picteus-ws-client/models/ImageFeatureFormat.js +1 -1
- package/dist/picteus-ws-client/models/ImageFeatureNullValue.d.ts +1 -1
- package/dist/picteus-ws-client/models/ImageFeatureNullValue.js +1 -1
- package/dist/picteus-ws-client/models/ImageFeatureType.d.ts +1 -1
- package/dist/picteus-ws-client/models/ImageFeatureType.js +1 -1
- package/dist/picteus-ws-client/models/ImageFeatureValue.d.ts +4 -9
- package/dist/picteus-ws-client/models/ImageFeatureValue.js +33 -9
- package/dist/picteus-ws-client/models/ImageFormat.d.ts +2 -2
- package/dist/picteus-ws-client/models/ImageFormat.js +2 -2
- package/dist/picteus-ws-client/models/ImageMediaUrl.d.ts +1 -1
- package/dist/picteus-ws-client/models/ImageMediaUrl.js +1 -1
- package/dist/picteus-ws-client/models/ImageMetadata.d.ts +1 -1
- package/dist/picteus-ws-client/models/ImageMetadata.js +1 -1
- package/dist/picteus-ws-client/models/ImageResizeRender.d.ts +1 -1
- package/dist/picteus-ws-client/models/ImageResizeRender.js +1 -1
- package/dist/picteus-ws-client/models/ImageSummary.d.ts +1 -1
- package/dist/picteus-ws-client/models/ImageSummary.js +1 -1
- package/dist/picteus-ws-client/models/InstructionsPrompt.d.ts +1 -1
- package/dist/picteus-ws-client/models/InstructionsPrompt.js +1 -1
- package/dist/picteus-ws-client/models/Manifest.d.ts +9 -2
- package/dist/picteus-ws-client/models/Manifest.js +6 -1
- package/dist/picteus-ws-client/models/ManifestCapability.d.ts +1 -1
- package/dist/picteus-ws-client/models/ManifestCapability.js +1 -1
- package/dist/picteus-ws-client/models/ManifestCapabilityId.d.ts +1 -1
- package/dist/picteus-ws-client/models/ManifestCapabilityId.js +1 -1
- package/dist/picteus-ws-client/models/ManifestEvent.d.ts +3 -1
- package/dist/picteus-ws-client/models/ManifestEvent.js +3 -1
- package/dist/picteus-ws-client/models/ManifestExecution.d.ts +1 -1
- package/dist/picteus-ws-client/models/ManifestExecution.js +1 -1
- package/dist/picteus-ws-client/models/ManifestExtensionCommand.d.ts +8 -1
- package/dist/picteus-ws-client/models/ManifestExtensionCommand.js +4 -1
- package/dist/picteus-ws-client/models/ManifestExtensionCommandOn.d.ts +1 -1
- package/dist/picteus-ws-client/models/ManifestExtensionCommandOn.js +1 -1
- package/dist/picteus-ws-client/models/ManifestExtensionCommandSpecification.d.ts +10 -4
- package/dist/picteus-ws-client/models/ManifestExtensionCommandSpecification.js +4 -4
- package/dist/picteus-ws-client/models/ManifestExtensionCommandUi.d.ts +32 -0
- package/dist/picteus-ws-client/models/ManifestExtensionCommandUi.js +43 -0
- package/dist/picteus-ws-client/models/ManifestInstructions.d.ts +1 -1
- package/dist/picteus-ws-client/models/ManifestInstructions.js +1 -1
- package/dist/picteus-ws-client/models/ManifestInterfaceElement.d.ts +1 -1
- package/dist/picteus-ws-client/models/ManifestInterfaceElement.js +1 -1
- package/dist/picteus-ws-client/models/ManifestInterfaceElementIntegration.d.ts +1 -1
- package/dist/picteus-ws-client/models/ManifestInterfaceElementIntegration.js +1 -1
- package/dist/picteus-ws-client/models/ManifestRuntime.d.ts +1 -1
- package/dist/picteus-ws-client/models/ManifestRuntime.js +1 -1
- package/dist/picteus-ws-client/models/ManifestRuntimeEnvironment.d.ts +1 -1
- package/dist/picteus-ws-client/models/ManifestRuntimeEnvironment.js +1 -1
- package/dist/picteus-ws-client/models/ManifestThrottlingPolicy.d.ts +1 -1
- package/dist/picteus-ws-client/models/ManifestThrottlingPolicy.js +1 -1
- package/dist/picteus-ws-client/models/ManifestUserInterface.d.ts +3 -3
- package/dist/picteus-ws-client/models/ManifestUserInterface.js +1 -1
- package/dist/picteus-ws-client/models/PromptKind.d.ts +1 -1
- package/dist/picteus-ws-client/models/PromptKind.js +1 -1
- package/dist/picteus-ws-client/models/Repository.d.ts +1 -1
- package/dist/picteus-ws-client/models/Repository.js +1 -1
- package/dist/picteus-ws-client/models/RepositoryActivity.d.ts +1 -1
- package/dist/picteus-ws-client/models/RepositoryActivity.js +1 -1
- package/dist/picteus-ws-client/models/RepositoryActivityKind.d.ts +1 -1
- package/dist/picteus-ws-client/models/RepositoryActivityKind.js +1 -1
- package/dist/picteus-ws-client/models/RepositoryLocationType.d.ts +1 -1
- package/dist/picteus-ws-client/models/RepositoryLocationType.js +1 -1
- package/dist/picteus-ws-client/models/RepositoryStatus.d.ts +1 -1
- package/dist/picteus-ws-client/models/RepositoryStatus.js +1 -1
- package/dist/picteus-ws-client/models/RunCommandParameters.d.ts +39 -0
- package/dist/picteus-ws-client/models/RunCommandParameters.js +46 -0
- package/dist/picteus-ws-client/models/SearchCriteria.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchCriteria.js +1 -1
- package/dist/picteus-ws-client/models/SearchFeatureComparisonOperator.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchFeatureComparisonOperator.js +1 -1
- package/dist/picteus-ws-client/models/SearchFeatureCondition.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchFeatureCondition.js +1 -1
- package/dist/picteus-ws-client/models/SearchFeatureConditionValue.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchFeatureConditionValue.js +1 -1
- package/dist/picteus-ws-client/models/SearchFeatureLogicalOperator.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchFeatureLogicalOperator.js +1 -1
- package/dist/picteus-ws-client/models/SearchFeatures.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchFeatures.js +1 -1
- package/dist/picteus-ws-client/models/SearchFeaturesResult.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchFeaturesResult.js +1 -1
- package/dist/picteus-ws-client/models/SearchFilter.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchFilter.js +1 -1
- package/dist/picteus-ws-client/models/SearchFilterOrigin.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchFilterOrigin.js +1 -1
- package/dist/picteus-ws-client/models/SearchImageIdResult.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchImageIdResult.js +1 -1
- package/dist/picteus-ws-client/models/SearchImageResult.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchImageResult.js +1 -1
- package/dist/picteus-ws-client/models/SearchImageSummaryResult.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchImageSummaryResult.js +1 -1
- package/dist/picteus-ws-client/models/SearchImagesOrigin.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchImagesOrigin.js +1 -1
- package/dist/picteus-ws-client/models/SearchKeyword.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchKeyword.js +1 -1
- package/dist/picteus-ws-client/models/SearchMediaUrlResult.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchMediaUrlResult.js +1 -1
- package/dist/picteus-ws-client/models/SearchOriginNature.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchOriginNature.js +1 -1
- package/dist/picteus-ws-client/models/SearchParameters.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchParameters.js +1 -1
- package/dist/picteus-ws-client/models/SearchProperties.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchProperties.js +1 -1
- package/dist/picteus-ws-client/models/SearchPropertyRange.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchPropertyRange.js +1 -1
- package/dist/picteus-ws-client/models/SearchRange.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchRange.js +1 -1
- package/dist/picteus-ws-client/models/SearchRepositoriesOrigin.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchRepositoriesOrigin.js +1 -1
- package/dist/picteus-ws-client/models/SearchSorting.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchSorting.js +1 -1
- package/dist/picteus-ws-client/models/SearchSortingProperty.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchSortingProperty.js +1 -1
- package/dist/picteus-ws-client/models/SearchTags.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchTags.js +1 -1
- package/dist/picteus-ws-client/models/SearchTagsResult.d.ts +1 -1
- package/dist/picteus-ws-client/models/SearchTagsResult.js +1 -1
- package/dist/picteus-ws-client/models/Software.d.ts +1 -1
- package/dist/picteus-ws-client/models/Software.js +1 -1
- package/dist/picteus-ws-client/models/TextualPrompt.d.ts +1 -1
- package/dist/picteus-ws-client/models/TextualPrompt.js +1 -1
- package/dist/picteus-ws-client/models/UserInterfaceAnchor.d.ts +1 -1
- package/dist/picteus-ws-client/models/UserInterfaceAnchor.js +1 -1
- package/dist/picteus-ws-client/models/UserInterfaceSidebarIntegration.d.ts +1 -1
- package/dist/picteus-ws-client/models/UserInterfaceSidebarIntegration.js +1 -1
- package/dist/picteus-ws-client/models/UserInterfaceWindowIntegration.d.ts +1 -1
- package/dist/picteus-ws-client/models/UserInterfaceWindowIntegration.js +1 -1
- package/dist/picteus-ws-client/models/index.d.ts +7 -2
- package/dist/picteus-ws-client/models/index.js +7 -2
- package/dist/picteus-ws-client/runtime.d.ts +1 -1
- package/dist/picteus-ws-client/runtime.js +1 -1
- package/dist/picteusExtension.d.ts +52 -26
- package/dist/picteusExtension.js +184 -57
- package/package.json +1 -1
package/dist/picteusExtension.js
CHANGED
|
@@ -4,34 +4,40 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
// We do not import the "process" package on purpose, otherwise we get the runtime error "process.on is not a function"
|
|
5
5
|
import console from "node:console";
|
|
6
6
|
import { io } from "socket.io-client";
|
|
7
|
-
import { ApiSecretApi, Configuration, ExtensionApi, ImageApi, ImageAttachmentApi, ManifestFromJSON, MiscellaneousApi, RepositoryApi } from "./index.js";
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
NotificationReturnedErrorCause[NotificationReturnedErrorCause["Cancel"] = 0] = "Cancel";
|
|
11
|
-
NotificationReturnedErrorCause[NotificationReturnedErrorCause["Error"] = 1] = "Error";
|
|
12
|
-
})(NotificationReturnedErrorCause || (NotificationReturnedErrorCause = {}));
|
|
13
|
-
export class NotificationReturnedError extends Error {
|
|
7
|
+
import { ApiSecretApi, CollectionApi, Configuration, ExtensionApi, ImageApi, ImageAttachmentApi, IntentToastType, ManifestFromJSON, MiscellaneousApi, RepositoryApi } from "./index.js";
|
|
8
|
+
export const InstructionReturnedErrorCause = { Cancel: 0, Error: 1 };
|
|
9
|
+
export class InstructionReturnedError extends Error {
|
|
14
10
|
reason;
|
|
15
11
|
constructor(message, reason) {
|
|
16
12
|
super(message);
|
|
17
13
|
this.reason = reason;
|
|
18
14
|
}
|
|
19
15
|
}
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
16
|
+
export class CommandError extends Error {
|
|
17
|
+
static fromError(error) {
|
|
18
|
+
return new CommandError(error.message);
|
|
19
|
+
}
|
|
20
|
+
constructor(message) {
|
|
21
|
+
super(message);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export const EventName = {
|
|
25
|
+
ProcessRunCommand: "process.runCommand",
|
|
26
|
+
ImageCreated: "image.created",
|
|
27
|
+
ImageUpdated: "image.updated",
|
|
28
|
+
ImageTagsUpdated: "image.tags.updated",
|
|
29
|
+
ImageFeaturesUpdated: "image.features.updated",
|
|
30
|
+
ImageDeleted: "image.deleted",
|
|
31
|
+
ImageComputeFeatures: "image.computeFeatures",
|
|
32
|
+
ImageComputeEmbeddings: "image.computeEmbeddings",
|
|
33
|
+
ImageComputeTags: "image.computeTags",
|
|
34
|
+
ImageRunCommand: "image.runCommand",
|
|
35
|
+
TextComputeEmbeddings: "text.computeEmbeddings"
|
|
36
|
+
};
|
|
37
|
+
const extensionVersionsChannel = "extension.versions";
|
|
38
|
+
const extensionReadyChannel = "extension.ready";
|
|
39
|
+
const extensionSettingsChannel = "extension.settings";
|
|
40
|
+
// noinspection JSUnusedGlobalSymbols
|
|
35
41
|
export class Helper {
|
|
36
42
|
static GENERATION_RECIPE_SCHEMA_VERSION = 1;
|
|
37
43
|
}
|
|
@@ -77,7 +83,7 @@ const stringifyWithStrippedBuffers = (object) => {
|
|
|
77
83
|
const bufferReplacement = "<bytes>";
|
|
78
84
|
return JSON.stringify(object, (_key, value) => {
|
|
79
85
|
// We check if the value is a Buffer
|
|
80
|
-
if (value !== undefined && value.type === "Buffer" && Array.isArray(value.data) === true) {
|
|
86
|
+
if (value !== undefined && value !== null && value.type === "Buffer" && Array.isArray(value.data) === true) {
|
|
81
87
|
return bufferReplacement;
|
|
82
88
|
}
|
|
83
89
|
// We also check for native Buffer instances if they haven't been pre-processed
|
|
@@ -93,6 +99,7 @@ class MessageSender {
|
|
|
93
99
|
socket;
|
|
94
100
|
toString;
|
|
95
101
|
contextId;
|
|
102
|
+
_maximumPayloadSizeInBytes;
|
|
96
103
|
constructor(logger, parameters, socket, toString, contextId) {
|
|
97
104
|
this.logger = logger;
|
|
98
105
|
this.parameters = parameters;
|
|
@@ -100,9 +107,12 @@ class MessageSender {
|
|
|
100
107
|
this.toString = toString;
|
|
101
108
|
this.contextId = contextId;
|
|
102
109
|
}
|
|
103
|
-
|
|
110
|
+
set maximumPayloadSizeInBytes(value) {
|
|
111
|
+
this._maximumPayloadSizeInBytes = value;
|
|
112
|
+
}
|
|
113
|
+
sendMessage(event, body, callback) {
|
|
104
114
|
const contextId = this.contextId;
|
|
105
|
-
this.logger.debug(`Sending the message '${stringifyWithStrippedBuffers(body)}'
|
|
115
|
+
this.logger.debug(`Sending the message '${stringifyWithStrippedBuffers(body)}' through the '${event}' event for ${this.toString()}${contextId === undefined ? "" : ` attached to the context with id '${contextId}'`}${callback === undefined ? "" : " and waiting for a callback"}`);
|
|
106
116
|
const value = {
|
|
107
117
|
extensionId: this.parameters.extensionId,
|
|
108
118
|
...body
|
|
@@ -115,14 +125,14 @@ class MessageSender {
|
|
|
115
125
|
value.contextId = contextId;
|
|
116
126
|
}
|
|
117
127
|
if (callback === undefined) {
|
|
118
|
-
this.socket.emit(
|
|
128
|
+
this.socket.emit(event, value);
|
|
119
129
|
}
|
|
120
130
|
else {
|
|
121
|
-
this.socket.emit(
|
|
131
|
+
this.socket.emit(event, value, callback);
|
|
122
132
|
}
|
|
123
133
|
}
|
|
124
134
|
}
|
|
125
|
-
const
|
|
135
|
+
const instructionsEvent = "instructions";
|
|
126
136
|
export class Communicator {
|
|
127
137
|
logger;
|
|
128
138
|
sender;
|
|
@@ -132,20 +142,21 @@ export class Communicator {
|
|
|
132
142
|
}
|
|
133
143
|
sendLog(message, level) {
|
|
134
144
|
this.logger[level](message);
|
|
135
|
-
this.sendMessage(
|
|
145
|
+
this.sendMessage(instructionsEvent, { log: { message, level } });
|
|
136
146
|
}
|
|
147
|
+
// noinspection JSUnusedGlobalSymbols
|
|
137
148
|
sendNotification(value) {
|
|
138
|
-
this.sendMessage(
|
|
149
|
+
this.sendMessage(instructionsEvent, { notification: value });
|
|
139
150
|
}
|
|
140
151
|
async launchIntent(intent) {
|
|
141
152
|
return await new Promise((resolve, reject) => {
|
|
142
|
-
this.sendMessage(
|
|
153
|
+
this.sendMessage(instructionsEvent, { intent }, async ({ value, cancel, error }) => {
|
|
143
154
|
this.logger.debug(`Received a result related to the intent '${stringifyWithStrippedBuffers(intent)}' for ${this.sender.toString()}`);
|
|
144
155
|
if (cancel !== undefined) {
|
|
145
|
-
reject(new
|
|
156
|
+
reject(new InstructionReturnedError(cancel, InstructionReturnedErrorCause.Cancel));
|
|
146
157
|
}
|
|
147
158
|
else if (error !== undefined) {
|
|
148
|
-
reject(new
|
|
159
|
+
reject(new InstructionReturnedError(error, InstructionReturnedErrorCause.Error));
|
|
149
160
|
}
|
|
150
161
|
else {
|
|
151
162
|
resolve(value);
|
|
@@ -153,8 +164,8 @@ export class Communicator {
|
|
|
153
164
|
});
|
|
154
165
|
});
|
|
155
166
|
}
|
|
156
|
-
sendMessage(
|
|
157
|
-
this.sender.sendMessage(
|
|
167
|
+
sendMessage(event, body, callback) {
|
|
168
|
+
this.sender.sendMessage(event, body, callback);
|
|
158
169
|
}
|
|
159
170
|
}
|
|
160
171
|
export class PicteusExtension {
|
|
@@ -164,6 +175,7 @@ export class PicteusExtension {
|
|
|
164
175
|
static getSdkVersion() {
|
|
165
176
|
return JSON.parse(fs.readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "package.json"), { encoding: "utf8" })).version;
|
|
166
177
|
}
|
|
178
|
+
// noinspection JSUnusedGlobalSymbols
|
|
167
179
|
static getCacheDirectoryPath() {
|
|
168
180
|
return path.join(PicteusExtension.getExtensionHomeDirectoryPath(), ".cache");
|
|
169
181
|
}
|
|
@@ -178,7 +190,6 @@ export class PicteusExtension {
|
|
|
178
190
|
apiKey;
|
|
179
191
|
configuration;
|
|
180
192
|
socket;
|
|
181
|
-
globalCommunicator;
|
|
182
193
|
constructor() {
|
|
183
194
|
this.logger.info(`Instantiating the ${this.toString()} through the process with id '${process.pid}' relying on the SDK version '${PicteusExtension.getSdkVersion()}'`);
|
|
184
195
|
process.on("SIGTERM", async (signal) => {
|
|
@@ -205,8 +216,7 @@ export class PicteusExtension {
|
|
|
205
216
|
result = await this.initialize();
|
|
206
217
|
}
|
|
207
218
|
catch (error) {
|
|
208
|
-
this.
|
|
209
|
-
process.exit(1);
|
|
219
|
+
this.exit(1, error, "the initialization failed");
|
|
210
220
|
}
|
|
211
221
|
try {
|
|
212
222
|
if (result === true) {
|
|
@@ -214,8 +224,7 @@ export class PicteusExtension {
|
|
|
214
224
|
this.connectSocket();
|
|
215
225
|
}
|
|
216
226
|
catch (error) {
|
|
217
|
-
this.
|
|
218
|
-
process.exit(2);
|
|
227
|
+
this.exit(2, error, "the connection failed");
|
|
219
228
|
}
|
|
220
229
|
}
|
|
221
230
|
else {
|
|
@@ -227,39 +236,119 @@ export class PicteusExtension {
|
|
|
227
236
|
}
|
|
228
237
|
}
|
|
229
238
|
toString() {
|
|
230
|
-
return `extension
|
|
239
|
+
return `extension${this.extensionId === undefined ? "" : ` with id '${this.extensionId}'`} of class '${this.constructor.name}'`;
|
|
231
240
|
}
|
|
232
241
|
async initialize() {
|
|
233
242
|
return true;
|
|
234
243
|
}
|
|
235
|
-
async
|
|
244
|
+
async onUpgrade(_communicator, _versions) {
|
|
245
|
+
}
|
|
246
|
+
async onReady(_communicator) {
|
|
236
247
|
}
|
|
237
248
|
async onTerminate() {
|
|
238
249
|
}
|
|
239
|
-
async onSettings(
|
|
240
|
-
return Promise.resolve();
|
|
250
|
+
async onSettings(_communicator, _value) {
|
|
241
251
|
}
|
|
242
|
-
// noinspection JSUnusedLocalSymbols
|
|
243
252
|
async onEvent(communicator, event, value) {
|
|
253
|
+
if (event === EventName.ImageCreated) {
|
|
254
|
+
const imageId = value["id"];
|
|
255
|
+
return await this.onImageCreated(communicator, imageId);
|
|
256
|
+
}
|
|
257
|
+
else if (event === EventName.ImageUpdated) {
|
|
258
|
+
const imageId = value["id"];
|
|
259
|
+
return await this.onImageUpdated(communicator, imageId);
|
|
260
|
+
}
|
|
261
|
+
else if (event === EventName.ImageDeleted) {
|
|
262
|
+
const imageId = value["id"];
|
|
263
|
+
return await this.onImageDeleted(communicator, imageId);
|
|
264
|
+
}
|
|
265
|
+
else if (event === EventName.ImageTagsUpdated) {
|
|
266
|
+
const imageId = value["id"];
|
|
267
|
+
return await this.onImageTagsUpdated(communicator, imageId);
|
|
268
|
+
}
|
|
269
|
+
else if (event === EventName.ImageFeaturesUpdated) {
|
|
270
|
+
const imageId = value["id"];
|
|
271
|
+
return await this.onImageFeaturesUpdated(communicator, imageId);
|
|
272
|
+
}
|
|
273
|
+
else if (event === EventName.ImageComputeTags) {
|
|
274
|
+
const imageId = value["id"];
|
|
275
|
+
return await this.onComputeImageTags(communicator, imageId);
|
|
276
|
+
}
|
|
277
|
+
else if (event === EventName.ImageComputeFeatures) {
|
|
278
|
+
const imageId = value["id"];
|
|
279
|
+
return await this.onComputeImageFeatures(communicator, imageId);
|
|
280
|
+
}
|
|
281
|
+
else if (event === EventName.ImageComputeEmbeddings) {
|
|
282
|
+
const imageId = value["id"];
|
|
283
|
+
return await this.onComputeImageEmbeddings(communicator, imageId);
|
|
284
|
+
}
|
|
285
|
+
else if (event === EventName.ImageRunCommand) {
|
|
286
|
+
const commandId = value["commandId"];
|
|
287
|
+
const imageIds = value["imageIds"];
|
|
288
|
+
const parameters = value["parameters"] ?? {};
|
|
289
|
+
return await this.onImagesCommand(communicator, commandId, imageIds, parameters);
|
|
290
|
+
}
|
|
291
|
+
else if (event === EventName.ProcessRunCommand) {
|
|
292
|
+
const commandId = value["commandId"];
|
|
293
|
+
const parameters = value["parameters"] ?? {};
|
|
294
|
+
return await this.onProcessCommand(communicator, commandId, parameters);
|
|
295
|
+
}
|
|
296
|
+
else if (event === EventName.TextComputeEmbeddings) {
|
|
297
|
+
const text = value["text"];
|
|
298
|
+
return await this.onComputeTextEmbeddings(communicator, text);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
async onImageCreated(_communicator, _imageId) {
|
|
302
|
+
}
|
|
303
|
+
async onImageUpdated(_communicator, _imageId) {
|
|
304
|
+
}
|
|
305
|
+
async onImageDeleted(_communicator, _imageId) {
|
|
244
306
|
}
|
|
307
|
+
async onImageTagsUpdated(_communicator, _imageId) {
|
|
308
|
+
}
|
|
309
|
+
async onImageFeaturesUpdated(_communicator, _imageId) {
|
|
310
|
+
}
|
|
311
|
+
async onComputeImageTags(_communicator, _imageId) {
|
|
312
|
+
}
|
|
313
|
+
async onComputeImageFeatures(_communicator, _imageId) {
|
|
314
|
+
}
|
|
315
|
+
async onComputeImageEmbeddings(_communicator, _imageId) {
|
|
316
|
+
}
|
|
317
|
+
async onImagesCommand(_communicator, _commandId, _imageIds, _parameters) {
|
|
318
|
+
}
|
|
319
|
+
async onProcessCommand(_communicator, _commandId, _parameters) {
|
|
320
|
+
}
|
|
321
|
+
async onComputeTextEmbeddings(_communicator, _text) {
|
|
322
|
+
return [];
|
|
323
|
+
}
|
|
324
|
+
// noinspection JSUnusedGlobalSymbols
|
|
245
325
|
getMiscellaneousApi() {
|
|
246
326
|
return new MiscellaneousApi(this.configuration);
|
|
247
327
|
}
|
|
328
|
+
// noinspection JSUnusedGlobalSymbols
|
|
248
329
|
getApiSecretApi() {
|
|
249
330
|
return new ApiSecretApi(this.configuration);
|
|
250
331
|
}
|
|
332
|
+
// noinspection JSUnusedGlobalSymbols
|
|
251
333
|
getExtensionApi() {
|
|
252
334
|
return new ExtensionApi(this.configuration);
|
|
253
335
|
}
|
|
336
|
+
// noinspection JSUnusedGlobalSymbols
|
|
254
337
|
getRepositoryApi() {
|
|
255
338
|
return new RepositoryApi(this.configuration);
|
|
256
339
|
}
|
|
340
|
+
// noinspection JSUnusedGlobalSymbols
|
|
341
|
+
getCollectionApi() {
|
|
342
|
+
return new CollectionApi(this.configuration);
|
|
343
|
+
}
|
|
257
344
|
getImageApi() {
|
|
258
345
|
return new ImageApi(this.configuration);
|
|
259
346
|
}
|
|
347
|
+
// noinspection JSUnusedGlobalSymbols
|
|
260
348
|
getImageAttachmentApi() {
|
|
261
349
|
return new ImageAttachmentApi(this.configuration);
|
|
262
350
|
}
|
|
351
|
+
// noinspection JSUnusedGlobalSymbols
|
|
263
352
|
async getSettings() {
|
|
264
353
|
return (await new ExtensionApi(this.configuration).extensionGetSettings({ id: this.extensionId })).value;
|
|
265
354
|
}
|
|
@@ -277,10 +366,17 @@ export class PicteusExtension {
|
|
|
277
366
|
const globalSender = new MessageSender(this.logger, this.parameters, this.socket, () => {
|
|
278
367
|
return this.toString();
|
|
279
368
|
});
|
|
280
|
-
this.globalCommunicator = new Communicator(this.logger, globalSender);
|
|
281
369
|
this.socket.on("connect", async () => {
|
|
282
370
|
this.logger.info(`The ${this.toString()} socket is connected`);
|
|
283
|
-
|
|
371
|
+
globalSender.sendMessage("connection", {
|
|
372
|
+
isOpen: true,
|
|
373
|
+
sdkVersion: PicteusExtension.getSdkVersion(),
|
|
374
|
+
environment: "node"
|
|
375
|
+
}, async (result) => {
|
|
376
|
+
const maximumPayloadSizeInBytes = result.maximumPayloadSizeInBytes;
|
|
377
|
+
this.logger.debug(`The ${this.toString()} socket has a maximum payload size of ${maximumPayloadSizeInBytes} bytes`);
|
|
378
|
+
globalSender.maximumPayloadSizeInBytes = maximumPayloadSizeInBytes;
|
|
379
|
+
});
|
|
284
380
|
});
|
|
285
381
|
this.socket.on("connect_error", async () => {
|
|
286
382
|
this.logger.warn(`The ${this.toString()} socket connection failed"`);
|
|
@@ -294,31 +390,58 @@ export class PicteusExtension {
|
|
|
294
390
|
const sender = new MessageSender(this.logger, this.parameters, this.socket, () => {
|
|
295
391
|
return this.toString();
|
|
296
392
|
}, contextId);
|
|
393
|
+
sender.maximumPayloadSizeInBytes = globalSender.maximumPayloadSizeInBytes;
|
|
297
394
|
const communicator = new Communicator(this.logger, sender);
|
|
298
|
-
const
|
|
395
|
+
const requiresResult = channel !== extensionSettingsChannel;
|
|
299
396
|
let result;
|
|
300
397
|
let success = false;
|
|
398
|
+
let eventName;
|
|
301
399
|
try {
|
|
302
|
-
|
|
400
|
+
if (channel === extensionSettingsChannel) {
|
|
401
|
+
result = await this.onSettings(communicator, value.value);
|
|
402
|
+
}
|
|
403
|
+
else if (channel === extensionVersionsChannel) {
|
|
404
|
+
const { upgrade, ...versions } = value;
|
|
405
|
+
if (upgrade === true) {
|
|
406
|
+
await this.onUpgrade(communicator, versions);
|
|
407
|
+
result = true;
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
result = true;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
else if (channel === extensionReadyChannel) {
|
|
414
|
+
try {
|
|
415
|
+
await this.onReady(communicator);
|
|
416
|
+
result = true;
|
|
417
|
+
}
|
|
418
|
+
catch (error) {
|
|
419
|
+
this.exit(3, error, "an error occurred during the execution of the 'onReady()' method: stopping the process");
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
eventName = channel;
|
|
424
|
+
result = await this.onEvent(communicator, eventName, value);
|
|
425
|
+
}
|
|
303
426
|
success = true;
|
|
304
427
|
}
|
|
305
428
|
catch (error) {
|
|
306
429
|
// We want the process to continue even if an exception occurs
|
|
307
430
|
this.logger.error(`An error occurred during the handling of the event on channel '${channel}'`, error);
|
|
308
|
-
|
|
431
|
+
if ((eventName === EventName.ImageRunCommand || eventName === EventName.ProcessRunCommand) && error instanceof CommandError) {
|
|
432
|
+
void communicator.launchIntent({ toast: { type: IntentToastType.Error, subtitle: error.message } });
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
communicator.sendLog(`The handling of the event failed for the ${this.toString()}. Reason: '${error.message}'`, "error");
|
|
436
|
+
}
|
|
309
437
|
}
|
|
310
438
|
finally {
|
|
311
|
-
sender.sendMessage(
|
|
439
|
+
sender.sendMessage(instructionsEvent, { acknowledgment: { success } });
|
|
312
440
|
}
|
|
313
|
-
if (
|
|
441
|
+
if (requiresResult === true && onResult !== undefined) {
|
|
314
442
|
onResult(result);
|
|
315
443
|
}
|
|
316
444
|
});
|
|
317
|
-
globalSender.sendMessage("connection", {
|
|
318
|
-
isOpen: true,
|
|
319
|
-
sdkVersion: PicteusExtension.getSdkVersion(),
|
|
320
|
-
environment: "node"
|
|
321
|
-
});
|
|
322
445
|
}
|
|
323
446
|
disconnectSocket() {
|
|
324
447
|
if (this.socket !== undefined && this.socket.disconnected === false) {
|
|
@@ -327,6 +450,10 @@ export class PicteusExtension {
|
|
|
327
450
|
this.socket = undefined;
|
|
328
451
|
}
|
|
329
452
|
}
|
|
453
|
+
exit(code, error, message) {
|
|
454
|
+
this.logger.error(`For the ${this.toString()}, ${message}. Reason: '${error.message}'`, error);
|
|
455
|
+
process.exit(code);
|
|
456
|
+
}
|
|
330
457
|
getApiConfiguration() {
|
|
331
458
|
if (this.parameters.webServicesBaseUrl.startsWith("https://localhost") == true) {
|
|
332
459
|
// This enables to discard the warning log message, caused by the fact that we are issuing HTTPS request on the localhost exposing a self-served certificate
|