@verentis/sdk 0.1.1 → 0.2.2

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.cts CHANGED
@@ -1,12 +1,61 @@
1
+ interface HeaderAction {
2
+ id: string;
3
+ label: string;
4
+ icon?: string;
5
+ variant?: 'default' | 'outline' | 'destructive';
6
+ /** Empty for client-only actions; otherwise a subset of the delegated token scopes. */
7
+ scopes: string[];
8
+ enabled?: boolean;
9
+ visible?: boolean;
10
+ busy?: boolean;
11
+ disabledReason?: string;
12
+ /** Clipboard actions return text for the host to copy during its user gesture. */
13
+ kind?: 'clipboard';
14
+ }
15
+ interface HeaderActionResult {
16
+ clipboardText?: string;
17
+ navigate?: {
18
+ path: string;
19
+ newTab?: boolean;
20
+ };
21
+ }
22
+ interface HeaderActionRegistration {
23
+ update(action: HeaderAction): void;
24
+ dispose(): void;
25
+ }
26
+ type HeaderActionHandler = () => void | HeaderActionResult | Promise<void | HeaderActionResult>;
27
+ declare function isHeaderAction(value: unknown): value is HeaderAction;
28
+
1
29
  interface VerentisMessage {
2
30
  type: `verentis:${string}`;
3
31
  version: 1;
4
32
  requestId?: string;
5
33
  }
34
+
6
35
  interface VerentisInitMessage extends VerentisMessage {
7
36
  type: 'verentis:init';
8
37
  context: AppContext;
9
38
  token: TokenInfo;
39
+ sessionId?: string;
40
+ }
41
+ interface VerentisActionsSetMessage extends VerentisMessage {
42
+ type: 'verentis:actions:set';
43
+ sessionId: string;
44
+ actions: HeaderAction[];
45
+ }
46
+ interface VerentisActionInvokeMessage extends VerentisMessage {
47
+ type: 'verentis:action:invoke';
48
+ sessionId: string;
49
+ requestId: string;
50
+ actionId: string;
51
+ }
52
+ interface VerentisActionResultMessage extends VerentisMessage {
53
+ type: 'verentis:action:result';
54
+ sessionId: string;
55
+ requestId: string;
56
+ actionId: string;
57
+ result?: HeaderActionResult;
58
+ error?: string;
10
59
  }
11
60
  interface VerentisTokenRefreshedMessage extends VerentisMessage {
12
61
  type: 'verentis:token:refreshed';
@@ -50,8 +99,8 @@ interface VerentisDirtyMessage extends VerentisMessage {
50
99
  type: 'verentis:dirty';
51
100
  isDirty: boolean;
52
101
  }
53
- type HostToAppMessage = VerentisInitMessage | VerentisTokenRefreshedMessage | VerentisFileChangedMessage | VerentisThemeMessage;
54
- type AppToHostMessage = VerentisReadyMessage | VerentisTokenRefreshMessage | VerentisNavigateMessage | VerentisResizeMessage | VerentisTitleMessage | VerentisDirtyMessage;
102
+ type HostToAppMessage = VerentisInitMessage | VerentisActionInvokeMessage | VerentisTokenRefreshedMessage | VerentisFileChangedMessage | VerentisThemeMessage;
103
+ type AppToHostMessage = VerentisReadyMessage | VerentisActionsSetMessage | VerentisActionResultMessage | VerentisTokenRefreshMessage | VerentisNavigateMessage | VerentisResizeMessage | VerentisTitleMessage | VerentisDirtyMessage;
55
104
  type AppSurface = 'file' | 'workspace';
56
105
  interface AppContextBase {
57
106
  workspace: WorkspaceInfo;
@@ -951,6 +1000,9 @@ declare class Bridge {
951
1000
  private _hostOrigin;
952
1001
  private _messageHandler;
953
1002
  private _destroyed;
1003
+ private sessionId;
1004
+ private actions;
1005
+ private requests;
954
1006
  constructor();
955
1007
  /** Post `verentis:ready` to the host to start the handshake */
956
1008
  sendReady(capabilities?: string[]): void;
@@ -979,6 +1031,9 @@ declare class Bridge {
979
1031
  setTitle(title: string): void;
980
1032
  /** Signal unsaved changes to the host */
981
1033
  setDirty(isDirty: boolean): void;
1034
+ registerAction(descriptor: HeaderAction, handler: HeaderActionHandler): HeaderActionRegistration;
1035
+ private publishActions;
1036
+ private invokeAction;
982
1037
  /** Subscribe to a specific message type from the host */
983
1038
  on(type: BridgeEventType, listener: BridgeListener): () => void;
984
1039
  /** Clean up event listeners */
@@ -1109,4 +1164,4 @@ declare class BridgeAuth implements AuthStrategy {
1109
1164
  */
1110
1165
  declare function createVerentisClient(options?: VerentisClientOptions): VerentisClient;
1111
1166
 
1112
- export { ApiError, ApiKeyAuth, type AppContext, type AppSurface, type AppToHostMessage, type ApplicationDisplayOptions, type ApplicationEntryPoint, type ApplicationFileType, type ApplicationLaunchConfig, type ApplicationManifest, type ApplicationSpec, type ArchiveFormat, type AuthOptions, type AuthStrategy, Bridge, BridgeAuth, type CatalogImage, ContextModule, type DeleteFileOptions, type EngineFileType, type EngineRuntime, type EngineTool, EnginesModule, type EntryPointInfo, type ExecuteEngineOptions, type Execution, type ExecutionEngine, type ExecutionEngineListOptions, type ExecutionListOptions, type ExecutionLogs, type ExecutionMode, type ExecutionResult, type ExecutionScopedOptions, type ExecutionStatus, type ExecutionTrigger, ExecutionsModule, type ExtractUploadOptions, type FileAppContext, type FileEntry, type FileInfo, FilesModule, type GetFileOptions, type HostToAppMessage, HttpTransport, type Installation, type InstallationDetail, type InstallationLifecycleResult, type InstallationListOptions, type InstallationMode, type InstallationScopedOptions, type InstallationStatus, InstallationsModule, type InstalledPackageDescriptor, type InstalledPackagePayload, type ManifestMetadata, type MimeTypeBinding, type MoveFileOptions, type NamespacedSettings, type NavigateOptions, type OAuthConfig, type PagedResult, type ReadArchiveOptions, type RequestOptions, type ResolveInstallationOptions, type ResourceMimeTypeBinding, type ResourceRegistration, type ResourceScopedOptions, ResourcesModule, type RunFileOptions, type SandboxOptions, type SettingDeclaration, type SettingDeclarationType, type SettingGroup, type SettingItem, type SettingOption, type SettingPresence, SettingsModule, type SettingsScopedOptions, TokenAuth, type TokenInfo, type UpdateInstallationOptions, VerentisClient, type VerentisClientOptions, type VerentisDirtyMessage, type VerentisFileChangedMessage, type VerentisInitMessage, type VerentisMessage, type VerentisNavigateMessage, type VerentisReadyMessage, type VerentisResizeMessage, type VerentisThemeMessage, type VerentisTitleMessage, type VerentisTokenRefreshMessage, type VerentisTokenRefreshedMessage, type WaitOptions, type WorkspaceAppContext, type WorkspaceInfo, type WriteFileOptions, createVerentisClient, findBestMatch, isTerminalStatus, matchMimeType };
1167
+ export { ApiError, ApiKeyAuth, type AppContext, type AppSurface, type AppToHostMessage, type ApplicationDisplayOptions, type ApplicationEntryPoint, type ApplicationFileType, type ApplicationLaunchConfig, type ApplicationManifest, type ApplicationSpec, type ArchiveFormat, type AuthOptions, type AuthStrategy, Bridge, BridgeAuth, type CatalogImage, ContextModule, type DeleteFileOptions, type EngineFileType, type EngineRuntime, type EngineTool, EnginesModule, type EntryPointInfo, type ExecuteEngineOptions, type Execution, type ExecutionEngine, type ExecutionEngineListOptions, type ExecutionListOptions, type ExecutionLogs, type ExecutionMode, type ExecutionResult, type ExecutionScopedOptions, type ExecutionStatus, type ExecutionTrigger, ExecutionsModule, type ExtractUploadOptions, type FileAppContext, type FileEntry, type FileInfo, FilesModule, type GetFileOptions, type HeaderAction, type HeaderActionHandler, type HeaderActionRegistration, type HeaderActionResult, type HostToAppMessage, HttpTransport, type Installation, type InstallationDetail, type InstallationLifecycleResult, type InstallationListOptions, type InstallationMode, type InstallationScopedOptions, type InstallationStatus, InstallationsModule, type InstalledPackageDescriptor, type InstalledPackagePayload, type ManifestMetadata, type MimeTypeBinding, type MoveFileOptions, type NamespacedSettings, type NavigateOptions, type OAuthConfig, type PagedResult, type ReadArchiveOptions, type RequestOptions, type ResolveInstallationOptions, type ResourceMimeTypeBinding, type ResourceRegistration, type ResourceScopedOptions, ResourcesModule, type RunFileOptions, type SandboxOptions, type SettingDeclaration, type SettingDeclarationType, type SettingGroup, type SettingItem, type SettingOption, type SettingPresence, SettingsModule, type SettingsScopedOptions, TokenAuth, type TokenInfo, type UpdateInstallationOptions, type VerentisActionInvokeMessage, type VerentisActionResultMessage, type VerentisActionsSetMessage, VerentisClient, type VerentisClientOptions, type VerentisDirtyMessage, type VerentisFileChangedMessage, type VerentisInitMessage, type VerentisMessage, type VerentisNavigateMessage, type VerentisReadyMessage, type VerentisResizeMessage, type VerentisThemeMessage, type VerentisTitleMessage, type VerentisTokenRefreshMessage, type VerentisTokenRefreshedMessage, type WaitOptions, type WorkspaceAppContext, type WorkspaceInfo, type WriteFileOptions, createVerentisClient, findBestMatch, isHeaderAction, isTerminalStatus, matchMimeType };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,61 @@
1
+ interface HeaderAction {
2
+ id: string;
3
+ label: string;
4
+ icon?: string;
5
+ variant?: 'default' | 'outline' | 'destructive';
6
+ /** Empty for client-only actions; otherwise a subset of the delegated token scopes. */
7
+ scopes: string[];
8
+ enabled?: boolean;
9
+ visible?: boolean;
10
+ busy?: boolean;
11
+ disabledReason?: string;
12
+ /** Clipboard actions return text for the host to copy during its user gesture. */
13
+ kind?: 'clipboard';
14
+ }
15
+ interface HeaderActionResult {
16
+ clipboardText?: string;
17
+ navigate?: {
18
+ path: string;
19
+ newTab?: boolean;
20
+ };
21
+ }
22
+ interface HeaderActionRegistration {
23
+ update(action: HeaderAction): void;
24
+ dispose(): void;
25
+ }
26
+ type HeaderActionHandler = () => void | HeaderActionResult | Promise<void | HeaderActionResult>;
27
+ declare function isHeaderAction(value: unknown): value is HeaderAction;
28
+
1
29
  interface VerentisMessage {
2
30
  type: `verentis:${string}`;
3
31
  version: 1;
4
32
  requestId?: string;
5
33
  }
34
+
6
35
  interface VerentisInitMessage extends VerentisMessage {
7
36
  type: 'verentis:init';
8
37
  context: AppContext;
9
38
  token: TokenInfo;
39
+ sessionId?: string;
40
+ }
41
+ interface VerentisActionsSetMessage extends VerentisMessage {
42
+ type: 'verentis:actions:set';
43
+ sessionId: string;
44
+ actions: HeaderAction[];
45
+ }
46
+ interface VerentisActionInvokeMessage extends VerentisMessage {
47
+ type: 'verentis:action:invoke';
48
+ sessionId: string;
49
+ requestId: string;
50
+ actionId: string;
51
+ }
52
+ interface VerentisActionResultMessage extends VerentisMessage {
53
+ type: 'verentis:action:result';
54
+ sessionId: string;
55
+ requestId: string;
56
+ actionId: string;
57
+ result?: HeaderActionResult;
58
+ error?: string;
10
59
  }
11
60
  interface VerentisTokenRefreshedMessage extends VerentisMessage {
12
61
  type: 'verentis:token:refreshed';
@@ -50,8 +99,8 @@ interface VerentisDirtyMessage extends VerentisMessage {
50
99
  type: 'verentis:dirty';
51
100
  isDirty: boolean;
52
101
  }
53
- type HostToAppMessage = VerentisInitMessage | VerentisTokenRefreshedMessage | VerentisFileChangedMessage | VerentisThemeMessage;
54
- type AppToHostMessage = VerentisReadyMessage | VerentisTokenRefreshMessage | VerentisNavigateMessage | VerentisResizeMessage | VerentisTitleMessage | VerentisDirtyMessage;
102
+ type HostToAppMessage = VerentisInitMessage | VerentisActionInvokeMessage | VerentisTokenRefreshedMessage | VerentisFileChangedMessage | VerentisThemeMessage;
103
+ type AppToHostMessage = VerentisReadyMessage | VerentisActionsSetMessage | VerentisActionResultMessage | VerentisTokenRefreshMessage | VerentisNavigateMessage | VerentisResizeMessage | VerentisTitleMessage | VerentisDirtyMessage;
55
104
  type AppSurface = 'file' | 'workspace';
56
105
  interface AppContextBase {
57
106
  workspace: WorkspaceInfo;
@@ -951,6 +1000,9 @@ declare class Bridge {
951
1000
  private _hostOrigin;
952
1001
  private _messageHandler;
953
1002
  private _destroyed;
1003
+ private sessionId;
1004
+ private actions;
1005
+ private requests;
954
1006
  constructor();
955
1007
  /** Post `verentis:ready` to the host to start the handshake */
956
1008
  sendReady(capabilities?: string[]): void;
@@ -979,6 +1031,9 @@ declare class Bridge {
979
1031
  setTitle(title: string): void;
980
1032
  /** Signal unsaved changes to the host */
981
1033
  setDirty(isDirty: boolean): void;
1034
+ registerAction(descriptor: HeaderAction, handler: HeaderActionHandler): HeaderActionRegistration;
1035
+ private publishActions;
1036
+ private invokeAction;
982
1037
  /** Subscribe to a specific message type from the host */
983
1038
  on(type: BridgeEventType, listener: BridgeListener): () => void;
984
1039
  /** Clean up event listeners */
@@ -1109,4 +1164,4 @@ declare class BridgeAuth implements AuthStrategy {
1109
1164
  */
1110
1165
  declare function createVerentisClient(options?: VerentisClientOptions): VerentisClient;
1111
1166
 
1112
- export { ApiError, ApiKeyAuth, type AppContext, type AppSurface, type AppToHostMessage, type ApplicationDisplayOptions, type ApplicationEntryPoint, type ApplicationFileType, type ApplicationLaunchConfig, type ApplicationManifest, type ApplicationSpec, type ArchiveFormat, type AuthOptions, type AuthStrategy, Bridge, BridgeAuth, type CatalogImage, ContextModule, type DeleteFileOptions, type EngineFileType, type EngineRuntime, type EngineTool, EnginesModule, type EntryPointInfo, type ExecuteEngineOptions, type Execution, type ExecutionEngine, type ExecutionEngineListOptions, type ExecutionListOptions, type ExecutionLogs, type ExecutionMode, type ExecutionResult, type ExecutionScopedOptions, type ExecutionStatus, type ExecutionTrigger, ExecutionsModule, type ExtractUploadOptions, type FileAppContext, type FileEntry, type FileInfo, FilesModule, type GetFileOptions, type HostToAppMessage, HttpTransport, type Installation, type InstallationDetail, type InstallationLifecycleResult, type InstallationListOptions, type InstallationMode, type InstallationScopedOptions, type InstallationStatus, InstallationsModule, type InstalledPackageDescriptor, type InstalledPackagePayload, type ManifestMetadata, type MimeTypeBinding, type MoveFileOptions, type NamespacedSettings, type NavigateOptions, type OAuthConfig, type PagedResult, type ReadArchiveOptions, type RequestOptions, type ResolveInstallationOptions, type ResourceMimeTypeBinding, type ResourceRegistration, type ResourceScopedOptions, ResourcesModule, type RunFileOptions, type SandboxOptions, type SettingDeclaration, type SettingDeclarationType, type SettingGroup, type SettingItem, type SettingOption, type SettingPresence, SettingsModule, type SettingsScopedOptions, TokenAuth, type TokenInfo, type UpdateInstallationOptions, VerentisClient, type VerentisClientOptions, type VerentisDirtyMessage, type VerentisFileChangedMessage, type VerentisInitMessage, type VerentisMessage, type VerentisNavigateMessage, type VerentisReadyMessage, type VerentisResizeMessage, type VerentisThemeMessage, type VerentisTitleMessage, type VerentisTokenRefreshMessage, type VerentisTokenRefreshedMessage, type WaitOptions, type WorkspaceAppContext, type WorkspaceInfo, type WriteFileOptions, createVerentisClient, findBestMatch, isTerminalStatus, matchMimeType };
1167
+ export { ApiError, ApiKeyAuth, type AppContext, type AppSurface, type AppToHostMessage, type ApplicationDisplayOptions, type ApplicationEntryPoint, type ApplicationFileType, type ApplicationLaunchConfig, type ApplicationManifest, type ApplicationSpec, type ArchiveFormat, type AuthOptions, type AuthStrategy, Bridge, BridgeAuth, type CatalogImage, ContextModule, type DeleteFileOptions, type EngineFileType, type EngineRuntime, type EngineTool, EnginesModule, type EntryPointInfo, type ExecuteEngineOptions, type Execution, type ExecutionEngine, type ExecutionEngineListOptions, type ExecutionListOptions, type ExecutionLogs, type ExecutionMode, type ExecutionResult, type ExecutionScopedOptions, type ExecutionStatus, type ExecutionTrigger, ExecutionsModule, type ExtractUploadOptions, type FileAppContext, type FileEntry, type FileInfo, FilesModule, type GetFileOptions, type HeaderAction, type HeaderActionHandler, type HeaderActionRegistration, type HeaderActionResult, type HostToAppMessage, HttpTransport, type Installation, type InstallationDetail, type InstallationLifecycleResult, type InstallationListOptions, type InstallationMode, type InstallationScopedOptions, type InstallationStatus, InstallationsModule, type InstalledPackageDescriptor, type InstalledPackagePayload, type ManifestMetadata, type MimeTypeBinding, type MoveFileOptions, type NamespacedSettings, type NavigateOptions, type OAuthConfig, type PagedResult, type ReadArchiveOptions, type RequestOptions, type ResolveInstallationOptions, type ResourceMimeTypeBinding, type ResourceRegistration, type ResourceScopedOptions, ResourcesModule, type RunFileOptions, type SandboxOptions, type SettingDeclaration, type SettingDeclarationType, type SettingGroup, type SettingItem, type SettingOption, type SettingPresence, SettingsModule, type SettingsScopedOptions, TokenAuth, type TokenInfo, type UpdateInstallationOptions, type VerentisActionInvokeMessage, type VerentisActionResultMessage, type VerentisActionsSetMessage, VerentisClient, type VerentisClientOptions, type VerentisDirtyMessage, type VerentisFileChangedMessage, type VerentisInitMessage, type VerentisMessage, type VerentisNavigateMessage, type VerentisReadyMessage, type VerentisResizeMessage, type VerentisThemeMessage, type VerentisTitleMessage, type VerentisTokenRefreshMessage, type VerentisTokenRefreshedMessage, type WaitOptions, type WorkspaceAppContext, type WorkspaceInfo, type WriteFileOptions, createVerentisClient, findBestMatch, isHeaderAction, isTerminalStatus, matchMimeType };
package/dist/index.js CHANGED
@@ -743,6 +743,13 @@ var SettingsModule = class {
743
743
  }
744
744
  };
745
745
 
746
+ // src/transport/header-actions.ts
747
+ function isHeaderAction(value) {
748
+ if (!value || typeof value !== "object") return false;
749
+ const a = value;
750
+ return typeof a.id === "string" && /^[a-z][a-z0-9.-]{0,63}$/.test(a.id) && typeof a.label === "string" && a.label.trim().length > 0 && a.label.length <= 100 && Array.isArray(a.scopes) && a.scopes.length <= 32 && a.scopes.every((s) => typeof s === "string" && /^[a-zA-Z0-9._:-]{1,128}$/.test(s)) && (a.icon === void 0 || typeof a.icon === "string" && /^lucide:[a-z0-9-]{1,64}$/.test(a.icon)) && (a.variant === void 0 || ["default", "outline", "destructive"].includes(String(a.variant))) && ["enabled", "visible", "busy"].every((key) => a[key] === void 0 || typeof a[key] === "boolean") && (a.disabledReason === void 0 || typeof a.disabledReason === "string" && a.disabledReason.length <= 200) && (a.kind === void 0 || a.kind === "clipboard");
751
+ }
752
+
746
753
  // src/transport/bridge.transport.ts
747
754
  var Bridge = class {
748
755
  listeners = /* @__PURE__ */ new Map();
@@ -751,6 +758,9 @@ var Bridge = class {
751
758
  _hostOrigin = null;
752
759
  _messageHandler;
753
760
  _destroyed = false;
761
+ sessionId = null;
762
+ actions = /* @__PURE__ */ new Map();
763
+ requests = /* @__PURE__ */ new Set();
754
764
  constructor() {
755
765
  this._initPromise = new Promise((resolve) => {
756
766
  this._initResolve = resolve;
@@ -780,6 +790,7 @@ var Bridge = class {
780
790
  }
781
791
  /** Send a message to the host */
782
792
  postToHost(message) {
793
+ if (this._destroyed) throw new Error("Bridge has been destroyed.");
783
794
  if (!this._hostOrigin) {
784
795
  throw new Error("Bridge not initialized: host origin unknown. Wait for init first.");
785
796
  }
@@ -814,6 +825,69 @@ var Bridge = class {
814
825
  setDirty(isDirty) {
815
826
  this.postToHost({ type: "verentis:dirty", version: 1, isDirty });
816
827
  }
828
+ registerAction(descriptor, handler) {
829
+ if (!this.sessionId || this._destroyed) throw new Error("Header actions require an initialized workspace host.");
830
+ if (!isHeaderAction(descriptor)) throw new Error("Invalid header action.");
831
+ if (this.actions.has(descriptor.id)) throw new Error(`Action '${descriptor.id}' is already registered.`);
832
+ if (this.actions.size >= 16) throw new Error("At most 16 header actions may be registered.");
833
+ const action = { descriptor: { ...descriptor, scopes: [...descriptor.scopes] }, handler, busy: false };
834
+ this.actions.set(descriptor.id, action);
835
+ this.publishActions();
836
+ return {
837
+ update: (next) => {
838
+ if (this.actions.get(descriptor.id) !== action) throw new Error("Action has been disposed.");
839
+ if (!isHeaderAction(next) || next.id !== descriptor.id) throw new Error("Invalid header action update.");
840
+ action.descriptor = { ...next, scopes: [...next.scopes] };
841
+ this.publishActions();
842
+ },
843
+ dispose: () => {
844
+ if (this.actions.get(descriptor.id) !== action) return;
845
+ this.actions.delete(descriptor.id);
846
+ this.publishActions();
847
+ }
848
+ };
849
+ }
850
+ publishActions() {
851
+ if (!this.sessionId || this._destroyed) return;
852
+ this.postToHost({
853
+ type: "verentis:actions:set",
854
+ version: 1,
855
+ sessionId: this.sessionId,
856
+ actions: [...this.actions.values()].map((a) => ({ ...a.descriptor, busy: a.busy || a.descriptor.busy }))
857
+ });
858
+ }
859
+ async invokeAction(message) {
860
+ if (message.sessionId !== this.sessionId || typeof message.requestId !== "string" || message.requestId.length > 128 || !message.requestId || this.requests.has(message.requestId)) return;
861
+ this.requests.add(message.requestId);
862
+ if (this.requests.size > 1e3) this.requests.delete(this.requests.values().next().value);
863
+ const action = this.actions.get(message.actionId);
864
+ const reply = {
865
+ type: "verentis:action:result",
866
+ version: 1,
867
+ sessionId: message.sessionId,
868
+ requestId: message.requestId,
869
+ actionId: message.actionId
870
+ };
871
+ if (!action || action.busy || action.descriptor.busy || action.descriptor.enabled === false || action.descriptor.visible === false) {
872
+ this.postToHost({ ...reply, error: "Action is unavailable." });
873
+ return;
874
+ }
875
+ action.busy = true;
876
+ this.publishActions();
877
+ try {
878
+ const result = await action.handler();
879
+ if (!this._destroyed && this.sessionId === message.sessionId) {
880
+ this.postToHost({ ...reply, result: result || void 0 });
881
+ }
882
+ } catch (error) {
883
+ if (!this._destroyed && this.sessionId === message.sessionId) {
884
+ this.postToHost({ ...reply, error: (error instanceof Error ? error.message : "Action failed.").slice(0, 500) });
885
+ }
886
+ } finally {
887
+ action.busy = false;
888
+ this.publishActions();
889
+ }
890
+ }
817
891
  /** Subscribe to a specific message type from the host */
818
892
  on(type, listener) {
819
893
  if (!this.listeners.has(type)) {
@@ -827,6 +901,8 @@ var Bridge = class {
827
901
  /** Clean up event listeners */
828
902
  destroy() {
829
903
  this._destroyed = true;
904
+ this.actions.clear();
905
+ this.requests.clear();
830
906
  this.listeners.clear();
831
907
  if (typeof window !== "undefined") {
832
908
  window.removeEventListener("message", this._messageHandler);
@@ -835,9 +911,12 @@ var Bridge = class {
835
911
  handleMessage(event) {
836
912
  if (this._destroyed) return;
837
913
  const data = event.data;
838
- if (!data?.type?.startsWith("verentis:")) return;
914
+ if (event.source !== window.parent || data?.version !== 1 || typeof data?.type !== "string" || !data.type.startsWith("verentis:")) return;
915
+ if (this._hostOrigin && event.origin !== this._hostOrigin) return;
839
916
  if (data.type === "verentis:init") {
917
+ if (this._hostOrigin) return;
840
918
  this._hostOrigin = event.origin;
919
+ this.sessionId = typeof data.sessionId === "string" ? data.sessionId : null;
841
920
  console.info("[Verentis SDK] Received verentis:init from host", {
842
921
  origin: event.origin,
843
922
  workspaceId: data.context.workspace.id,
@@ -846,6 +925,10 @@ var Bridge = class {
846
925
  const initData = data;
847
926
  this._initResolve({ context: initData.context, token: initData.token });
848
927
  }
928
+ if (data.type === "verentis:action:invoke") {
929
+ void this.invokeAction(data);
930
+ return;
931
+ }
849
932
  const typeListeners = this.listeners.get(data.type);
850
933
  if (typeListeners) {
851
934
  for (const listener of typeListeners) {
@@ -1099,6 +1182,6 @@ function createVerentisClient(options) {
1099
1182
  return new VerentisClient(options);
1100
1183
  }
1101
1184
 
1102
- export { ApiKeyAuth, Bridge, BridgeAuth, ContextModule, EnginesModule, ExecutionsModule, FilesModule, HttpTransport, InstallationsModule, ResourcesModule, SettingsModule, TokenAuth, VerentisClient, createVerentisClient, findBestMatch, isTerminalStatus, matchMimeType };
1185
+ export { ApiKeyAuth, Bridge, BridgeAuth, ContextModule, EnginesModule, ExecutionsModule, FilesModule, HttpTransport, InstallationsModule, ResourcesModule, SettingsModule, TokenAuth, VerentisClient, createVerentisClient, findBestMatch, isHeaderAction, isTerminalStatus, matchMimeType };
1103
1186
  //# sourceMappingURL=index.js.map
1104
1187
  //# sourceMappingURL=index.js.map