@metamask/snaps-controllers 12.1.0 → 12.3.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +27 -1
  2. package/dist/cronjob/CronjobController.cjs +13 -4
  3. package/dist/cronjob/CronjobController.cjs.map +1 -1
  4. package/dist/cronjob/CronjobController.d.cts.map +1 -1
  5. package/dist/cronjob/CronjobController.d.mts.map +1 -1
  6. package/dist/cronjob/CronjobController.mjs +15 -6
  7. package/dist/cronjob/CronjobController.mjs.map +1 -1
  8. package/dist/interface/SnapInterfaceController.cjs +15 -1
  9. package/dist/interface/SnapInterfaceController.cjs.map +1 -1
  10. package/dist/interface/SnapInterfaceController.d.cts +10 -2
  11. package/dist/interface/SnapInterfaceController.d.cts.map +1 -1
  12. package/dist/interface/SnapInterfaceController.d.mts +10 -2
  13. package/dist/interface/SnapInterfaceController.d.mts.map +1 -1
  14. package/dist/interface/SnapInterfaceController.mjs +17 -3
  15. package/dist/interface/SnapInterfaceController.mjs.map +1 -1
  16. package/dist/interface/utils.cjs +104 -4
  17. package/dist/interface/utils.cjs.map +1 -1
  18. package/dist/interface/utils.d.cts +71 -2
  19. package/dist/interface/utils.d.cts.map +1 -1
  20. package/dist/interface/utils.d.mts +71 -2
  21. package/dist/interface/utils.d.mts.map +1 -1
  22. package/dist/interface/utils.mjs +101 -5
  23. package/dist/interface/utils.mjs.map +1 -1
  24. package/dist/multichain/MultichainRouter.cjs +1 -0
  25. package/dist/multichain/MultichainRouter.cjs.map +1 -1
  26. package/dist/multichain/MultichainRouter.d.cts +1 -0
  27. package/dist/multichain/MultichainRouter.d.cts.map +1 -1
  28. package/dist/multichain/MultichainRouter.d.mts +1 -0
  29. package/dist/multichain/MultichainRouter.d.mts.map +1 -1
  30. package/dist/multichain/MultichainRouter.mjs +1 -0
  31. package/dist/multichain/MultichainRouter.mjs.map +1 -1
  32. package/dist/services/AbstractExecutionService.cjs +127 -202
  33. package/dist/services/AbstractExecutionService.cjs.map +1 -1
  34. package/dist/services/AbstractExecutionService.d.cts +8 -53
  35. package/dist/services/AbstractExecutionService.d.cts.map +1 -1
  36. package/dist/services/AbstractExecutionService.d.mts +8 -53
  37. package/dist/services/AbstractExecutionService.d.mts.map +1 -1
  38. package/dist/services/AbstractExecutionService.mjs +127 -202
  39. package/dist/services/AbstractExecutionService.mjs.map +1 -1
  40. package/dist/services/iframe/IframeExecutionService.cjs +2 -2
  41. package/dist/services/iframe/IframeExecutionService.cjs.map +1 -1
  42. package/dist/services/iframe/IframeExecutionService.d.cts +1 -1
  43. package/dist/services/iframe/IframeExecutionService.d.cts.map +1 -1
  44. package/dist/services/iframe/IframeExecutionService.d.mts +1 -1
  45. package/dist/services/iframe/IframeExecutionService.d.mts.map +1 -1
  46. package/dist/services/iframe/IframeExecutionService.mjs +2 -2
  47. package/dist/services/iframe/IframeExecutionService.mjs.map +1 -1
  48. package/dist/services/offscreen/OffscreenExecutionService.cjs +5 -5
  49. package/dist/services/offscreen/OffscreenExecutionService.cjs.map +1 -1
  50. package/dist/services/offscreen/OffscreenExecutionService.d.cts +4 -4
  51. package/dist/services/offscreen/OffscreenExecutionService.d.cts.map +1 -1
  52. package/dist/services/offscreen/OffscreenExecutionService.d.mts +4 -4
  53. package/dist/services/offscreen/OffscreenExecutionService.d.mts.map +1 -1
  54. package/dist/services/offscreen/OffscreenExecutionService.mjs +5 -5
  55. package/dist/services/offscreen/OffscreenExecutionService.mjs.map +1 -1
  56. package/dist/services/proxy/ProxyExecutionService.cjs +6 -6
  57. package/dist/services/proxy/ProxyExecutionService.cjs.map +1 -1
  58. package/dist/services/proxy/ProxyExecutionService.d.cts +4 -4
  59. package/dist/services/proxy/ProxyExecutionService.d.cts.map +1 -1
  60. package/dist/services/proxy/ProxyExecutionService.d.mts +4 -4
  61. package/dist/services/proxy/ProxyExecutionService.d.mts.map +1 -1
  62. package/dist/services/proxy/ProxyExecutionService.mjs +6 -6
  63. package/dist/services/proxy/ProxyExecutionService.mjs.map +1 -1
  64. package/dist/services/webview/WebViewExecutionService.cjs +6 -6
  65. package/dist/services/webview/WebViewExecutionService.cjs.map +1 -1
  66. package/dist/services/webview/WebViewExecutionService.d.cts +5 -5
  67. package/dist/services/webview/WebViewExecutionService.d.cts.map +1 -1
  68. package/dist/services/webview/WebViewExecutionService.d.mts +5 -5
  69. package/dist/services/webview/WebViewExecutionService.d.mts.map +1 -1
  70. package/dist/services/webview/WebViewExecutionService.mjs +6 -6
  71. package/dist/services/webview/WebViewExecutionService.mjs.map +1 -1
  72. package/dist/snaps/SnapController.cjs +60 -72
  73. package/dist/snaps/SnapController.cjs.map +1 -1
  74. package/dist/snaps/SnapController.d.cts +19 -10
  75. package/dist/snaps/SnapController.d.cts.map +1 -1
  76. package/dist/snaps/SnapController.d.mts +19 -10
  77. package/dist/snaps/SnapController.d.mts.map +1 -1
  78. package/dist/snaps/SnapController.mjs +61 -73
  79. package/dist/snaps/SnapController.mjs.map +1 -1
  80. package/dist/snaps/registry/json.cjs +4 -2
  81. package/dist/snaps/registry/json.cjs.map +1 -1
  82. package/dist/snaps/registry/json.d.cts.map +1 -1
  83. package/dist/snaps/registry/json.d.mts.map +1 -1
  84. package/dist/snaps/registry/json.mjs +4 -2
  85. package/dist/snaps/registry/json.mjs.map +1 -1
  86. package/package.json +4 -4
  87. package/dist/snaps/RequestQueue.cjs +0 -44
  88. package/dist/snaps/RequestQueue.cjs.map +0 -1
  89. package/dist/snaps/RequestQueue.d.cts +0 -25
  90. package/dist/snaps/RequestQueue.d.cts.map +0 -1
  91. package/dist/snaps/RequestQueue.d.mts +0 -25
  92. package/dist/snaps/RequestQueue.d.mts.map +0 -1
  93. package/dist/snaps/RequestQueue.mjs +0 -40
  94. package/dist/snaps/RequestQueue.mjs.map +0 -1
@@ -4,7 +4,6 @@ import type { BasePostMessageStream } from "@metamask/post-message-stream";
4
4
  import type { SnapRpcHookArgs } from "@metamask/snaps-utils";
5
5
  import type { Duplex } from "readable-stream";
6
6
  import type { ExecutionService, ExecutionServiceMessenger, SnapExecutionData } from "./ExecutionService.cjs";
7
- import { Timer } from "../snaps/Timer.cjs";
8
7
  declare const controllerName = "ExecutionService";
9
8
  export type SetupSnapProvider = (snapId: string, stream: Duplex) => void;
10
9
  export type ExecutionServiceArgs = {
@@ -31,14 +30,7 @@ export declare abstract class AbstractExecutionService<WorkerType> implements Ex
31
30
  #private;
32
31
  name: typeof controllerName;
33
32
  state: null;
34
- protected jobs: Map<string, Job<WorkerType>>;
35
- private readonly setupSnapProvider;
36
33
  constructor({ setupSnapProvider, messenger, initTimeout, pingTimeout, terminationTimeout, usePing, }: ExecutionServiceArgs);
37
- /**
38
- * Constructor helper for registering the controller's messaging system
39
- * actions.
40
- */
41
- private registerMessageHandlers;
42
34
  /**
43
35
  * Performs additional necessary work during job termination. **MUST** be
44
36
  * implemented by concrete implementations. See
@@ -48,62 +40,26 @@ export declare abstract class AbstractExecutionService<WorkerType> implements Ex
48
40
  */
49
41
  protected abstract terminateJob(job: TerminateJobArgs<WorkerType>): void;
50
42
  /**
51
- * Terminates the job with the specified ID and deletes all its associated
52
- * data. Any subsequent messages targeting the job will fail with an error.
53
- * Throws an error if the specified job does not exist, or if termination
43
+ * Terminates the Snap with the specified ID and deletes all its associated
44
+ * data. Any subsequent messages targeting the Snap will fail with an error.
45
+ * Throws an error if the specified Snap does not exist, or if termination
54
46
  * fails unexpectedly.
55
47
  *
56
- * @param jobId - The id of the job to be terminated.
57
- */
58
- terminate(jobId: string): Promise<void>;
59
- /**
60
- * Initiates a job for a snap.
61
- *
62
- * @param jobId - The ID of the job to initiate.
63
- * @param timer - The timer to use for timeouts.
64
- * @returns Information regarding the created job.
65
- * @throws If the execution service returns an error or execution times out.
66
- */
67
- protected initJob(jobId: string, timer: Timer): Promise<Job<WorkerType>>;
68
- /**
69
- * Sets up the streams for an initiated job.
70
- *
71
- * @param jobId - The id of the job.
72
- * @param timer - The timer to use for timeouts.
73
- * @returns The streams to communicate with the worker and the worker itself.
74
- * @throws If the execution service returns an error or execution times out.
48
+ * @param snapId - The id of the Snap to be terminated.
75
49
  */
76
- protected initStreams(jobId: string, timer: Timer): Promise<{
77
- streams: JobStreams;
78
- worker: WorkerType;
79
- }>;
50
+ terminateSnap(snapId: string): Promise<void>;
80
51
  /**
81
52
  * Abstract function implemented by implementing class that spins up a new worker for a job.
82
53
  *
83
54
  * Depending on the execution environment, this may run forever if the Snap fails to start up properly, therefore any call to this function should be wrapped in a timeout.
84
55
  */
85
- protected abstract initEnvStream(jobId: string): Promise<{
56
+ protected abstract initEnvStream(snapId: string): Promise<{
86
57
  worker: WorkerType;
87
58
  stream: BasePostMessageStream;
88
59
  }>;
89
- /**
90
- * Terminates the Snap with the specified ID. May throw an error if
91
- * termination unexpectedly fails, but will not fail if no job for the snap
92
- * with the specified ID is found.
93
- *
94
- * @param snapId - The ID of the snap to terminate.
95
- */
96
- terminateSnap(snapId: string): Promise<void>;
97
60
  terminateAllSnaps(): Promise<void>;
98
61
  /**
99
- * Gets the RPC request handler for the given snap.
100
- *
101
- * @param snapId - The id of the Snap whose message handler to get.
102
- * @returns The RPC request handler for the snap.
103
- */
104
- private getRpcRequestHandler;
105
- /**
106
- * Initializes and executes a snap, setting up the communication channels to the snap etc.
62
+ * Initializes and executes a Snap, setting up the communication channels to the Snap etc.
107
63
  *
108
64
  * @param snapData - Data needed for Snap execution.
109
65
  * @param snapData.snapId - The ID of the Snap to execute.
@@ -113,11 +69,10 @@ export declare abstract class AbstractExecutionService<WorkerType> implements Ex
113
69
  * @throws If the execution service returns an error or execution times out.
114
70
  */
115
71
  executeSnap({ snapId, sourceCode, endowments, }: SnapExecutionData): Promise<string>;
116
- private command;
117
72
  /**
118
73
  * Handle RPC request.
119
74
  *
120
- * @param snapId - The ID of the recipient snap.
75
+ * @param snapId - The ID of the recipient Snap.
121
76
  * @param options - Bag of options to pass to the RPC handler.
122
77
  * @returns Promise that can handle the request.
123
78
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractExecutionService.d.cts","sourceRoot":"","sources":["../../src/services/AbstractExecutionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kCAAkC;AAE1D,OAAO,eAAe,mCAAmC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAsC;AAE3E,OAAO,KAAK,EAAe,eAAe,EAAE,8BAA8B;AAiB1E,OAAO,KAAK,EAAE,MAAM,EAAE,wBAAwB;AAE9C,OAAO,KAAK,EACV,gBAAgB,EAChB,yBAAyB,EAEzB,iBAAiB,EAClB,+BAA2B;AAE5B,OAAO,EAAE,KAAK,EAAE,2BAAuB;AAGvC,QAAA,MAAM,cAAc,qBAAqB,CAAC;AAE1C,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;AAEzE,MAAM,MAAM,oBAAoB,GAAG;IACjC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,SAAS,EAAE,yBAAyB,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,qBAAqB,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,UAAU,IAAI;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,UAAU,CAAC;IACpB,SAAS,EAAE,aAAa,CAAC;IACzB,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,GACjE,IAAI,CAAC,GAAG,CAAC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;OASG;IACG,WAAW,CAAC,EAChB,MAAM,EACN,UAAU,EACV,UAAU,GACX,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;YA4DxB,OAAO;IA6DrB;;;;;;OAMG;IACU,gBAAgB,CAC3B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,OAAO,CAAC;CAWpB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,MAAM,GACjB,eAAe,CAUjB"}
1
+ {"version":3,"file":"AbstractExecutionService.d.cts","sourceRoot":"","sources":["../../src/services/AbstractExecutionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kCAAkC;AAE1D,OAAO,eAAe,mCAAmC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAsC;AAE3E,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAgB7D,OAAO,KAAK,EAAE,MAAM,EAAE,wBAAwB;AAE9C,OAAO,KAAK,EACV,gBAAgB,EAChB,yBAAyB,EAEzB,iBAAiB,EAClB,+BAA2B;AAK5B,QAAA,MAAM,cAAc,qBAAqB,CAAC;AAE1C,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;AAEzE,MAAM,MAAM,oBAAoB,GAAG;IACjC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,SAAS,EAAE,yBAAyB,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,qBA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AC5B,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,MAAM,GACjB,eAAe,CAQjB"}
@@ -4,7 +4,6 @@ import type { BasePostMessageStream } from "@metamask/post-message-stream";
4
4
  import type { SnapRpcHookArgs } from "@metamask/snaps-utils";
5
5
  import type { Duplex } from "readable-stream";
6
6
  import type { ExecutionService, ExecutionServiceMessenger, SnapExecutionData } from "./ExecutionService.mjs";
7
- import { Timer } from "../snaps/Timer.mjs";
8
7
  declare const controllerName = "ExecutionService";
9
8
  export type SetupSnapProvider = (snapId: string, stream: Duplex) => void;
10
9
  export type ExecutionServiceArgs = {
@@ -31,14 +30,7 @@ export declare abstract class AbstractExecutionService<WorkerType> implements Ex
31
30
  #private;
32
31
  name: typeof controllerName;
33
32
  state: null;
34
- protected jobs: Map<string, Job<WorkerType>>;
35
- private readonly setupSnapProvider;
36
33
  constructor({ setupSnapProvider, messenger, initTimeout, pingTimeout, terminationTimeout, usePing, }: ExecutionServiceArgs);
37
- /**
38
- * Constructor helper for registering the controller's messaging system
39
- * actions.
40
- */
41
- private registerMessageHandlers;
42
34
  /**
43
35
  * Performs additional necessary work during job termination. **MUST** be
44
36
  * implemented by concrete implementations. See
@@ -48,62 +40,26 @@ export declare abstract class AbstractExecutionService<WorkerType> implements Ex
48
40
  */
49
41
  protected abstract terminateJob(job: TerminateJobArgs<WorkerType>): void;
50
42
  /**
51
- * Terminates the job with the specified ID and deletes all its associated
52
- * data. Any subsequent messages targeting the job will fail with an error.
53
- * Throws an error if the specified job does not exist, or if termination
43
+ * Terminates the Snap with the specified ID and deletes all its associated
44
+ * data. Any subsequent messages targeting the Snap will fail with an error.
45
+ * Throws an error if the specified Snap does not exist, or if termination
54
46
  * fails unexpectedly.
55
47
  *
56
- * @param jobId - The id of the job to be terminated.
57
- */
58
- terminate(jobId: string): Promise<void>;
59
- /**
60
- * Initiates a job for a snap.
61
- *
62
- * @param jobId - The ID of the job to initiate.
63
- * @param timer - The timer to use for timeouts.
64
- * @returns Information regarding the created job.
65
- * @throws If the execution service returns an error or execution times out.
66
- */
67
- protected initJob(jobId: string, timer: Timer): Promise<Job<WorkerType>>;
68
- /**
69
- * Sets up the streams for an initiated job.
70
- *
71
- * @param jobId - The id of the job.
72
- * @param timer - The timer to use for timeouts.
73
- * @returns The streams to communicate with the worker and the worker itself.
74
- * @throws If the execution service returns an error or execution times out.
48
+ * @param snapId - The id of the Snap to be terminated.
75
49
  */
76
- protected initStreams(jobId: string, timer: Timer): Promise<{
77
- streams: JobStreams;
78
- worker: WorkerType;
79
- }>;
50
+ terminateSnap(snapId: string): Promise<void>;
80
51
  /**
81
52
  * Abstract function implemented by implementing class that spins up a new worker for a job.
82
53
  *
83
54
  * Depending on the execution environment, this may run forever if the Snap fails to start up properly, therefore any call to this function should be wrapped in a timeout.
84
55
  */
85
- protected abstract initEnvStream(jobId: string): Promise<{
56
+ protected abstract initEnvStream(snapId: string): Promise<{
86
57
  worker: WorkerType;
87
58
  stream: BasePostMessageStream;
88
59
  }>;
89
- /**
90
- * Terminates the Snap with the specified ID. May throw an error if
91
- * termination unexpectedly fails, but will not fail if no job for the snap
92
- * with the specified ID is found.
93
- *
94
- * @param snapId - The ID of the snap to terminate.
95
- */
96
- terminateSnap(snapId: string): Promise<void>;
97
60
  terminateAllSnaps(): Promise<void>;
98
61
  /**
99
- * Gets the RPC request handler for the given snap.
100
- *
101
- * @param snapId - The id of the Snap whose message handler to get.
102
- * @returns The RPC request handler for the snap.
103
- */
104
- private getRpcRequestHandler;
105
- /**
106
- * Initializes and executes a snap, setting up the communication channels to the snap etc.
62
+ * Initializes and executes a Snap, setting up the communication channels to the Snap etc.
107
63
  *
108
64
  * @param snapData - Data needed for Snap execution.
109
65
  * @param snapData.snapId - The ID of the Snap to execute.
@@ -113,11 +69,10 @@ export declare abstract class AbstractExecutionService<WorkerType> implements Ex
113
69
  * @throws If the execution service returns an error or execution times out.
114
70
  */
115
71
  executeSnap({ snapId, sourceCode, endowments, }: SnapExecutionData): Promise<string>;
116
- private command;
117
72
  /**
118
73
  * Handle RPC request.
119
74
  *
120
- * @param snapId - The ID of the recipient snap.
75
+ * @param snapId - The ID of the recipient Snap.
121
76
  * @param options - Bag of options to pass to the RPC handler.
122
77
  * @returns Promise that can handle the request.
123
78
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractExecutionService.d.mts","sourceRoot":"","sources":["../../src/services/AbstractExecutionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kCAAkC;AAE1D,OAAO,eAAe,mCAAmC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAsC;AAE3E,OAAO,KAAK,EAAe,eAAe,EAAE,8BAA8B;AAiB1E,OAAO,KAAK,EAAE,MAAM,EAAE,wBAAwB;AAE9C,OAAO,KAAK,EACV,gBAAgB,EAChB,yBAAyB,EAEzB,iBAAiB,EAClB,+BAA2B;AAE5B,OAAO,EAAE,KAAK,EAAE,2BAAuB;AAGvC,QAAA,MAAM,cAAc,qBAAqB,CAAC;AAE1C,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;AAEzE,MAAM,MAAM,oBAAoB,GAAG;IACjC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,SAAS,EAAE,yBAAyB,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,qBAAqB,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,UAAU,IAAI;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,UAAU,CAAC;IACpB,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,CAAC;QACnB,MAAM,EAAE,qBAAqB,CAAC;KAC/B,CAAC;IAEF;;;;;;OAMG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM;IAO5B,iBAAiB;IAOvB;;;;;OAKG;IAIH,OAAO,CAAC,oBAAoB;IAI5B;;;;;;;;;OASG;IACG,WAAW,CAAC,EAChB,MAAM,EACN,UAAU,EACV,UAAU,GACX,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;YA4DxB,OAAO;IA6DrB;;;;;;OAMG;IACU,gBAAgB,CAC3B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,OAAO,CAAC;CAWpB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,MAAM,GACjB,eAAe,CAUjB"}
1
+ {"version":3,"file":"AbstractExecutionService.d.mts","sourceRoot":"","sources":["../../src/services/AbstractExecutionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kCAAkC;AAE1D,OAAO,eAAe,mCAAmC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAsC;AAE3E,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAgB7D,OAAO,KAAK,EAAE,MAAM,EAAE,wBAAwB;AAE9C,OAAO,KAAK,EACV,gBAAgB,EAChB,yBAAyB,EAEzB,iBAAiB,EAClB,+BAA2B;AAK5B,QAAA,MAAM,cAAc,qBAAqB,CAAC;AAE1C,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;AAEzE,MAAM,MAAM,oBAAoB,GAAG;IACjC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,SAAS,EAAE,yBAAyB,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAA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