@n8n/task-runner 0.1.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.
@@ -0,0 +1,160 @@
1
+ import type { INodeExecutionData } from 'n8n-workflow';
2
+ export type DataRequestType = 'input' | 'node' | 'all';
3
+ export interface TaskResultData {
4
+ result: INodeExecutionData[];
5
+ customData?: Record<string, string>;
6
+ }
7
+ export declare namespace N8nMessage {
8
+ namespace ToRunner {
9
+ interface InfoRequest {
10
+ type: 'broker:inforequest';
11
+ }
12
+ interface RunnerRegistered {
13
+ type: 'broker:runnerregistered';
14
+ }
15
+ interface TaskOfferAccept {
16
+ type: 'broker:taskofferaccept';
17
+ taskId: string;
18
+ offerId: string;
19
+ }
20
+ interface TaskCancel {
21
+ type: 'broker:taskcancel';
22
+ taskId: string;
23
+ reason: string;
24
+ }
25
+ interface TaskSettings {
26
+ type: 'broker:tasksettings';
27
+ taskId: string;
28
+ settings: unknown;
29
+ }
30
+ interface RPCResponse {
31
+ type: 'broker:rpcresponse';
32
+ callId: string;
33
+ taskId: string;
34
+ status: 'success' | 'error';
35
+ data: unknown;
36
+ }
37
+ interface TaskDataResponse {
38
+ type: 'broker:taskdataresponse';
39
+ taskId: string;
40
+ requestId: string;
41
+ data: unknown;
42
+ }
43
+ type All = InfoRequest | TaskOfferAccept | TaskCancel | TaskSettings | RunnerRegistered | RPCResponse | TaskDataResponse;
44
+ }
45
+ namespace ToRequester {
46
+ interface TaskReady {
47
+ type: 'broker:taskready';
48
+ requestId: string;
49
+ taskId: string;
50
+ }
51
+ interface TaskDone {
52
+ type: 'broker:taskdone';
53
+ taskId: string;
54
+ data: TaskResultData;
55
+ }
56
+ interface TaskError {
57
+ type: 'broker:taskerror';
58
+ taskId: string;
59
+ error: unknown;
60
+ }
61
+ interface TaskDataRequest {
62
+ type: 'broker:taskdatarequest';
63
+ taskId: string;
64
+ requestId: string;
65
+ requestType: DataRequestType;
66
+ param?: string;
67
+ }
68
+ interface RPC {
69
+ type: 'broker:rpc';
70
+ callId: string;
71
+ taskId: string;
72
+ name: (typeof RPC_ALLOW_LIST)[number];
73
+ params: unknown[];
74
+ }
75
+ type All = TaskReady | TaskDone | TaskError | TaskDataRequest | RPC;
76
+ }
77
+ }
78
+ export declare namespace RequesterMessage {
79
+ namespace ToN8n {
80
+ interface TaskSettings {
81
+ type: 'requester:tasksettings';
82
+ taskId: string;
83
+ settings: unknown;
84
+ }
85
+ interface TaskCancel {
86
+ type: 'requester:taskcancel';
87
+ taskId: string;
88
+ reason: string;
89
+ }
90
+ interface TaskDataResponse {
91
+ type: 'requester:taskdataresponse';
92
+ taskId: string;
93
+ requestId: string;
94
+ data: unknown;
95
+ }
96
+ interface RPCResponse {
97
+ type: 'requester:rpcresponse';
98
+ taskId: string;
99
+ callId: string;
100
+ status: 'success' | 'error';
101
+ data: unknown;
102
+ }
103
+ interface TaskRequest {
104
+ type: 'requester:taskrequest';
105
+ requestId: string;
106
+ taskType: string;
107
+ }
108
+ type All = TaskSettings | TaskCancel | RPCResponse | TaskDataResponse | TaskRequest;
109
+ }
110
+ }
111
+ export declare namespace RunnerMessage {
112
+ namespace ToN8n {
113
+ interface Info {
114
+ type: 'runner:info';
115
+ name: string;
116
+ types: string[];
117
+ }
118
+ interface TaskAccepted {
119
+ type: 'runner:taskaccepted';
120
+ taskId: string;
121
+ }
122
+ interface TaskRejected {
123
+ type: 'runner:taskrejected';
124
+ taskId: string;
125
+ reason: string;
126
+ }
127
+ interface TaskDone {
128
+ type: 'runner:taskdone';
129
+ taskId: string;
130
+ data: TaskResultData;
131
+ }
132
+ interface TaskError {
133
+ type: 'runner:taskerror';
134
+ taskId: string;
135
+ error: unknown;
136
+ }
137
+ interface TaskOffer {
138
+ type: 'runner:taskoffer';
139
+ offerId: string;
140
+ taskType: string;
141
+ validFor: number;
142
+ }
143
+ interface TaskDataRequest {
144
+ type: 'runner:taskdatarequest';
145
+ taskId: string;
146
+ requestId: string;
147
+ requestType: DataRequestType;
148
+ param?: string;
149
+ }
150
+ interface RPC {
151
+ type: 'runner:rpc';
152
+ callId: string;
153
+ taskId: string;
154
+ name: (typeof RPC_ALLOW_LIST)[number];
155
+ params: unknown[];
156
+ }
157
+ type All = Info | TaskDone | TaskError | TaskAccepted | TaskRejected | TaskOffer | RPC | TaskDataRequest;
158
+ }
159
+ }
160
+ export declare const RPC_ALLOW_LIST: readonly ["helpers.httpRequestWithAuthentication", "helpers.requestWithAuthenticationPaginated", "helpers.getBinaryDataBuffer", "helpers.getSSHClient", "helpers.createReadStream", "helpers.writeContentToFile", "helpers.prepareBinaryData", "helpers.setBinaryDataBuffer", "helpers.copyBinaryFile", "helpers.binaryToBuffer", "helpers.getBinaryStream", "helpers.getBinaryMetadata", "helpers.createDeferredPromise", "helpers.httpRequest", "logNodeOutput"];
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RPC_ALLOW_LIST = void 0;
4
+ exports.RPC_ALLOW_LIST = [
5
+ 'helpers.httpRequestWithAuthentication',
6
+ 'helpers.requestWithAuthenticationPaginated',
7
+ 'helpers.getBinaryDataBuffer',
8
+ 'helpers.getSSHClient',
9
+ 'helpers.createReadStream',
10
+ 'helpers.writeContentToFile',
11
+ 'helpers.prepareBinaryData',
12
+ 'helpers.setBinaryDataBuffer',
13
+ 'helpers.copyBinaryFile',
14
+ 'helpers.binaryToBuffer',
15
+ 'helpers.getBinaryStream',
16
+ 'helpers.getBinaryMetadata',
17
+ 'helpers.createDeferredPromise',
18
+ 'helpers.httpRequest',
19
+ 'logNodeOutput',
20
+ ];
21
+ //# sourceMappingURL=runner-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner-types.js","sourceRoot":"","sources":["../src/runner-types.ts"],"names":[],"mappings":";;;AA8Ma,QAAA,cAAc,GAAG;IAC7B,uCAAuC;IACvC,4CAA4C;IAI5C,6BAA6B;IAG7B,sBAAsB;IACtB,0BAA0B;IAE1B,4BAA4B;IAC5B,2BAA2B;IAC3B,6BAA6B;IAC7B,wBAAwB;IACxB,wBAAwB;IAGxB,yBAAyB;IACzB,2BAA2B;IAC3B,+BAA+B;IAC/B,qBAAqB;IACrB,eAAe;CACN,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
package/dist/start.js ADDED
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const n8n_workflow_1 = require("n8n-workflow");
27
+ const a = __importStar(require("node:assert/strict"));
28
+ const authenticator_1 = require("./authenticator");
29
+ const code_1 = require("./code");
30
+ function readAndParseConfig() {
31
+ const authToken = process.env.N8N_RUNNERS_AUTH_TOKEN;
32
+ const grantToken = process.env.N8N_RUNNERS_GRANT_TOKEN;
33
+ if (!authToken && !grantToken) {
34
+ throw new n8n_workflow_1.ApplicationError('Missing task runner authentication. Use either N8N_RUNNERS_AUTH_TOKEN or N8N_RUNNERS_GRANT_TOKEN to configure it');
35
+ }
36
+ return {
37
+ n8nUri: process.env.N8N_RUNNERS_N8N_URI ?? 'localhost:5678',
38
+ authToken,
39
+ grantToken,
40
+ };
41
+ }
42
+ void (async function start() {
43
+ const config = readAndParseConfig();
44
+ let grantToken = config.grantToken;
45
+ if (!grantToken) {
46
+ a.ok(config.authToken);
47
+ grantToken = await (0, authenticator_1.authenticate)({
48
+ authToken: config.authToken,
49
+ n8nUri: config.n8nUri,
50
+ });
51
+ }
52
+ const wsUrl = `ws://${config.n8nUri}/rest/runners/_ws`;
53
+ new code_1.JsTaskRunner('javascript', wsUrl, grantToken, 5);
54
+ })();
55
+ //# sourceMappingURL=start.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgD;AAChD,sDAAwC;AAExC,mDAA+C;AAC/C,iCAAsC;AAQtC,SAAS,kBAAkB;IAC1B,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;IACrD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;IACvD,IAAI,CAAC,SAAS,IAAI,CAAC,UAAU,EAAE,CAAC;QAC/B,MAAM,IAAI,+BAAgB,CAAC,kHAAkH,CAAC,CAAA;IAC/I,CAAC;IAED,OAAO;QACN,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,gBAAgB;QAC3D,SAAS;QACT,UAAU;KACV,CAAC;AACH,CAAC;AAED,KAAK,CAAC,KAAK,UAAU,KAAK;IACzB,MAAM,MAAM,GAAG,kBAAkB,EAAE,CAAC;IAEpC,IAAI,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IACnC,IAAI,CAAC,UAAU,EAAE,CAAC;QACjB,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAEvB,UAAU,GAAG,MAAM,IAAA,4BAAY,EAAC;YAC/B,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;SACrB,CAAC,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,QAAQ,MAAM,CAAC,MAAM,mBAAmB,CAAC;IACvD,IAAI,mBAAY,CAAC,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;AACtD,CAAC,CAAC,EAAE,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { WebSocket } from 'ws';
2
+ import { type RunnerMessage, type N8nMessage, type TaskResultData } from './runner-types';
3
+ export interface Task<T = unknown> {
4
+ taskId: string;
5
+ settings?: T;
6
+ active: boolean;
7
+ cancelled: boolean;
8
+ }
9
+ export interface TaskOffer {
10
+ offerId: string;
11
+ validUntil: bigint;
12
+ }
13
+ interface DataRequest {
14
+ requestId: string;
15
+ resolve: (data: unknown) => void;
16
+ reject: (error: unknown) => void;
17
+ }
18
+ interface RPCCall {
19
+ callId: string;
20
+ resolve: (data: unknown) => void;
21
+ reject: (error: unknown) => void;
22
+ }
23
+ export interface RPCCallObject {
24
+ [name: string]: ((...args: unknown[]) => Promise<unknown>) | RPCCallObject;
25
+ }
26
+ export declare abstract class TaskRunner {
27
+ taskType: string;
28
+ private maxConcurrency;
29
+ name?: string | undefined;
30
+ id: string;
31
+ ws: WebSocket;
32
+ canSendOffers: boolean;
33
+ runningTasks: Map<Task['taskId'], Task>;
34
+ offerInterval: NodeJS.Timeout | undefined;
35
+ openOffers: Map<TaskOffer['offerId'], TaskOffer>;
36
+ dataRequests: Map<DataRequest['requestId'], DataRequest>;
37
+ rpcCalls: Map<RPCCall['callId'], RPCCall>;
38
+ constructor(taskType: string, wsUrl: string, grantToken: string, maxConcurrency: number, name?: string | undefined);
39
+ private receiveMessage;
40
+ private stopTaskOffers;
41
+ private startTaskOffers;
42
+ deleteStaleOffers(): void;
43
+ sendOffers(): void;
44
+ send(message: RunnerMessage.ToN8n.All): void;
45
+ onMessage(message: N8nMessage.ToRunner.All): void;
46
+ processDataResponse(requestId: string, data: unknown): void;
47
+ hasOpenTasks(): boolean;
48
+ offerAccepted(offerId: string, taskId: string): void;
49
+ taskCancelled(taskId: string): void;
50
+ taskErrored(taskId: string, error: unknown): void;
51
+ taskDone(taskId: string, data: RunnerMessage.ToN8n.TaskDone['data']): void;
52
+ receivedSettings(taskId: string, settings: unknown): Promise<void>;
53
+ executeTask(_task: Task): Promise<TaskResultData>;
54
+ requestData<T = unknown>(taskId: Task['taskId'], type: RunnerMessage.ToN8n.TaskDataRequest['requestType'], param?: string): Promise<T>;
55
+ makeRpcCall(taskId: string, name: RunnerMessage.ToN8n.RPC['name'], params: unknown[]): Promise<unknown>;
56
+ handleRpcResponse(callId: string, status: N8nMessage.ToRunner.RPCResponse['status'], data: unknown): void;
57
+ buildRpcCallObject(taskId: string): RPCCallObject;
58
+ }
59
+ export {};
@@ -0,0 +1,281 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TaskRunner = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const nanoid_1 = require("nanoid");
6
+ const node_url_1 = require("node:url");
7
+ const ws_1 = require("ws");
8
+ const runner_types_1 = require("./runner-types");
9
+ const VALID_TIME_MS = 1000;
10
+ const VALID_EXTRA_MS = 100;
11
+ class TaskRunner {
12
+ constructor(taskType, wsUrl, grantToken, maxConcurrency, name) {
13
+ this.taskType = taskType;
14
+ this.maxConcurrency = maxConcurrency;
15
+ this.name = name;
16
+ this.id = (0, nanoid_1.nanoid)();
17
+ this.canSendOffers = false;
18
+ this.runningTasks = new Map();
19
+ this.openOffers = new Map();
20
+ this.dataRequests = new Map();
21
+ this.rpcCalls = new Map();
22
+ this.receiveMessage = (message) => {
23
+ const data = JSON.parse(message.data);
24
+ void this.onMessage(data);
25
+ };
26
+ this.stopTaskOffers = () => {
27
+ this.canSendOffers = false;
28
+ if (this.offerInterval) {
29
+ clearInterval(this.offerInterval);
30
+ this.offerInterval = undefined;
31
+ }
32
+ };
33
+ const url = new node_url_1.URL(wsUrl);
34
+ url.searchParams.append('id', this.id);
35
+ this.ws = new ws_1.WebSocket(url.toString(), {
36
+ headers: {
37
+ authorization: `Bearer ${grantToken}`,
38
+ },
39
+ });
40
+ this.ws.addEventListener('message', this.receiveMessage);
41
+ this.ws.addEventListener('close', this.stopTaskOffers);
42
+ }
43
+ startTaskOffers() {
44
+ this.canSendOffers = true;
45
+ if (this.offerInterval) {
46
+ clearInterval(this.offerInterval);
47
+ }
48
+ this.offerInterval = setInterval(() => this.sendOffers(), 250);
49
+ }
50
+ deleteStaleOffers() {
51
+ this.openOffers.forEach((offer, key) => {
52
+ if (offer.validUntil < process.hrtime.bigint()) {
53
+ this.openOffers.delete(key);
54
+ }
55
+ });
56
+ }
57
+ sendOffers() {
58
+ this.deleteStaleOffers();
59
+ const offersToSend = this.maxConcurrency -
60
+ (Object.values(this.openOffers).length + Object.values(this.runningTasks).length);
61
+ for (let i = 0; i < offersToSend; i++) {
62
+ const offer = {
63
+ offerId: (0, nanoid_1.nanoid)(),
64
+ validUntil: process.hrtime.bigint() + BigInt((VALID_TIME_MS + VALID_EXTRA_MS) * 1_000_000),
65
+ };
66
+ this.openOffers.set(offer.offerId, offer);
67
+ this.send({
68
+ type: 'runner:taskoffer',
69
+ taskType: this.taskType,
70
+ offerId: offer.offerId,
71
+ validFor: VALID_TIME_MS,
72
+ });
73
+ }
74
+ }
75
+ send(message) {
76
+ this.ws.send(JSON.stringify(message));
77
+ }
78
+ onMessage(message) {
79
+ switch (message.type) {
80
+ case 'broker:inforequest':
81
+ this.send({
82
+ type: 'runner:info',
83
+ name: this.name ?? 'Node.js Task Runner SDK',
84
+ types: [this.taskType],
85
+ });
86
+ break;
87
+ case 'broker:runnerregistered':
88
+ this.startTaskOffers();
89
+ break;
90
+ case 'broker:taskofferaccept':
91
+ this.offerAccepted(message.offerId, message.taskId);
92
+ break;
93
+ case 'broker:taskcancel':
94
+ this.taskCancelled(message.taskId);
95
+ break;
96
+ case 'broker:tasksettings':
97
+ void this.receivedSettings(message.taskId, message.settings);
98
+ break;
99
+ case 'broker:taskdataresponse':
100
+ this.processDataResponse(message.requestId, message.data);
101
+ break;
102
+ case 'broker:rpcresponse':
103
+ this.handleRpcResponse(message.callId, message.status, message.data);
104
+ }
105
+ }
106
+ processDataResponse(requestId, data) {
107
+ const request = this.dataRequests.get(requestId);
108
+ if (!request) {
109
+ return;
110
+ }
111
+ request.resolve(data);
112
+ }
113
+ hasOpenTasks() {
114
+ return Object.values(this.runningTasks).length < this.maxConcurrency;
115
+ }
116
+ offerAccepted(offerId, taskId) {
117
+ if (!this.hasOpenTasks()) {
118
+ this.send({
119
+ type: 'runner:taskrejected',
120
+ taskId,
121
+ reason: 'No open task slots',
122
+ });
123
+ return;
124
+ }
125
+ const offer = this.openOffers.get(offerId);
126
+ if (!offer) {
127
+ this.send({
128
+ type: 'runner:taskrejected',
129
+ taskId,
130
+ reason: 'Offer expired and no open task slots',
131
+ });
132
+ return;
133
+ }
134
+ else {
135
+ this.openOffers.delete(offerId);
136
+ }
137
+ this.runningTasks.set(taskId, {
138
+ taskId,
139
+ active: false,
140
+ cancelled: false,
141
+ });
142
+ this.send({
143
+ type: 'runner:taskaccepted',
144
+ taskId,
145
+ });
146
+ }
147
+ taskCancelled(taskId) {
148
+ const task = this.runningTasks.get(taskId);
149
+ if (!task) {
150
+ return;
151
+ }
152
+ task.cancelled = true;
153
+ if (task.active) {
154
+ }
155
+ else {
156
+ this.runningTasks.delete(taskId);
157
+ }
158
+ this.sendOffers();
159
+ }
160
+ taskErrored(taskId, error) {
161
+ this.send({
162
+ type: 'runner:taskerror',
163
+ taskId,
164
+ error,
165
+ });
166
+ this.runningTasks.delete(taskId);
167
+ this.sendOffers();
168
+ }
169
+ taskDone(taskId, data) {
170
+ this.send({
171
+ type: 'runner:taskdone',
172
+ taskId,
173
+ data,
174
+ });
175
+ this.runningTasks.delete(taskId);
176
+ this.sendOffers();
177
+ }
178
+ async receivedSettings(taskId, settings) {
179
+ const task = this.runningTasks.get(taskId);
180
+ if (!task) {
181
+ return;
182
+ }
183
+ if (task.cancelled) {
184
+ this.runningTasks.delete(taskId);
185
+ return;
186
+ }
187
+ task.settings = settings;
188
+ task.active = true;
189
+ try {
190
+ const data = await this.executeTask(task);
191
+ this.taskDone(taskId, data);
192
+ }
193
+ catch (e) {
194
+ if ((0, n8n_workflow_1.ensureError)(e)) {
195
+ this.taskErrored(taskId, e.message);
196
+ }
197
+ else {
198
+ this.taskErrored(taskId, e);
199
+ }
200
+ }
201
+ }
202
+ async executeTask(_task) {
203
+ throw new n8n_workflow_1.ApplicationError('Unimplemented');
204
+ }
205
+ async requestData(taskId, type, param) {
206
+ const requestId = (0, nanoid_1.nanoid)();
207
+ const p = new Promise((resolve, reject) => {
208
+ this.dataRequests.set(requestId, {
209
+ requestId,
210
+ resolve: resolve,
211
+ reject,
212
+ });
213
+ });
214
+ this.send({
215
+ type: 'runner:taskdatarequest',
216
+ taskId,
217
+ requestId,
218
+ requestType: type,
219
+ param,
220
+ });
221
+ try {
222
+ return await p;
223
+ }
224
+ finally {
225
+ this.dataRequests.delete(requestId);
226
+ }
227
+ }
228
+ async makeRpcCall(taskId, name, params) {
229
+ const callId = (0, nanoid_1.nanoid)();
230
+ const dataPromise = new Promise((resolve, reject) => {
231
+ this.rpcCalls.set(callId, {
232
+ callId,
233
+ resolve,
234
+ reject,
235
+ });
236
+ });
237
+ this.send({
238
+ type: 'runner:rpc',
239
+ callId,
240
+ taskId,
241
+ name,
242
+ params,
243
+ });
244
+ try {
245
+ return await dataPromise;
246
+ }
247
+ finally {
248
+ this.rpcCalls.delete(callId);
249
+ }
250
+ }
251
+ handleRpcResponse(callId, status, data) {
252
+ const call = this.rpcCalls.get(callId);
253
+ if (!call) {
254
+ return;
255
+ }
256
+ if (status === 'success') {
257
+ call.resolve(data);
258
+ }
259
+ else {
260
+ call.reject(typeof data === 'string' ? new Error(data) : data);
261
+ }
262
+ }
263
+ buildRpcCallObject(taskId) {
264
+ const rpcObject = {};
265
+ for (const r of runner_types_1.RPC_ALLOW_LIST) {
266
+ const splitPath = r.split('.');
267
+ let obj = rpcObject;
268
+ splitPath.forEach((s, index) => {
269
+ if (index !== splitPath.length - 1) {
270
+ obj[s] = {};
271
+ obj = obj[s];
272
+ return;
273
+ }
274
+ obj[s] = async (...args) => await this.makeRpcCall(taskId, r, args);
275
+ });
276
+ }
277
+ return rpcObject;
278
+ }
279
+ }
280
+ exports.TaskRunner = TaskRunner;
281
+ //# sourceMappingURL=task-runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-runner.js","sourceRoot":"","sources":["../src/task-runner.ts"],"names":[],"mappings":";;;AAAA,+CAA6D;AAC7D,mCAAgC;AAChC,uCAA+B;AAC/B,2BAAkD;AAElD,iDAKwB;AA8BxB,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,MAAsB,UAAU;IAiB/B,YACQ,QAAgB,EACvB,KAAa,EACb,UAAkB,EACV,cAAsB,EACvB,IAAa;QAJb,aAAQ,GAAR,QAAQ,CAAQ;QAGf,mBAAc,GAAd,cAAc,CAAQ;QACvB,SAAI,GAAJ,IAAI,CAAS;QArBrB,OAAE,GAAW,IAAA,eAAM,GAAE,CAAC;QAItB,kBAAa,GAAG,KAAK,CAAC;QAEtB,iBAAY,GAA8B,IAAI,GAAG,EAAE,CAAC;QAIpD,eAAU,GAAyC,IAAI,GAAG,EAAE,CAAC;QAE7D,iBAAY,GAA+C,IAAI,GAAG,EAAE,CAAC;QAErE,aAAQ,GAAoC,IAAI,GAAG,EAAE,CAAC;QAoB9C,mBAAc,GAAG,CAAC,OAAqB,EAAE,EAAE;YAElD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAc,CAA4B,CAAC;YAC3E,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QA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