@haex-space/vault-sdk 4.7.1 → 4.8.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/README.md +7 -3
- package/dist/{client-BlUizM-l.d.mts → client-D9zisRb8.d.mts} +9 -2
- package/dist/{client--CgEtJ4G.d.ts → client-DiqylZ59.d.ts} +9 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +27 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -4
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +28 -5
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +28 -5
- package/dist/react.mjs.map +1 -1
- package/dist/runtime/nuxt.plugin.client.js +28 -5
- package/dist/runtime/nuxt.plugin.client.js.map +1 -1
- package/dist/runtime/nuxt.plugin.client.mjs +28 -5
- package/dist/runtime/nuxt.plugin.client.mjs.map +1 -1
- package/dist/svelte.d.mts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +28 -5
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +28 -5
- package/dist/svelte.mjs.map +1 -1
- package/dist/vue.d.mts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +28 -5
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +28 -5
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1156,9 +1156,13 @@ else console.warn(end.error?.code, end.error?.message);
|
|
|
1156
1156
|
The user decides at run time which model your extension may use and up to which effort, and gives
|
|
1157
1157
|
consent before anything goes to a destination outside the device; the SDK waits for these answers
|
|
1158
1158
|
and starts the job again. `models.listAsync()` names the allowed models with their place and
|
|
1159
|
-
capabilities, never an address or a key
|
|
1160
|
-
`
|
|
1161
|
-
|
|
1159
|
+
capabilities, never an address or a key. To let the user stop a job, pass a signal:
|
|
1160
|
+
`runAsync(job, { signal })` asks to cancel the job when the signal aborts; the job ends as `cancelled`,
|
|
1161
|
+
unless it had already ended, then you get its actual result. A signal that is already aborted rejects
|
|
1162
|
+
with its reason and starts no job; a failed cancel request rejects the run with that error, while an
|
|
1163
|
+
unknown job rejects it with an error.
|
|
1164
|
+
`models.startAsync`, `models.onCompleted` and `models.cancelAsync` give you the job's id and its end
|
|
1165
|
+
separately. A job has no tools and sees only the input you send.
|
|
1162
1166
|
|
|
1163
1167
|
### Database Operations
|
|
1164
1168
|
|
|
@@ -1799,8 +1799,15 @@ declare class ModelsAPI {
|
|
|
1799
1799
|
* `cancelled` with the error. Errors of the start itself (an invalid job, a refused model or
|
|
1800
1800
|
* consent, no fitting model) reject. The end can arrive before the start answers; it is kept
|
|
1801
1801
|
* until then.
|
|
1802
|
-
|
|
1803
|
-
|
|
1802
|
+
*
|
|
1803
|
+
* Aborting `signal` asks to cancel the job, which then ends as `cancelled`; a job that had
|
|
1804
|
+
* already ended keeps its actual end. A signal that is already aborted rejects with its reason
|
|
1805
|
+
* and starts no job. If the cancel request fails, the run rejects with that error and the job
|
|
1806
|
+
* keeps running on the host; if it reports an unknown job, the run rejects with an error.
|
|
1807
|
+
*/
|
|
1808
|
+
runAsync(job: ModelJob, options?: {
|
|
1809
|
+
signal?: AbortSignal;
|
|
1810
|
+
}): Promise<ModelJobCompletion>;
|
|
1804
1811
|
}
|
|
1805
1812
|
|
|
1806
1813
|
/**
|
|
@@ -1799,8 +1799,15 @@ declare class ModelsAPI {
|
|
|
1799
1799
|
* `cancelled` with the error. Errors of the start itself (an invalid job, a refused model or
|
|
1800
1800
|
* consent, no fitting model) reject. The end can arrive before the start answers; it is kept
|
|
1801
1801
|
* until then.
|
|
1802
|
-
|
|
1803
|
-
|
|
1802
|
+
*
|
|
1803
|
+
* Aborting `signal` asks to cancel the job, which then ends as `cancelled`; a job that had
|
|
1804
|
+
* already ended keeps its actual end. A signal that is already aborted rejects with its reason
|
|
1805
|
+
* and starts no job. If the cancel request fails, the run rejects with that error and the job
|
|
1806
|
+
* keeps running on the host; if it reports an unknown job, the run rejects with an error.
|
|
1807
|
+
*/
|
|
1808
|
+
runAsync(job: ModelJob, options?: {
|
|
1809
|
+
signal?: AbortSignal;
|
|
1810
|
+
}): Promise<ModelJobCompletion>;
|
|
1804
1811
|
}
|
|
1805
1812
|
|
|
1806
1813
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HaexVaultSdk } from './client-
|
|
2
|
-
export { A as AuthorizedClient, B as BlockedClient, C as ConfirmOptions, a as ConnectionSecurity, b as ContactDetail, c as ContactHolziAddresses, d as ContactHolziDevice, e as ContactList, f as ContactListOptions, g as ContactSummary, h as ContactValue, i as ContactsAPI, D as DatabaseAPI, j as DecryptedSpace, k as DeepLink, l as Device, m as DeviceInfo, n as DeviceType, o as DialogAPI, p as DirEntry, E as EncryptedFolderAccess, q as EncryptedFolderChoice, r as EncryptedFolderEntry, s as EncryptedFolderProviderErrorKind, t as EncryptedFoldersAPI, u as ExtensionModel, v as ExternalAuthDecision, w as ExternalConnection, x as ExternalConnectionErrorCode, y as ExternalConnectionState, z as ExternalRequest, F as ExternalRequestEvent, G as ExternalRequestHandler, I as ExternalRequestPayload, J as ExternalResponse, K as FileStat, L as FilesystemAPI, M as ImapConfig, N as KnownPath, O as KnownPaths, P as LOCALSEND_EVENTS, Q as LocalSendAPI, R as LocalSendEvent, T as LocalSendFileInfo, U as LocalSendSettings, V as MailAPI, W as MailAccount, X as MailAddress, Y as MailAttachment, Z as MailFetchRange, _ as MailMessage, $ as MailNewMessagesEvent, a0 as MailSearchCriteria, a1 as MailSearchResult, a2 as MailboxInfo, a3 as MessageEnvelope, a4 as ModelEffort, a5 as ModelJob, a6 as ModelJobAttempt, a7 as ModelJobCompletion, a8 as ModelJobErrorCode, a9 as ModelJobFormat, aa as ModelJobImage, ab as ModelJobProvenance, ac as ModelJobStep, ad as ModelPlace, ae as ModelsAPI, af as NotificationAction, ag as NotificationClickEvent, ah as NotificationOptions, ai as NotificationsAPI, aj as OutgoingAttachment, ak as OutgoingMessage, al as PasswordInput, am as PasswordItemFull, an as PasswordItemSummary, ao as PasswordKeyValue, ap as PasswordKeyValueInput, aq as PasswordsAPI, ar as PendingAuthorization, as as PendingTransfer, at as PermissionsAPI, au as RemoteAddBackendRequest, av as RemoteFolderBackendInfo, aw as RemoteS3BackendInfo, ax as RemoteS3Config, ay as RemoteS3Proposal, az as RemoteS3PublicConfig, aA as RemoteSftpProposal, aB as RemoteStorageAPI, aC as RemoteStorageBackendInfo, aD as RemoteStorageBackendType, aE as RemoteStorageObjectInfo, aF as RemoteUpdateBackendRequest, aG as RemoteWebDavProposal, aH as RequestedExtension, aI as SelectFileOptions, aJ as SelectFolderOptions, aK as ServerInfo, aL as ServerStatus, aM as SessionAuthorization, aN as SharedSpace, aO as ShellAPI, aP as ShellCreateOptions, aQ as ShellCreateResponse, aR as ShellExitEvent, aS as ShellOutputEvent, aT as SmtpConfig, aU as SpaceAccessTokenInfo, aV as SpaceAssignment, aW as SpaceInvite, aX as SpaceKeyGrantInfo, aY as SpaceMember, aZ as SpaceMemberInfo, a_ as SpacesAPI, a$ as SyncBackendInfo, b0 as TabAPI, b1 as ToolContext, b2 as ToolHandler, b3 as ToolsAPI, b4 as TransferDirection, b5 as TransferProgress, b6 as TransferState, b7 as WebAPI, b8 as canExternalClientSendRequests, b9 as isExternalClientConnected } from './client-
|
|
1
|
+
import { H as HaexVaultSdk } from './client-D9zisRb8.mjs';
|
|
2
|
+
export { A as AuthorizedClient, B as BlockedClient, C as ConfirmOptions, a as ConnectionSecurity, b as ContactDetail, c as ContactHolziAddresses, d as ContactHolziDevice, e as ContactList, f as ContactListOptions, g as ContactSummary, h as ContactValue, i as ContactsAPI, D as DatabaseAPI, j as DecryptedSpace, k as DeepLink, l as Device, m as DeviceInfo, n as DeviceType, o as DialogAPI, p as DirEntry, E as EncryptedFolderAccess, q as EncryptedFolderChoice, r as EncryptedFolderEntry, s as EncryptedFolderProviderErrorKind, t as EncryptedFoldersAPI, u as ExtensionModel, v as ExternalAuthDecision, w as ExternalConnection, x as ExternalConnectionErrorCode, y as ExternalConnectionState, z as ExternalRequest, F as ExternalRequestEvent, G as ExternalRequestHandler, I as ExternalRequestPayload, J as ExternalResponse, K as FileStat, L as FilesystemAPI, M as ImapConfig, N as KnownPath, O as KnownPaths, P as LOCALSEND_EVENTS, Q as LocalSendAPI, R as LocalSendEvent, T as LocalSendFileInfo, U as LocalSendSettings, V as MailAPI, W as MailAccount, X as MailAddress, Y as MailAttachment, Z as MailFetchRange, _ as MailMessage, $ as MailNewMessagesEvent, a0 as MailSearchCriteria, a1 as MailSearchResult, a2 as MailboxInfo, a3 as MessageEnvelope, a4 as ModelEffort, a5 as ModelJob, a6 as ModelJobAttempt, a7 as ModelJobCompletion, a8 as ModelJobErrorCode, a9 as ModelJobFormat, aa as ModelJobImage, ab as ModelJobProvenance, ac as ModelJobStep, ad as ModelPlace, ae as ModelsAPI, af as NotificationAction, ag as NotificationClickEvent, ah as NotificationOptions, ai as NotificationsAPI, aj as OutgoingAttachment, ak as OutgoingMessage, al as PasswordInput, am as PasswordItemFull, an as PasswordItemSummary, ao as PasswordKeyValue, ap as PasswordKeyValueInput, aq as PasswordsAPI, ar as PendingAuthorization, as as PendingTransfer, at as PermissionsAPI, au as RemoteAddBackendRequest, av as RemoteFolderBackendInfo, aw as RemoteS3BackendInfo, ax as RemoteS3Config, ay as RemoteS3Proposal, az as RemoteS3PublicConfig, aA as RemoteSftpProposal, aB as RemoteStorageAPI, aC as RemoteStorageBackendInfo, aD as RemoteStorageBackendType, aE as RemoteStorageObjectInfo, aF as RemoteUpdateBackendRequest, aG as RemoteWebDavProposal, aH as RequestedExtension, aI as SelectFileOptions, aJ as SelectFolderOptions, aK as ServerInfo, aL as ServerStatus, aM as SessionAuthorization, aN as SharedSpace, aO as ShellAPI, aP as ShellCreateOptions, aQ as ShellCreateResponse, aR as ShellExitEvent, aS as ShellOutputEvent, aT as SmtpConfig, aU as SpaceAccessTokenInfo, aV as SpaceAssignment, aW as SpaceInvite, aX as SpaceKeyGrantInfo, aY as SpaceMember, aZ as SpaceMemberInfo, a_ as SpacesAPI, a$ as SyncBackendInfo, b0 as TabAPI, b1 as ToolContext, b2 as ToolHandler, b3 as ToolsAPI, b4 as TransferDirection, b5 as TransferProgress, b6 as TransferState, b7 as WebAPI, b8 as canExternalClientSendRequests, b9 as isExternalClientConnected } from './client-D9zisRb8.mjs';
|
|
3
3
|
import { h as SignedClaimPresentation, H as HaexHubConfig } from './types-3iifP-Q1.mjs';
|
|
4
4
|
export { A as ApplicationContext, C as ClaimRequirement, i as ContextChangedEvent, j as DEFAULT_TIMEOUT, k as DatabaseColumnInfo, l as DatabaseExecuteParams, m as DatabasePermission, g as DatabasePermissionRequest, n as DatabaseQueryParams, D as DatabaseQueryResult, o as DatabaseTableInfo, c as EXTERNAL_EVENTS, p as ErrorCode, f as EventCallback, E as ExtensionInfo, a as ExtensionManifest, q as ExtensionRuntimeMode, r as ExternalEvent, F as FileChangeEvent, s as FileChangePayload, t as FileChangeType, u as FilteredSyncTablesResult, v as HAEXTENSION_EVENTS, b as HaexHubEvent, w as HaexHubRequest, x as HaexHubResponse, y as HaexVaultSdkError, z as HaextensionEvent, B as HostErrorCode, I as IdentityClaim, G as MAIL_EVENTS, J as MODEL_JOB_EVENTS, K as MailEvent, L as ManifestI18nEntry, N as ManifestTool, O as ManifestToolEffect, Q as ModelJobEvent, T as NOTIFICATION_EVENTS, U as NotificationEvent, V as PermissionDeniedError, X as PermissionErrorBase, Y as PermissionErrorCode, Z as PermissionPromptError, P as PermissionResponse, _ as PermissionStatus, R as RequestOptions, $ as SHELL_EVENTS, a0 as SearchQuery, a1 as SearchRequestEvent, S as SearchResult, a2 as ShellEvent, a3 as SyncTablesUpdatedEvent, a4 as TABLE_SEPARATOR, W as WebRequestOptions, e as WebResponse, a5 as getTableName, a6 as isPermissionDeniedError, a7 as isPermissionError, a8 as isPermissionPromptError } from './types-3iifP-Q1.mjs';
|
|
5
5
|
export { H as HaextensionConfig } from './config-P_6DqTHl.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HaexVaultSdk } from './client
|
|
2
|
-
export { A as AuthorizedClient, B as BlockedClient, C as ConfirmOptions, a as ConnectionSecurity, b as ContactDetail, c as ContactHolziAddresses, d as ContactHolziDevice, e as ContactList, f as ContactListOptions, g as ContactSummary, h as ContactValue, i as ContactsAPI, D as DatabaseAPI, j as DecryptedSpace, k as DeepLink, l as Device, m as DeviceInfo, n as DeviceType, o as DialogAPI, p as DirEntry, E as EncryptedFolderAccess, q as EncryptedFolderChoice, r as EncryptedFolderEntry, s as EncryptedFolderProviderErrorKind, t as EncryptedFoldersAPI, u as ExtensionModel, v as ExternalAuthDecision, w as ExternalConnection, x as ExternalConnectionErrorCode, y as ExternalConnectionState, z as ExternalRequest, F as ExternalRequestEvent, G as ExternalRequestHandler, I as ExternalRequestPayload, J as ExternalResponse, K as FileStat, L as FilesystemAPI, M as ImapConfig, N as KnownPath, O as KnownPaths, P as LOCALSEND_EVENTS, Q as LocalSendAPI, R as LocalSendEvent, T as LocalSendFileInfo, U as LocalSendSettings, V as MailAPI, W as MailAccount, X as MailAddress, Y as MailAttachment, Z as MailFetchRange, _ as MailMessage, $ as MailNewMessagesEvent, a0 as MailSearchCriteria, a1 as MailSearchResult, a2 as MailboxInfo, a3 as MessageEnvelope, a4 as ModelEffort, a5 as ModelJob, a6 as ModelJobAttempt, a7 as ModelJobCompletion, a8 as ModelJobErrorCode, a9 as ModelJobFormat, aa as ModelJobImage, ab as ModelJobProvenance, ac as ModelJobStep, ad as ModelPlace, ae as ModelsAPI, af as NotificationAction, ag as NotificationClickEvent, ah as NotificationOptions, ai as NotificationsAPI, aj as OutgoingAttachment, ak as OutgoingMessage, al as PasswordInput, am as PasswordItemFull, an as PasswordItemSummary, ao as PasswordKeyValue, ap as PasswordKeyValueInput, aq as PasswordsAPI, ar as PendingAuthorization, as as PendingTransfer, at as PermissionsAPI, au as RemoteAddBackendRequest, av as RemoteFolderBackendInfo, aw as RemoteS3BackendInfo, ax as RemoteS3Config, ay as RemoteS3Proposal, az as RemoteS3PublicConfig, aA as RemoteSftpProposal, aB as RemoteStorageAPI, aC as RemoteStorageBackendInfo, aD as RemoteStorageBackendType, aE as RemoteStorageObjectInfo, aF as RemoteUpdateBackendRequest, aG as RemoteWebDavProposal, aH as RequestedExtension, aI as SelectFileOptions, aJ as SelectFolderOptions, aK as ServerInfo, aL as ServerStatus, aM as SessionAuthorization, aN as SharedSpace, aO as ShellAPI, aP as ShellCreateOptions, aQ as ShellCreateResponse, aR as ShellExitEvent, aS as ShellOutputEvent, aT as SmtpConfig, aU as SpaceAccessTokenInfo, aV as SpaceAssignment, aW as SpaceInvite, aX as SpaceKeyGrantInfo, aY as SpaceMember, aZ as SpaceMemberInfo, a_ as SpacesAPI, a$ as SyncBackendInfo, b0 as TabAPI, b1 as ToolContext, b2 as ToolHandler, b3 as ToolsAPI, b4 as TransferDirection, b5 as TransferProgress, b6 as TransferState, b7 as WebAPI, b8 as canExternalClientSendRequests, b9 as isExternalClientConnected } from './client
|
|
1
|
+
import { H as HaexVaultSdk } from './client-DiqylZ59.js';
|
|
2
|
+
export { A as AuthorizedClient, B as BlockedClient, C as ConfirmOptions, a as ConnectionSecurity, b as ContactDetail, c as ContactHolziAddresses, d as ContactHolziDevice, e as ContactList, f as ContactListOptions, g as ContactSummary, h as ContactValue, i as ContactsAPI, D as DatabaseAPI, j as DecryptedSpace, k as DeepLink, l as Device, m as DeviceInfo, n as DeviceType, o as DialogAPI, p as DirEntry, E as EncryptedFolderAccess, q as EncryptedFolderChoice, r as EncryptedFolderEntry, s as EncryptedFolderProviderErrorKind, t as EncryptedFoldersAPI, u as ExtensionModel, v as ExternalAuthDecision, w as ExternalConnection, x as ExternalConnectionErrorCode, y as ExternalConnectionState, z as ExternalRequest, F as ExternalRequestEvent, G as ExternalRequestHandler, I as ExternalRequestPayload, J as ExternalResponse, K as FileStat, L as FilesystemAPI, M as ImapConfig, N as KnownPath, O as KnownPaths, P as LOCALSEND_EVENTS, Q as LocalSendAPI, R as LocalSendEvent, T as LocalSendFileInfo, U as LocalSendSettings, V as MailAPI, W as MailAccount, X as MailAddress, Y as MailAttachment, Z as MailFetchRange, _ as MailMessage, $ as MailNewMessagesEvent, a0 as MailSearchCriteria, a1 as MailSearchResult, a2 as MailboxInfo, a3 as MessageEnvelope, a4 as ModelEffort, a5 as ModelJob, a6 as ModelJobAttempt, a7 as ModelJobCompletion, a8 as ModelJobErrorCode, a9 as ModelJobFormat, aa as ModelJobImage, ab as ModelJobProvenance, ac as ModelJobStep, ad as ModelPlace, ae as ModelsAPI, af as NotificationAction, ag as NotificationClickEvent, ah as NotificationOptions, ai as NotificationsAPI, aj as OutgoingAttachment, ak as OutgoingMessage, al as PasswordInput, am as PasswordItemFull, an as PasswordItemSummary, ao as PasswordKeyValue, ap as PasswordKeyValueInput, aq as PasswordsAPI, ar as PendingAuthorization, as as PendingTransfer, at as PermissionsAPI, au as RemoteAddBackendRequest, av as RemoteFolderBackendInfo, aw as RemoteS3BackendInfo, ax as RemoteS3Config, ay as RemoteS3Proposal, az as RemoteS3PublicConfig, aA as RemoteSftpProposal, aB as RemoteStorageAPI, aC as RemoteStorageBackendInfo, aD as RemoteStorageBackendType, aE as RemoteStorageObjectInfo, aF as RemoteUpdateBackendRequest, aG as RemoteWebDavProposal, aH as RequestedExtension, aI as SelectFileOptions, aJ as SelectFolderOptions, aK as ServerInfo, aL as ServerStatus, aM as SessionAuthorization, aN as SharedSpace, aO as ShellAPI, aP as ShellCreateOptions, aQ as ShellCreateResponse, aR as ShellExitEvent, aS as ShellOutputEvent, aT as SmtpConfig, aU as SpaceAccessTokenInfo, aV as SpaceAssignment, aW as SpaceInvite, aX as SpaceKeyGrantInfo, aY as SpaceMember, aZ as SpaceMemberInfo, a_ as SpacesAPI, a$ as SyncBackendInfo, b0 as TabAPI, b1 as ToolContext, b2 as ToolHandler, b3 as ToolsAPI, b4 as TransferDirection, b5 as TransferProgress, b6 as TransferState, b7 as WebAPI, b8 as canExternalClientSendRequests, b9 as isExternalClientConnected } from './client-DiqylZ59.js';
|
|
3
3
|
import { h as SignedClaimPresentation, H as HaexHubConfig } from './types-3iifP-Q1.js';
|
|
4
4
|
export { A as ApplicationContext, C as ClaimRequirement, i as ContextChangedEvent, j as DEFAULT_TIMEOUT, k as DatabaseColumnInfo, l as DatabaseExecuteParams, m as DatabasePermission, g as DatabasePermissionRequest, n as DatabaseQueryParams, D as DatabaseQueryResult, o as DatabaseTableInfo, c as EXTERNAL_EVENTS, p as ErrorCode, f as EventCallback, E as ExtensionInfo, a as ExtensionManifest, q as ExtensionRuntimeMode, r as ExternalEvent, F as FileChangeEvent, s as FileChangePayload, t as FileChangeType, u as FilteredSyncTablesResult, v as HAEXTENSION_EVENTS, b as HaexHubEvent, w as HaexHubRequest, x as HaexHubResponse, y as HaexVaultSdkError, z as HaextensionEvent, B as HostErrorCode, I as IdentityClaim, G as MAIL_EVENTS, J as MODEL_JOB_EVENTS, K as MailEvent, L as ManifestI18nEntry, N as ManifestTool, O as ManifestToolEffect, Q as ModelJobEvent, T as NOTIFICATION_EVENTS, U as NotificationEvent, V as PermissionDeniedError, X as PermissionErrorBase, Y as PermissionErrorCode, Z as PermissionPromptError, P as PermissionResponse, _ as PermissionStatus, R as RequestOptions, $ as SHELL_EVENTS, a0 as SearchQuery, a1 as SearchRequestEvent, S as SearchResult, a2 as ShellEvent, a3 as SyncTablesUpdatedEvent, a4 as TABLE_SEPARATOR, W as WebRequestOptions, e as WebResponse, a5 as getTableName, a6 as isPermissionDeniedError, a7 as isPermissionError, a8 as isPermissionPromptError } from './types-3iifP-Q1.js';
|
|
5
5
|
export { H as HaextensionConfig } from './config-P_6DqTHl.js';
|
package/dist/index.js
CHANGED
|
@@ -2485,22 +2485,45 @@ var ModelsAPI = class {
|
|
|
2485
2485
|
* `cancelled` with the error. Errors of the start itself (an invalid job, a refused model or
|
|
2486
2486
|
* consent, no fitting model) reject. The end can arrive before the start answers; it is kept
|
|
2487
2487
|
* until then.
|
|
2488
|
+
*
|
|
2489
|
+
* Aborting `signal` asks to cancel the job, which then ends as `cancelled`; a job that had
|
|
2490
|
+
* already ended keeps its actual end. A signal that is already aborted rejects with its reason
|
|
2491
|
+
* and starts no job. If the cancel request fails, the run rejects with that error and the job
|
|
2492
|
+
* keeps running on the host; if it reports an unknown job, the run rejects with an error.
|
|
2488
2493
|
*/
|
|
2489
|
-
async runAsync(job) {
|
|
2494
|
+
async runAsync(job, options = {}) {
|
|
2495
|
+
const { signal } = options;
|
|
2496
|
+
if (signal?.aborted) throw signal.reason;
|
|
2490
2497
|
const ended = /* @__PURE__ */ new Map();
|
|
2491
2498
|
let waiting = null;
|
|
2492
2499
|
const unsubscribe = this.onCompleted((completion) => {
|
|
2493
2500
|
if (waiting && completion.jobId === waiting.jobId) waiting.resolve(completion);
|
|
2494
2501
|
else ended.set(completion.jobId, completion);
|
|
2495
2502
|
});
|
|
2503
|
+
let detach = () => {
|
|
2504
|
+
};
|
|
2496
2505
|
try {
|
|
2497
2506
|
const { jobId } = await this.startAsync(job);
|
|
2498
|
-
return await new Promise((resolve) => {
|
|
2507
|
+
return await new Promise((resolve, reject) => {
|
|
2499
2508
|
const early = ended.get(jobId);
|
|
2500
|
-
if (early) resolve(early);
|
|
2501
|
-
|
|
2509
|
+
if (early) return resolve(early);
|
|
2510
|
+
waiting = { jobId, resolve };
|
|
2511
|
+
if (!signal) return;
|
|
2512
|
+
const cancel = async () => {
|
|
2513
|
+
try {
|
|
2514
|
+
if (!await this.cancelAsync(jobId)) {
|
|
2515
|
+
reject(new Error("The model job could not be cancelled"));
|
|
2516
|
+
}
|
|
2517
|
+
} catch (error) {
|
|
2518
|
+
reject(error);
|
|
2519
|
+
}
|
|
2520
|
+
};
|
|
2521
|
+
if (signal.aborted) return cancel();
|
|
2522
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
2523
|
+
detach = () => signal.removeEventListener("abort", cancel);
|
|
2502
2524
|
});
|
|
2503
2525
|
} finally {
|
|
2526
|
+
detach();
|
|
2504
2527
|
unsubscribe();
|
|
2505
2528
|
}
|
|
2506
2529
|
}
|