@tasker-systems/tasker 0.1.4 → 0.1.5
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 +46 -85
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.js +374 -295
- package/dist/events/index.js.map +1 -1
- package/dist/ffi/index.d.ts +323 -221
- package/dist/ffi/index.js +58 -1887
- package/dist/ffi/index.js.map +1 -1
- package/dist/{index-CTl8lGpU.d.ts → index-Bvdub2HH.d.ts} +77 -36
- package/dist/index.d.ts +75 -141
- package/dist/index.js +618 -2486
- package/dist/index.js.map +1 -1
- package/package.json +14 -7
- package/{native/libtasker_ts-darwin-arm64.dylib → tasker_ts.darwin-arm64.node} +0 -0
- package/{native/libtasker_ts-linux-x64.so → tasker_ts.linux-x64-gnu.node} +0 -0
- package/dist/koffi-3HFAASOB.node +0 -0
- package/dist/koffi-AHHUCM3C.node +0 -0
- package/dist/koffi-AVDVVSXH.node +0 -0
- package/dist/koffi-BMO5K7B3.node +0 -0
- package/dist/koffi-G4D35B2D.node +0 -0
- package/dist/koffi-GG4SDSYA.node +0 -0
- package/dist/koffi-GOENU54R.node +0 -0
- package/dist/koffi-IDX6JEDH.node +0 -0
- package/dist/koffi-KFZAXWPQ.node +0 -0
- package/dist/koffi-LOH6WKRQ.node +0 -0
- package/dist/koffi-LUY2JHJP.node +0 -0
- package/dist/koffi-OMHWL3D6.node +0 -0
- package/dist/koffi-QKY2KSXW.node +0 -0
- package/dist/koffi-ROB3FRHA.node +0 -0
- package/dist/koffi-SE4ZI36U.node +0 -0
- package/dist/koffi-X3YT67KE.node +0 -0
- package/dist/koffi-X7JMBSZH.node +0 -0
- package/dist/koffi-YNQDUF3Q.node +0 -0
- package/dist/runtime-interface-D940vUzy.d.ts +0 -694
package/dist/ffi/index.js
CHANGED
|
@@ -2,1956 +2,131 @@ import { existsSync } from 'fs';
|
|
|
2
2
|
import { dirname, join } from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
|
|
5
|
-
var __create = Object.create;
|
|
6
|
-
var __defProp = Object.defineProperty;
|
|
7
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
9
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
5
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
12
6
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
13
7
|
}) : x)(function(x) {
|
|
14
8
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
15
9
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
16
10
|
});
|
|
17
|
-
var __esm = (fn, res) => function __init() {
|
|
18
|
-
return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
|
|
19
|
-
};
|
|
20
|
-
var __commonJS2 = (cb, mod3) => function __require2() {
|
|
21
|
-
return mod3 || (0, cb[__getOwnPropNames2(cb)[0]])((mod3 = { exports: {} }).exports, mod3), mod3.exports;
|
|
22
|
-
};
|
|
23
|
-
var __export = (target, all) => {
|
|
24
|
-
for (var name in all)
|
|
25
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
|
-
};
|
|
27
|
-
var __copyProps = (to, from, except, desc) => {
|
|
28
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
-
for (let key of __getOwnPropNames2(from))
|
|
30
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
31
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
32
|
-
}
|
|
33
|
-
return to;
|
|
34
|
-
};
|
|
35
|
-
var __toESM = (mod3, isNodeMode, target) => (target = mod3 != null ? __create(__getProtoOf(mod3)) : {}, __copyProps(
|
|
36
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
37
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
38
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
39
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
40
|
-
__defProp(target, "default", { value: mod3, enumerable: true }) ,
|
|
41
|
-
mod3
|
|
42
|
-
));
|
|
43
|
-
|
|
44
|
-
// src/ffi/runtime-interface.ts
|
|
45
|
-
var BaseTaskerRuntime;
|
|
46
|
-
var init_runtime_interface = __esm({
|
|
47
|
-
"src/ffi/runtime-interface.ts"() {
|
|
48
|
-
BaseTaskerRuntime = class {
|
|
49
|
-
/**
|
|
50
|
-
* Helper to parse JSON string from FFI
|
|
51
|
-
*/
|
|
52
|
-
parseJson(jsonStr) {
|
|
53
|
-
if (jsonStr === null || jsonStr === "") {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
return JSON.parse(jsonStr);
|
|
58
|
-
} catch {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Helper to stringify JSON for FFI
|
|
64
|
-
*/
|
|
65
|
-
toJson(value) {
|
|
66
|
-
return JSON.stringify(value);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// src/ffi/deno-runtime.ts
|
|
73
|
-
var deno_runtime_exports = {};
|
|
74
|
-
__export(deno_runtime_exports, {
|
|
75
|
-
DenoRuntime: () => DenoRuntime
|
|
76
|
-
});
|
|
77
|
-
var DenoRuntime;
|
|
78
|
-
var init_deno_runtime = __esm({
|
|
79
|
-
"src/ffi/deno-runtime.ts"() {
|
|
80
|
-
init_runtime_interface();
|
|
81
|
-
DenoRuntime = class extends BaseTaskerRuntime {
|
|
82
|
-
name = "deno";
|
|
83
|
-
lib = null;
|
|
84
|
-
encoder = new TextEncoder();
|
|
85
|
-
get isLoaded() {
|
|
86
|
-
return this.lib !== null;
|
|
87
|
-
}
|
|
88
|
-
async load(libraryPath) {
|
|
89
|
-
if (this.lib !== null) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (typeof Deno === "undefined") {
|
|
93
|
-
throw new Error("Deno runtime not detected");
|
|
94
|
-
}
|
|
95
|
-
this.lib = Deno.dlopen(libraryPath, {
|
|
96
|
-
get_version: {
|
|
97
|
-
parameters: [],
|
|
98
|
-
result: "pointer"
|
|
99
|
-
},
|
|
100
|
-
get_rust_version: {
|
|
101
|
-
parameters: [],
|
|
102
|
-
result: "pointer"
|
|
103
|
-
},
|
|
104
|
-
health_check: {
|
|
105
|
-
parameters: [],
|
|
106
|
-
result: "i32"
|
|
107
|
-
},
|
|
108
|
-
is_worker_running: {
|
|
109
|
-
parameters: [],
|
|
110
|
-
result: "i32"
|
|
111
|
-
},
|
|
112
|
-
bootstrap_worker: {
|
|
113
|
-
parameters: ["buffer"],
|
|
114
|
-
result: "pointer"
|
|
115
|
-
},
|
|
116
|
-
get_worker_status: {
|
|
117
|
-
parameters: [],
|
|
118
|
-
result: "pointer"
|
|
119
|
-
},
|
|
120
|
-
stop_worker: {
|
|
121
|
-
parameters: [],
|
|
122
|
-
result: "pointer"
|
|
123
|
-
},
|
|
124
|
-
transition_to_graceful_shutdown: {
|
|
125
|
-
parameters: [],
|
|
126
|
-
result: "pointer"
|
|
127
|
-
},
|
|
128
|
-
poll_step_events: {
|
|
129
|
-
parameters: [],
|
|
130
|
-
result: "pointer"
|
|
131
|
-
},
|
|
132
|
-
poll_in_process_events: {
|
|
133
|
-
parameters: [],
|
|
134
|
-
result: "pointer"
|
|
135
|
-
},
|
|
136
|
-
complete_step_event: {
|
|
137
|
-
parameters: ["buffer", "buffer"],
|
|
138
|
-
result: "i32"
|
|
139
|
-
},
|
|
140
|
-
checkpoint_yield_step_event: {
|
|
141
|
-
parameters: ["buffer", "buffer"],
|
|
142
|
-
result: "i32"
|
|
143
|
-
},
|
|
144
|
-
get_ffi_dispatch_metrics: {
|
|
145
|
-
parameters: [],
|
|
146
|
-
result: "pointer"
|
|
147
|
-
},
|
|
148
|
-
check_starvation_warnings: {
|
|
149
|
-
parameters: [],
|
|
150
|
-
result: "void"
|
|
151
|
-
},
|
|
152
|
-
cleanup_timeouts: {
|
|
153
|
-
parameters: [],
|
|
154
|
-
result: "void"
|
|
155
|
-
},
|
|
156
|
-
log_error: {
|
|
157
|
-
parameters: ["buffer", "buffer"],
|
|
158
|
-
result: "void"
|
|
159
|
-
},
|
|
160
|
-
log_warn: {
|
|
161
|
-
parameters: ["buffer", "buffer"],
|
|
162
|
-
result: "void"
|
|
163
|
-
},
|
|
164
|
-
log_info: {
|
|
165
|
-
parameters: ["buffer", "buffer"],
|
|
166
|
-
result: "void"
|
|
167
|
-
},
|
|
168
|
-
log_debug: {
|
|
169
|
-
parameters: ["buffer", "buffer"],
|
|
170
|
-
result: "void"
|
|
171
|
-
},
|
|
172
|
-
log_trace: {
|
|
173
|
-
parameters: ["buffer", "buffer"],
|
|
174
|
-
result: "void"
|
|
175
|
-
},
|
|
176
|
-
free_rust_string: {
|
|
177
|
-
parameters: ["pointer"],
|
|
178
|
-
result: "void"
|
|
179
|
-
},
|
|
180
|
-
// Client API functions (TAS-231)
|
|
181
|
-
client_create_task: {
|
|
182
|
-
parameters: ["buffer"],
|
|
183
|
-
result: "pointer"
|
|
184
|
-
},
|
|
185
|
-
client_get_task: {
|
|
186
|
-
parameters: ["buffer"],
|
|
187
|
-
result: "pointer"
|
|
188
|
-
},
|
|
189
|
-
client_list_tasks: {
|
|
190
|
-
parameters: ["buffer"],
|
|
191
|
-
result: "pointer"
|
|
192
|
-
},
|
|
193
|
-
client_cancel_task: {
|
|
194
|
-
parameters: ["buffer"],
|
|
195
|
-
result: "pointer"
|
|
196
|
-
},
|
|
197
|
-
client_list_task_steps: {
|
|
198
|
-
parameters: ["buffer"],
|
|
199
|
-
result: "pointer"
|
|
200
|
-
},
|
|
201
|
-
client_get_step: {
|
|
202
|
-
parameters: ["buffer", "buffer"],
|
|
203
|
-
result: "pointer"
|
|
204
|
-
},
|
|
205
|
-
client_get_step_audit_history: {
|
|
206
|
-
parameters: ["buffer", "buffer"],
|
|
207
|
-
result: "pointer"
|
|
208
|
-
},
|
|
209
|
-
client_health_check: {
|
|
210
|
-
parameters: [],
|
|
211
|
-
result: "pointer"
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
unload() {
|
|
216
|
-
if (this.lib) {
|
|
217
|
-
this.lib.close();
|
|
218
|
-
this.lib = null;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
ensureLoaded() {
|
|
222
|
-
if (!this.lib) {
|
|
223
|
-
throw new Error("Native library not loaded. Call load() first.");
|
|
224
|
-
}
|
|
225
|
-
return this.lib.symbols;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Creates a null-terminated C string buffer.
|
|
229
|
-
* With 'buffer' FFI type, we return Uint8Array directly.
|
|
230
|
-
*/
|
|
231
|
-
toCString(str) {
|
|
232
|
-
return this.encoder.encode(`${str}\0`);
|
|
233
|
-
}
|
|
234
|
-
// biome-ignore lint/suspicious/noExplicitAny: Deno PointerValue type
|
|
235
|
-
fromCString(ptr) {
|
|
236
|
-
if (ptr === null || Deno.UnsafePointer.equals(ptr, null)) {
|
|
237
|
-
return null;
|
|
238
|
-
}
|
|
239
|
-
const view = new Deno.UnsafePointerView(ptr);
|
|
240
|
-
return view.getCString();
|
|
241
|
-
}
|
|
242
|
-
getVersion() {
|
|
243
|
-
const symbols = this.ensureLoaded();
|
|
244
|
-
const result = symbols.get_version();
|
|
245
|
-
const version = this.fromCString(result) ?? "unknown";
|
|
246
|
-
if (result !== null) symbols.free_rust_string(result);
|
|
247
|
-
return version;
|
|
248
|
-
}
|
|
249
|
-
getRustVersion() {
|
|
250
|
-
const symbols = this.ensureLoaded();
|
|
251
|
-
const result = symbols.get_rust_version();
|
|
252
|
-
const version = this.fromCString(result) ?? "unknown";
|
|
253
|
-
if (result !== null) symbols.free_rust_string(result);
|
|
254
|
-
return version;
|
|
255
|
-
}
|
|
256
|
-
healthCheck() {
|
|
257
|
-
const symbols = this.ensureLoaded();
|
|
258
|
-
return symbols.health_check() === 1;
|
|
259
|
-
}
|
|
260
|
-
bootstrapWorker(config) {
|
|
261
|
-
const symbols = this.ensureLoaded();
|
|
262
|
-
const configBuf = config ? this.toCString(this.toJson(config)) : null;
|
|
263
|
-
const result = symbols.bootstrap_worker(configBuf);
|
|
264
|
-
const jsonStr = this.fromCString(result);
|
|
265
|
-
if (result !== null) symbols.free_rust_string(result);
|
|
266
|
-
const parsed = this.parseJson(jsonStr);
|
|
267
|
-
return parsed ?? {
|
|
268
|
-
success: false,
|
|
269
|
-
status: "error",
|
|
270
|
-
message: "Failed to parse bootstrap result",
|
|
271
|
-
error: "Invalid JSON response"
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
isWorkerRunning() {
|
|
275
|
-
const symbols = this.ensureLoaded();
|
|
276
|
-
return symbols.is_worker_running() === 1;
|
|
277
|
-
}
|
|
278
|
-
getWorkerStatus() {
|
|
279
|
-
const symbols = this.ensureLoaded();
|
|
280
|
-
const result = symbols.get_worker_status();
|
|
281
|
-
const jsonStr = this.fromCString(result);
|
|
282
|
-
if (result !== null) symbols.free_rust_string(result);
|
|
283
|
-
const parsed = this.parseJson(jsonStr);
|
|
284
|
-
return parsed ?? { success: false, running: false };
|
|
285
|
-
}
|
|
286
|
-
stopWorker() {
|
|
287
|
-
const symbols = this.ensureLoaded();
|
|
288
|
-
const result = symbols.stop_worker();
|
|
289
|
-
const jsonStr = this.fromCString(result);
|
|
290
|
-
if (result !== null) symbols.free_rust_string(result);
|
|
291
|
-
const parsed = this.parseJson(jsonStr);
|
|
292
|
-
return parsed ?? {
|
|
293
|
-
success: false,
|
|
294
|
-
status: "error",
|
|
295
|
-
message: "Failed to parse stop result",
|
|
296
|
-
error: "Invalid JSON response"
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
transitionToGracefulShutdown() {
|
|
300
|
-
const symbols = this.ensureLoaded();
|
|
301
|
-
const result = symbols.transition_to_graceful_shutdown();
|
|
302
|
-
const jsonStr = this.fromCString(result);
|
|
303
|
-
if (result !== null) symbols.free_rust_string(result);
|
|
304
|
-
const parsed = this.parseJson(jsonStr);
|
|
305
|
-
return parsed ?? {
|
|
306
|
-
success: false,
|
|
307
|
-
status: "error",
|
|
308
|
-
message: "Failed to parse shutdown result",
|
|
309
|
-
error: "Invalid JSON response"
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
pollStepEvents() {
|
|
313
|
-
const symbols = this.ensureLoaded();
|
|
314
|
-
const result = symbols.poll_step_events();
|
|
315
|
-
if (result === null || Deno.UnsafePointer.equals(result, null)) {
|
|
316
|
-
return null;
|
|
317
|
-
}
|
|
318
|
-
const jsonStr = this.fromCString(result);
|
|
319
|
-
symbols.free_rust_string(result);
|
|
320
|
-
return this.parseJson(jsonStr);
|
|
321
|
-
}
|
|
322
|
-
pollInProcessEvents() {
|
|
323
|
-
const symbols = this.ensureLoaded();
|
|
324
|
-
const result = symbols.poll_in_process_events();
|
|
325
|
-
if (result === null || Deno.UnsafePointer.equals(result, null)) {
|
|
326
|
-
return null;
|
|
327
|
-
}
|
|
328
|
-
const jsonStr = this.fromCString(result);
|
|
329
|
-
symbols.free_rust_string(result);
|
|
330
|
-
return this.parseJson(jsonStr);
|
|
331
|
-
}
|
|
332
|
-
completeStepEvent(eventId, result) {
|
|
333
|
-
const symbols = this.ensureLoaded();
|
|
334
|
-
const eventIdBuf = this.toCString(eventId);
|
|
335
|
-
const resultJsonBuf = this.toCString(this.toJson(result));
|
|
336
|
-
return symbols.complete_step_event(eventIdBuf, resultJsonBuf) === 1;
|
|
337
|
-
}
|
|
338
|
-
checkpointYieldStepEvent(eventId, checkpointData) {
|
|
339
|
-
const symbols = this.ensureLoaded();
|
|
340
|
-
const eventIdBuf = this.toCString(eventId);
|
|
341
|
-
const checkpointJsonBuf = this.toCString(this.toJson(checkpointData));
|
|
342
|
-
return symbols.checkpoint_yield_step_event(eventIdBuf, checkpointJsonBuf) === 1;
|
|
343
|
-
}
|
|
344
|
-
getFfiDispatchMetrics() {
|
|
345
|
-
const symbols = this.ensureLoaded();
|
|
346
|
-
const result = symbols.get_ffi_dispatch_metrics();
|
|
347
|
-
const jsonStr = this.fromCString(result);
|
|
348
|
-
if (result !== null) symbols.free_rust_string(result);
|
|
349
|
-
const parsed = this.parseJson(jsonStr);
|
|
350
|
-
if (parsed && typeof parsed.pending_count === "number") {
|
|
351
|
-
return parsed;
|
|
352
|
-
}
|
|
353
|
-
return {
|
|
354
|
-
pending_count: 0,
|
|
355
|
-
starvation_detected: false,
|
|
356
|
-
starving_event_count: 0,
|
|
357
|
-
oldest_pending_age_ms: null,
|
|
358
|
-
newest_pending_age_ms: null,
|
|
359
|
-
oldest_event_id: null
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
checkStarvationWarnings() {
|
|
363
|
-
const symbols = this.ensureLoaded();
|
|
364
|
-
symbols.check_starvation_warnings();
|
|
365
|
-
}
|
|
366
|
-
cleanupTimeouts() {
|
|
367
|
-
const symbols = this.ensureLoaded();
|
|
368
|
-
symbols.cleanup_timeouts();
|
|
369
|
-
}
|
|
370
|
-
logError(message, fields) {
|
|
371
|
-
const symbols = this.ensureLoaded();
|
|
372
|
-
const msgBuf = this.toCString(message);
|
|
373
|
-
const fieldsBuf = fields ? this.toCString(this.toJson(fields)) : null;
|
|
374
|
-
symbols.log_error(msgBuf, fieldsBuf);
|
|
375
|
-
}
|
|
376
|
-
logWarn(message, fields) {
|
|
377
|
-
const symbols = this.ensureLoaded();
|
|
378
|
-
const msgBuf = this.toCString(message);
|
|
379
|
-
const fieldsBuf = fields ? this.toCString(this.toJson(fields)) : null;
|
|
380
|
-
symbols.log_warn(msgBuf, fieldsBuf);
|
|
381
|
-
}
|
|
382
|
-
logInfo(message, fields) {
|
|
383
|
-
const symbols = this.ensureLoaded();
|
|
384
|
-
const msgBuf = this.toCString(message);
|
|
385
|
-
const fieldsBuf = fields ? this.toCString(this.toJson(fields)) : null;
|
|
386
|
-
symbols.log_info(msgBuf, fieldsBuf);
|
|
387
|
-
}
|
|
388
|
-
logDebug(message, fields) {
|
|
389
|
-
const symbols = this.ensureLoaded();
|
|
390
|
-
const msgBuf = this.toCString(message);
|
|
391
|
-
const fieldsBuf = fields ? this.toCString(this.toJson(fields)) : null;
|
|
392
|
-
symbols.log_debug(msgBuf, fieldsBuf);
|
|
393
|
-
}
|
|
394
|
-
logTrace(message, fields) {
|
|
395
|
-
const symbols = this.ensureLoaded();
|
|
396
|
-
const msgBuf = this.toCString(message);
|
|
397
|
-
const fieldsBuf = fields ? this.toCString(this.toJson(fields)) : null;
|
|
398
|
-
symbols.log_trace(msgBuf, fieldsBuf);
|
|
399
|
-
}
|
|
400
|
-
// ==========================================================================
|
|
401
|
-
// Client API Operations (TAS-231)
|
|
402
|
-
// ==========================================================================
|
|
403
|
-
parseClientResult(result) {
|
|
404
|
-
const jsonStr = this.fromCString(result);
|
|
405
|
-
if (result !== null) this.ensureLoaded().free_rust_string(result);
|
|
406
|
-
const parsed = this.parseJson(jsonStr);
|
|
407
|
-
return parsed ?? {
|
|
408
|
-
success: false,
|
|
409
|
-
data: null,
|
|
410
|
-
error: "Failed to parse client result",
|
|
411
|
-
recoverable: null
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
clientCreateTask(requestJson) {
|
|
415
|
-
const symbols = this.ensureLoaded();
|
|
416
|
-
const buf = this.toCString(requestJson);
|
|
417
|
-
const result = symbols.client_create_task(buf);
|
|
418
|
-
return this.parseClientResult(result);
|
|
419
|
-
}
|
|
420
|
-
clientGetTask(taskUuid) {
|
|
421
|
-
const symbols = this.ensureLoaded();
|
|
422
|
-
const buf = this.toCString(taskUuid);
|
|
423
|
-
const result = symbols.client_get_task(buf);
|
|
424
|
-
return this.parseClientResult(result);
|
|
425
|
-
}
|
|
426
|
-
clientListTasks(paramsJson) {
|
|
427
|
-
const symbols = this.ensureLoaded();
|
|
428
|
-
const buf = this.toCString(paramsJson);
|
|
429
|
-
const result = symbols.client_list_tasks(buf);
|
|
430
|
-
return this.parseClientResult(result);
|
|
431
|
-
}
|
|
432
|
-
clientCancelTask(taskUuid) {
|
|
433
|
-
const symbols = this.ensureLoaded();
|
|
434
|
-
const buf = this.toCString(taskUuid);
|
|
435
|
-
const result = symbols.client_cancel_task(buf);
|
|
436
|
-
return this.parseClientResult(result);
|
|
437
|
-
}
|
|
438
|
-
clientListTaskSteps(taskUuid) {
|
|
439
|
-
const symbols = this.ensureLoaded();
|
|
440
|
-
const buf = this.toCString(taskUuid);
|
|
441
|
-
const result = symbols.client_list_task_steps(buf);
|
|
442
|
-
return this.parseClientResult(result);
|
|
443
|
-
}
|
|
444
|
-
clientGetStep(taskUuid, stepUuid) {
|
|
445
|
-
const symbols = this.ensureLoaded();
|
|
446
|
-
const tBuf = this.toCString(taskUuid);
|
|
447
|
-
const sBuf = this.toCString(stepUuid);
|
|
448
|
-
const result = symbols.client_get_step(tBuf, sBuf);
|
|
449
|
-
return this.parseClientResult(result);
|
|
450
|
-
}
|
|
451
|
-
clientGetStepAuditHistory(taskUuid, stepUuid) {
|
|
452
|
-
const symbols = this.ensureLoaded();
|
|
453
|
-
const tBuf = this.toCString(taskUuid);
|
|
454
|
-
const sBuf = this.toCString(stepUuid);
|
|
455
|
-
const result = symbols.client_get_step_audit_history(tBuf, sBuf);
|
|
456
|
-
return this.parseClientResult(result);
|
|
457
|
-
}
|
|
458
|
-
clientHealthCheck() {
|
|
459
|
-
const symbols = this.ensureLoaded();
|
|
460
|
-
const result = symbols.client_health_check();
|
|
461
|
-
return this.parseClientResult(result);
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
|
|
467
|
-
// node_modules/koffi/build/koffi/darwin_arm64/koffi.node
|
|
468
|
-
var koffi_default;
|
|
469
|
-
var init_koffi = __esm({
|
|
470
|
-
"node_modules/koffi/build/koffi/darwin_arm64/koffi.node"() {
|
|
471
|
-
koffi_default = "../koffi-X7JMBSZH.node";
|
|
472
|
-
}
|
|
473
|
-
});
|
|
474
|
-
|
|
475
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/darwin_arm64/koffi.node
|
|
476
|
-
var require_koffi = __commonJS2({
|
|
477
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/darwin_arm64/koffi.node"(exports2, module2) {
|
|
478
|
-
init_koffi();
|
|
479
|
-
try {
|
|
480
|
-
module2.exports = __require(koffi_default);
|
|
481
|
-
} catch {
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
// node_modules/koffi/build/koffi/darwin_x64/koffi.node
|
|
487
|
-
var koffi_default2;
|
|
488
|
-
var init_koffi2 = __esm({
|
|
489
|
-
"node_modules/koffi/build/koffi/darwin_x64/koffi.node"() {
|
|
490
|
-
koffi_default2 = "../koffi-OMHWL3D6.node";
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/darwin_x64/koffi.node
|
|
495
|
-
var require_koffi2 = __commonJS2({
|
|
496
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/darwin_x64/koffi.node"(exports2, module2) {
|
|
497
|
-
init_koffi2();
|
|
498
|
-
try {
|
|
499
|
-
module2.exports = __require(koffi_default2);
|
|
500
|
-
} catch {
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
|
-
|
|
505
|
-
// node_modules/koffi/build/koffi/freebsd_arm64/koffi.node
|
|
506
|
-
var koffi_default3;
|
|
507
|
-
var init_koffi3 = __esm({
|
|
508
|
-
"node_modules/koffi/build/koffi/freebsd_arm64/koffi.node"() {
|
|
509
|
-
koffi_default3 = "../koffi-AVDVVSXH.node";
|
|
510
|
-
}
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/freebsd_arm64/koffi.node
|
|
514
|
-
var require_koffi3 = __commonJS2({
|
|
515
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/freebsd_arm64/koffi.node"(exports2, module2) {
|
|
516
|
-
init_koffi3();
|
|
517
|
-
try {
|
|
518
|
-
module2.exports = __require(koffi_default3);
|
|
519
|
-
} catch {
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
});
|
|
523
|
-
|
|
524
|
-
// node_modules/koffi/build/koffi/freebsd_ia32/koffi.node
|
|
525
|
-
var koffi_default4;
|
|
526
|
-
var init_koffi4 = __esm({
|
|
527
|
-
"node_modules/koffi/build/koffi/freebsd_ia32/koffi.node"() {
|
|
528
|
-
koffi_default4 = "../koffi-GG4SDSYA.node";
|
|
529
|
-
}
|
|
530
|
-
});
|
|
531
|
-
|
|
532
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/freebsd_ia32/koffi.node
|
|
533
|
-
var require_koffi4 = __commonJS2({
|
|
534
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/freebsd_ia32/koffi.node"(exports2, module2) {
|
|
535
|
-
init_koffi4();
|
|
536
|
-
try {
|
|
537
|
-
module2.exports = __require(koffi_default4);
|
|
538
|
-
} catch {
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
// node_modules/koffi/build/koffi/freebsd_x64/koffi.node
|
|
544
|
-
var koffi_default5;
|
|
545
|
-
var init_koffi5 = __esm({
|
|
546
|
-
"node_modules/koffi/build/koffi/freebsd_x64/koffi.node"() {
|
|
547
|
-
koffi_default5 = "../koffi-AHHUCM3C.node";
|
|
548
|
-
}
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/freebsd_x64/koffi.node
|
|
552
|
-
var require_koffi5 = __commonJS2({
|
|
553
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/freebsd_x64/koffi.node"(exports2, module2) {
|
|
554
|
-
init_koffi5();
|
|
555
|
-
try {
|
|
556
|
-
module2.exports = __require(koffi_default5);
|
|
557
|
-
} catch {
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
});
|
|
561
|
-
|
|
562
|
-
// node_modules/koffi/build/koffi/linux_armhf/koffi.node
|
|
563
|
-
var koffi_default6;
|
|
564
|
-
var init_koffi6 = __esm({
|
|
565
|
-
"node_modules/koffi/build/koffi/linux_armhf/koffi.node"() {
|
|
566
|
-
koffi_default6 = "../koffi-YNQDUF3Q.node";
|
|
567
|
-
}
|
|
568
|
-
});
|
|
569
|
-
|
|
570
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_armhf/koffi.node
|
|
571
|
-
var require_koffi6 = __commonJS2({
|
|
572
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_armhf/koffi.node"(exports2, module2) {
|
|
573
|
-
init_koffi6();
|
|
574
|
-
try {
|
|
575
|
-
module2.exports = __require(koffi_default6);
|
|
576
|
-
} catch {
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
});
|
|
580
|
-
|
|
581
|
-
// node_modules/koffi/build/koffi/linux_arm64/koffi.node
|
|
582
|
-
var koffi_default7;
|
|
583
|
-
var init_koffi7 = __esm({
|
|
584
|
-
"node_modules/koffi/build/koffi/linux_arm64/koffi.node"() {
|
|
585
|
-
koffi_default7 = "../koffi-SE4ZI36U.node";
|
|
586
|
-
}
|
|
587
|
-
});
|
|
588
|
-
|
|
589
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_arm64/koffi.node
|
|
590
|
-
var require_koffi7 = __commonJS2({
|
|
591
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_arm64/koffi.node"(exports2, module2) {
|
|
592
|
-
init_koffi7();
|
|
593
|
-
try {
|
|
594
|
-
module2.exports = __require(koffi_default7);
|
|
595
|
-
} catch {
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
});
|
|
599
|
-
|
|
600
|
-
// node_modules/koffi/build/koffi/linux_ia32/koffi.node
|
|
601
|
-
var koffi_default8;
|
|
602
|
-
var init_koffi8 = __esm({
|
|
603
|
-
"node_modules/koffi/build/koffi/linux_ia32/koffi.node"() {
|
|
604
|
-
koffi_default8 = "../koffi-LOH6WKRQ.node";
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
|
-
|
|
608
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_ia32/koffi.node
|
|
609
|
-
var require_koffi8 = __commonJS2({
|
|
610
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_ia32/koffi.node"(exports2, module2) {
|
|
611
|
-
init_koffi8();
|
|
612
|
-
try {
|
|
613
|
-
module2.exports = __require(koffi_default8);
|
|
614
|
-
} catch {
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
});
|
|
618
|
-
|
|
619
|
-
// node_modules/koffi/build/koffi/linux_loong64/koffi.node
|
|
620
|
-
var koffi_default9;
|
|
621
|
-
var init_koffi9 = __esm({
|
|
622
|
-
"node_modules/koffi/build/koffi/linux_loong64/koffi.node"() {
|
|
623
|
-
koffi_default9 = "../koffi-QKY2KSXW.node";
|
|
624
|
-
}
|
|
625
|
-
});
|
|
626
|
-
|
|
627
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_loong64/koffi.node
|
|
628
|
-
var require_koffi9 = __commonJS2({
|
|
629
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_loong64/koffi.node"(exports2, module2) {
|
|
630
|
-
init_koffi9();
|
|
631
|
-
try {
|
|
632
|
-
module2.exports = __require(koffi_default9);
|
|
633
|
-
} catch {
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
});
|
|
637
|
-
|
|
638
|
-
// node_modules/koffi/build/koffi/linux_riscv64d/koffi.node
|
|
639
|
-
var koffi_default10;
|
|
640
|
-
var init_koffi10 = __esm({
|
|
641
|
-
"node_modules/koffi/build/koffi/linux_riscv64d/koffi.node"() {
|
|
642
|
-
koffi_default10 = "../koffi-X3YT67KE.node";
|
|
643
|
-
}
|
|
644
|
-
});
|
|
645
|
-
|
|
646
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_riscv64d/koffi.node
|
|
647
|
-
var require_koffi10 = __commonJS2({
|
|
648
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_riscv64d/koffi.node"(exports2, module2) {
|
|
649
|
-
init_koffi10();
|
|
650
|
-
try {
|
|
651
|
-
module2.exports = __require(koffi_default10);
|
|
652
|
-
} catch {
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
});
|
|
656
|
-
|
|
657
|
-
// node_modules/koffi/build/koffi/linux_x64/koffi.node
|
|
658
|
-
var koffi_default11;
|
|
659
|
-
var init_koffi11 = __esm({
|
|
660
|
-
"node_modules/koffi/build/koffi/linux_x64/koffi.node"() {
|
|
661
|
-
koffi_default11 = "../koffi-G4D35B2D.node";
|
|
662
|
-
}
|
|
663
|
-
});
|
|
664
|
-
|
|
665
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_x64/koffi.node
|
|
666
|
-
var require_koffi11 = __commonJS2({
|
|
667
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_x64/koffi.node"(exports2, module2) {
|
|
668
|
-
init_koffi11();
|
|
669
|
-
try {
|
|
670
|
-
module2.exports = __require(koffi_default11);
|
|
671
|
-
} catch {
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
});
|
|
675
|
-
|
|
676
|
-
// node_modules/koffi/build/koffi/openbsd_ia32/koffi.node
|
|
677
|
-
var koffi_default12;
|
|
678
|
-
var init_koffi12 = __esm({
|
|
679
|
-
"node_modules/koffi/build/koffi/openbsd_ia32/koffi.node"() {
|
|
680
|
-
koffi_default12 = "../koffi-LUY2JHJP.node";
|
|
681
|
-
}
|
|
682
|
-
});
|
|
683
|
-
|
|
684
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/openbsd_ia32/koffi.node
|
|
685
|
-
var require_koffi12 = __commonJS2({
|
|
686
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/openbsd_ia32/koffi.node"(exports2, module2) {
|
|
687
|
-
init_koffi12();
|
|
688
|
-
try {
|
|
689
|
-
module2.exports = __require(koffi_default12);
|
|
690
|
-
} catch {
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
});
|
|
694
|
-
|
|
695
|
-
// node_modules/koffi/build/koffi/openbsd_x64/koffi.node
|
|
696
|
-
var koffi_default13;
|
|
697
|
-
var init_koffi13 = __esm({
|
|
698
|
-
"node_modules/koffi/build/koffi/openbsd_x64/koffi.node"() {
|
|
699
|
-
koffi_default13 = "../koffi-ROB3FRHA.node";
|
|
700
|
-
}
|
|
701
|
-
});
|
|
702
|
-
|
|
703
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/openbsd_x64/koffi.node
|
|
704
|
-
var require_koffi13 = __commonJS2({
|
|
705
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/openbsd_x64/koffi.node"(exports2, module2) {
|
|
706
|
-
init_koffi13();
|
|
707
|
-
try {
|
|
708
|
-
module2.exports = __require(koffi_default13);
|
|
709
|
-
} catch {
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
});
|
|
713
|
-
|
|
714
|
-
// node_modules/koffi/build/koffi/win32_arm64/koffi.node
|
|
715
|
-
var koffi_default14;
|
|
716
|
-
var init_koffi14 = __esm({
|
|
717
|
-
"node_modules/koffi/build/koffi/win32_arm64/koffi.node"() {
|
|
718
|
-
koffi_default14 = "../koffi-GOENU54R.node";
|
|
719
|
-
}
|
|
720
|
-
});
|
|
721
|
-
|
|
722
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/win32_arm64/koffi.node
|
|
723
|
-
var require_koffi14 = __commonJS2({
|
|
724
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/win32_arm64/koffi.node"(exports2, module2) {
|
|
725
|
-
init_koffi14();
|
|
726
|
-
try {
|
|
727
|
-
module2.exports = __require(koffi_default14);
|
|
728
|
-
} catch {
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
});
|
|
732
|
-
|
|
733
|
-
// node_modules/koffi/build/koffi/win32_ia32/koffi.node
|
|
734
|
-
var koffi_default15;
|
|
735
|
-
var init_koffi15 = __esm({
|
|
736
|
-
"node_modules/koffi/build/koffi/win32_ia32/koffi.node"() {
|
|
737
|
-
koffi_default15 = "../koffi-KFZAXWPQ.node";
|
|
738
|
-
}
|
|
739
|
-
});
|
|
740
|
-
|
|
741
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/win32_ia32/koffi.node
|
|
742
|
-
var require_koffi15 = __commonJS2({
|
|
743
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/win32_ia32/koffi.node"(exports2, module2) {
|
|
744
|
-
init_koffi15();
|
|
745
|
-
try {
|
|
746
|
-
module2.exports = __require(koffi_default15);
|
|
747
|
-
} catch {
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
});
|
|
751
|
-
|
|
752
|
-
// node_modules/koffi/build/koffi/win32_x64/koffi.node
|
|
753
|
-
var koffi_default16;
|
|
754
|
-
var init_koffi16 = __esm({
|
|
755
|
-
"node_modules/koffi/build/koffi/win32_x64/koffi.node"() {
|
|
756
|
-
koffi_default16 = "../koffi-IDX6JEDH.node";
|
|
757
|
-
}
|
|
758
|
-
});
|
|
759
|
-
|
|
760
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/win32_x64/koffi.node
|
|
761
|
-
var require_koffi16 = __commonJS2({
|
|
762
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/win32_x64/koffi.node"(exports2, module2) {
|
|
763
|
-
init_koffi16();
|
|
764
|
-
try {
|
|
765
|
-
module2.exports = __require(koffi_default16);
|
|
766
|
-
} catch {
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
});
|
|
770
|
-
|
|
771
|
-
// node_modules/koffi/build/koffi/musl_arm64/koffi.node
|
|
772
|
-
var koffi_default17;
|
|
773
|
-
var init_koffi17 = __esm({
|
|
774
|
-
"node_modules/koffi/build/koffi/musl_arm64/koffi.node"() {
|
|
775
|
-
koffi_default17 = "../koffi-3HFAASOB.node";
|
|
776
|
-
}
|
|
777
|
-
});
|
|
778
|
-
|
|
779
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/musl_arm64/koffi.node
|
|
780
|
-
var require_koffi17 = __commonJS2({
|
|
781
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/musl_arm64/koffi.node"(exports2, module2) {
|
|
782
|
-
init_koffi17();
|
|
783
|
-
try {
|
|
784
|
-
module2.exports = __require(koffi_default17);
|
|
785
|
-
} catch {
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
});
|
|
789
|
-
|
|
790
|
-
// node_modules/koffi/build/koffi/musl_x64/koffi.node
|
|
791
|
-
var koffi_default18;
|
|
792
|
-
var init_koffi18 = __esm({
|
|
793
|
-
"node_modules/koffi/build/koffi/musl_x64/koffi.node"() {
|
|
794
|
-
koffi_default18 = "../koffi-BMO5K7B3.node";
|
|
795
|
-
}
|
|
796
|
-
});
|
|
797
|
-
|
|
798
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/musl_x64/koffi.node
|
|
799
|
-
var require_koffi18 = __commonJS2({
|
|
800
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/musl_x64/koffi.node"(exports2, module2) {
|
|
801
|
-
init_koffi18();
|
|
802
|
-
try {
|
|
803
|
-
module2.exports = __require(koffi_default18);
|
|
804
|
-
} catch {
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
});
|
|
808
|
-
|
|
809
|
-
// node_modules/koffi/index.js
|
|
810
|
-
var require_koffi19 = __commonJS2({
|
|
811
|
-
"node_modules/koffi/index.js"(exports$1, module) {
|
|
812
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
813
|
-
var __commonJS = (cb, mod3) => function __require2() {
|
|
814
|
-
return mod3 || (0, cb[__getOwnPropNames(cb)[0]])((mod3 = { exports: {} }).exports, mod3), mod3.exports;
|
|
815
|
-
};
|
|
816
|
-
var require_tools = __commonJS({
|
|
817
|
-
"bin/Koffi/package/src/cnoke/src/tools.js"(exports2, module2) {
|
|
818
|
-
var crypto = __require("crypto");
|
|
819
|
-
var fs2 = __require("fs");
|
|
820
|
-
var http = __require("https");
|
|
821
|
-
var path2 = __require("path");
|
|
822
|
-
var zlib = __require("zlib");
|
|
823
|
-
async function download_http(url, dest) {
|
|
824
|
-
console.log(">> Downloading " + url);
|
|
825
|
-
let [tmp_name, file] = open_temporary_stream(dest);
|
|
826
|
-
try {
|
|
827
|
-
await new Promise((resolve, reject) => {
|
|
828
|
-
let request = http.get(url, (response) => {
|
|
829
|
-
if (response.statusCode != 200) {
|
|
830
|
-
let err = new Error(`Download failed: ${response.statusMessage} [${response.statusCode}]`);
|
|
831
|
-
err.code = response.statusCode;
|
|
832
|
-
reject(err);
|
|
833
|
-
return;
|
|
834
|
-
}
|
|
835
|
-
response.pipe(file);
|
|
836
|
-
file.on("finish", () => file.close(() => {
|
|
837
|
-
try {
|
|
838
|
-
fs2.renameSync(file.path, dest);
|
|
839
|
-
} catch (err) {
|
|
840
|
-
if (!fs2.existsSync(dest))
|
|
841
|
-
reject(err);
|
|
842
|
-
}
|
|
843
|
-
resolve();
|
|
844
|
-
}));
|
|
845
|
-
});
|
|
846
|
-
request.on("error", reject);
|
|
847
|
-
file.on("error", reject);
|
|
848
|
-
});
|
|
849
|
-
} catch (err) {
|
|
850
|
-
file.close();
|
|
851
|
-
try {
|
|
852
|
-
fs2.unlinkSync(tmp_name);
|
|
853
|
-
} catch (err2) {
|
|
854
|
-
if (err2.code != "ENOENT")
|
|
855
|
-
throw err2;
|
|
856
|
-
}
|
|
857
|
-
throw err;
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
function open_temporary_stream(prefix) {
|
|
861
|
-
let buf = Buffer.allocUnsafe(4);
|
|
862
|
-
for (; ; ) {
|
|
863
|
-
try {
|
|
864
|
-
crypto.randomFillSync(buf);
|
|
865
|
-
let suffix = buf.toString("hex").padStart(8, "0");
|
|
866
|
-
let filename2 = `${prefix}.${suffix}`;
|
|
867
|
-
let file = fs2.createWriteStream(filename2, { flags: "wx", mode: 420 });
|
|
868
|
-
return [filename2, file];
|
|
869
|
-
} catch (err) {
|
|
870
|
-
if (err.code != "EEXIST")
|
|
871
|
-
throw err;
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
function extract_targz(filename2, dest_dir, strip = 0) {
|
|
876
|
-
let reader = fs2.createReadStream(filename2).pipe(zlib.createGunzip());
|
|
877
|
-
return new Promise((resolve, reject) => {
|
|
878
|
-
let header = null;
|
|
879
|
-
let extended = {};
|
|
880
|
-
reader.on("readable", () => {
|
|
881
|
-
try {
|
|
882
|
-
for (; ; ) {
|
|
883
|
-
if (header == null) {
|
|
884
|
-
let buf = reader.read(512);
|
|
885
|
-
if (buf == null)
|
|
886
|
-
break;
|
|
887
|
-
if (!buf[0])
|
|
888
|
-
continue;
|
|
889
|
-
header = {
|
|
890
|
-
filename: buf.toString("utf-8", 0, 100).replace(/\0/g, ""),
|
|
891
|
-
mode: parseInt(buf.toString("ascii", 100, 109), 8),
|
|
892
|
-
size: parseInt(buf.toString("ascii", 124, 137), 8),
|
|
893
|
-
type: String.fromCharCode(buf[156])
|
|
894
|
-
};
|
|
895
|
-
Object.assign(header, extended);
|
|
896
|
-
extended = {};
|
|
897
|
-
header.filename = header.filename.replace(/\\/g, "/");
|
|
898
|
-
if (!header.filename.length)
|
|
899
|
-
throw new Error(`Insecure empty filename inside TAR archive`);
|
|
900
|
-
if (path_is_absolute(header.filename[0]))
|
|
901
|
-
throw new Error(`Insecure filename starting with / inside TAR archive`);
|
|
902
|
-
if (path_has_dotdot(header.filename))
|
|
903
|
-
throw new Error(`Insecure filename containing '..' inside TAR archive`);
|
|
904
|
-
for (let i = 0; i < strip; i++)
|
|
905
|
-
header.filename = header.filename.substr(header.filename.indexOf("/") + 1);
|
|
906
|
-
}
|
|
907
|
-
let aligned = Math.floor((header.size + 511) / 512) * 512;
|
|
908
|
-
let data = header.size ? reader.read(aligned) : null;
|
|
909
|
-
if (data == null) {
|
|
910
|
-
if (header.size)
|
|
911
|
-
break;
|
|
912
|
-
data = Buffer.alloc(0);
|
|
913
|
-
}
|
|
914
|
-
data = data.subarray(0, header.size);
|
|
915
|
-
if (header.type == "0" || header.type == "7") {
|
|
916
|
-
let filename3 = dest_dir + "/" + header.filename;
|
|
917
|
-
let dirname2 = path2.dirname(filename3);
|
|
918
|
-
fs2.mkdirSync(dirname2, { recursive: true, mode: 493 });
|
|
919
|
-
fs2.writeFileSync(filename3, data, { mode: header.mode });
|
|
920
|
-
} else if (header.type == "5") {
|
|
921
|
-
let filename3 = dest_dir + "/" + header.filename;
|
|
922
|
-
fs2.mkdirSync(filename3, { recursive: true, mode: header.mode });
|
|
923
|
-
} else if (header.type == "L") {
|
|
924
|
-
extended.filename = data.toString("utf-8").replace(/\0/g, "");
|
|
925
|
-
} else if (header.type == "x") {
|
|
926
|
-
let str = data.toString("utf-8");
|
|
927
|
-
try {
|
|
928
|
-
while (str.length) {
|
|
929
|
-
let matches = str.match(/^([0-9]+) ([a-zA-Z0-9\._]+)=(.*)\n/);
|
|
930
|
-
let skip = parseInt(matches[1], 10);
|
|
931
|
-
let key = matches[2];
|
|
932
|
-
let value = matches[3];
|
|
933
|
-
switch (key) {
|
|
934
|
-
case "path":
|
|
935
|
-
{
|
|
936
|
-
extended.filename = value;
|
|
937
|
-
}
|
|
938
|
-
break;
|
|
939
|
-
case "size":
|
|
940
|
-
{
|
|
941
|
-
extended.size = parseInt(value, 10);
|
|
942
|
-
}
|
|
943
|
-
break;
|
|
944
|
-
}
|
|
945
|
-
str = str.substr(skip).trimStart();
|
|
946
|
-
}
|
|
947
|
-
} catch (err) {
|
|
948
|
-
throw new Error("Malformed PAX entry");
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
header = null;
|
|
952
|
-
}
|
|
953
|
-
} catch (err) {
|
|
954
|
-
reject(err);
|
|
955
|
-
}
|
|
956
|
-
});
|
|
957
|
-
reader.on("error", reject);
|
|
958
|
-
reader.on("end", resolve);
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
function path_is_absolute(path3) {
|
|
962
|
-
if (process.platform == "win32" && path3.match(/^[a-zA-Z]:/))
|
|
963
|
-
path3 = path3.substr(2);
|
|
964
|
-
return is_path_separator(path3[0]);
|
|
965
|
-
}
|
|
966
|
-
function path_has_dotdot(path3) {
|
|
967
|
-
let start = 0;
|
|
968
|
-
for (; ; ) {
|
|
969
|
-
let offset = path3.indexOf("..", start);
|
|
970
|
-
if (offset < 0)
|
|
971
|
-
break;
|
|
972
|
-
start = offset + 2;
|
|
973
|
-
if (offset && !is_path_separator(path3[offset - 1]))
|
|
974
|
-
continue;
|
|
975
|
-
if (offset + 2 < path3.length && !is_path_separator(path3[offset + 2]))
|
|
976
|
-
continue;
|
|
977
|
-
return true;
|
|
978
|
-
}
|
|
979
|
-
return false;
|
|
980
|
-
}
|
|
981
|
-
function is_path_separator(c) {
|
|
982
|
-
if (c == "/")
|
|
983
|
-
return true;
|
|
984
|
-
if (process.platform == "win32" && c == "\\")
|
|
985
|
-
return true;
|
|
986
|
-
return false;
|
|
987
|
-
}
|
|
988
|
-
function sync_files(src_dir, dest_dir) {
|
|
989
|
-
let keep = /* @__PURE__ */ new Set();
|
|
990
|
-
{
|
|
991
|
-
let entries = fs2.readdirSync(src_dir, { withFileTypes: true });
|
|
992
|
-
for (let entry of entries) {
|
|
993
|
-
if (!entry.isFile())
|
|
994
|
-
continue;
|
|
995
|
-
keep.add(entry.name);
|
|
996
|
-
fs2.copyFileSync(src_dir + `/${entry.name}`, dest_dir + `/${entry.name}`);
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
{
|
|
1000
|
-
let entries = fs2.readdirSync(dest_dir, { withFileTypes: true });
|
|
1001
|
-
for (let entry of entries) {
|
|
1002
|
-
if (!entry.isFile())
|
|
1003
|
-
continue;
|
|
1004
|
-
if (keep.has(entry.name))
|
|
1005
|
-
continue;
|
|
1006
|
-
fs2.unlinkSync(dest_dir + `/${entry.name}`);
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
function determine_arch2() {
|
|
1011
|
-
let arch = process.arch;
|
|
1012
|
-
if (arch == "riscv32" || arch == "riscv64") {
|
|
1013
|
-
let buf = read_file_header(process.execPath, 512);
|
|
1014
|
-
let header = decode_elf_header(buf);
|
|
1015
|
-
let float_abi = header.e_flags & 6;
|
|
1016
|
-
switch (float_abi) {
|
|
1017
|
-
case 0:
|
|
1018
|
-
break;
|
|
1019
|
-
case 2:
|
|
1020
|
-
{
|
|
1021
|
-
arch += "f";
|
|
1022
|
-
}
|
|
1023
|
-
break;
|
|
1024
|
-
case 4:
|
|
1025
|
-
{
|
|
1026
|
-
arch += "d";
|
|
1027
|
-
}
|
|
1028
|
-
break;
|
|
1029
|
-
case 6:
|
|
1030
|
-
{
|
|
1031
|
-
arch += "q";
|
|
1032
|
-
}
|
|
1033
|
-
break;
|
|
1034
|
-
}
|
|
1035
|
-
} else if (arch == "arm") {
|
|
1036
|
-
let buf = read_file_header(process.execPath, 512);
|
|
1037
|
-
let header = decode_elf_header(buf);
|
|
1038
|
-
if (header.e_flags & 1024) {
|
|
1039
|
-
arch += "hf";
|
|
1040
|
-
} else if (header.e_flags & 512) {
|
|
1041
|
-
arch += "sf";
|
|
1042
|
-
} else {
|
|
1043
|
-
throw new Error("Unknown ARM floating-point ABI");
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
return arch;
|
|
1047
|
-
}
|
|
1048
|
-
function read_file_header(filename2, read) {
|
|
1049
|
-
try {
|
|
1050
|
-
let fd2 = fs2.openSync(filename2);
|
|
1051
|
-
let buf = Buffer.allocUnsafe(read);
|
|
1052
|
-
let len = fs2.readSync(fd2, buf);
|
|
1053
|
-
return buf.subarray(0, len);
|
|
1054
|
-
} finally {
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
function decode_elf_header(buf) {
|
|
1058
|
-
let header = {};
|
|
1059
|
-
if (buf.length < 16)
|
|
1060
|
-
throw new Error("Truncated header");
|
|
1061
|
-
if (buf[0] != 127 || buf[1] != 69 || buf[2] != 76 || buf[3] != 70)
|
|
1062
|
-
throw new Error("Invalid magic number");
|
|
1063
|
-
if (buf[6] != 1)
|
|
1064
|
-
throw new Error("Invalid ELF version");
|
|
1065
|
-
if (buf[5] != 1)
|
|
1066
|
-
throw new Error("Big-endian architectures are not supported");
|
|
1067
|
-
let machine = buf.readUInt16LE(18);
|
|
1068
|
-
switch (machine) {
|
|
1069
|
-
case 3:
|
|
1070
|
-
{
|
|
1071
|
-
header.e_machine = "ia32";
|
|
1072
|
-
}
|
|
1073
|
-
break;
|
|
1074
|
-
case 40:
|
|
1075
|
-
{
|
|
1076
|
-
header.e_machine = "arm";
|
|
1077
|
-
}
|
|
1078
|
-
break;
|
|
1079
|
-
case 62:
|
|
1080
|
-
{
|
|
1081
|
-
header.e_machine = "amd64";
|
|
1082
|
-
}
|
|
1083
|
-
break;
|
|
1084
|
-
case 183:
|
|
1085
|
-
{
|
|
1086
|
-
header.e_machine = "arm64";
|
|
1087
|
-
}
|
|
1088
|
-
break;
|
|
1089
|
-
case 243:
|
|
1090
|
-
{
|
|
1091
|
-
switch (buf[4]) {
|
|
1092
|
-
case 1:
|
|
1093
|
-
{
|
|
1094
|
-
header.e_machine = "riscv32";
|
|
1095
|
-
}
|
|
1096
|
-
break;
|
|
1097
|
-
case 2:
|
|
1098
|
-
{
|
|
1099
|
-
header.e_machine = "riscv64";
|
|
1100
|
-
}
|
|
1101
|
-
break;
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
break;
|
|
1105
|
-
case 248:
|
|
1106
|
-
{
|
|
1107
|
-
switch (buf[4]) {
|
|
1108
|
-
case 1:
|
|
1109
|
-
{
|
|
1110
|
-
header.e_machine = "loong32";
|
|
1111
|
-
}
|
|
1112
|
-
break;
|
|
1113
|
-
case 2:
|
|
1114
|
-
{
|
|
1115
|
-
header.e_machine = "loong64";
|
|
1116
|
-
}
|
|
1117
|
-
break;
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
break;
|
|
1121
|
-
default:
|
|
1122
|
-
throw new Error("Unknown ELF machine type");
|
|
1123
|
-
}
|
|
1124
|
-
switch (buf[4]) {
|
|
1125
|
-
case 1:
|
|
1126
|
-
{
|
|
1127
|
-
buf = buf.subarray(0, 68);
|
|
1128
|
-
if (buf.length < 68)
|
|
1129
|
-
throw new Error("Truncated ELF header");
|
|
1130
|
-
header.ei_class = 32;
|
|
1131
|
-
header.e_flags = buf.readUInt32LE(36);
|
|
1132
|
-
}
|
|
1133
|
-
break;
|
|
1134
|
-
case 2:
|
|
1135
|
-
{
|
|
1136
|
-
buf = buf.subarray(0, 120);
|
|
1137
|
-
if (buf.length < 120)
|
|
1138
|
-
throw new Error("Truncated ELF header");
|
|
1139
|
-
header.ei_class = 64;
|
|
1140
|
-
header.e_flags = buf.readUInt32LE(48);
|
|
1141
|
-
}
|
|
1142
|
-
break;
|
|
1143
|
-
default:
|
|
1144
|
-
throw new Error("Invalid ELF class");
|
|
1145
|
-
}
|
|
1146
|
-
return header;
|
|
1147
|
-
}
|
|
1148
|
-
function unlink_recursive(path3) {
|
|
1149
|
-
try {
|
|
1150
|
-
if (fs2.rmSync != null) {
|
|
1151
|
-
fs2.rmSync(path3, { recursive: true, maxRetries: process.platform == "win32" ? 3 : 0 });
|
|
1152
|
-
} else {
|
|
1153
|
-
fs2.rmdirSync(path3, { recursive: true, maxRetries: process.platform == "win32" ? 3 : 0 });
|
|
1154
|
-
}
|
|
1155
|
-
} catch (err) {
|
|
1156
|
-
if (err.code !== "ENOENT")
|
|
1157
|
-
throw err;
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
function get_napi_version2(napi, major) {
|
|
1161
|
-
if (napi > 8)
|
|
1162
|
-
return null;
|
|
1163
|
-
const support = {
|
|
1164
|
-
6: ["6.14.2", "6.14.2", "6.14.2"],
|
|
1165
|
-
8: ["8.6.0", "8.10.0", "8.11.2"],
|
|
1166
|
-
9: ["9.0.0", "9.3.0", "9.11.0"],
|
|
1167
|
-
10: ["10.0.0", "10.0.0", "10.0.0", "10.16.0", "10.17.0", "10.20.0", "10.23.0"],
|
|
1168
|
-
11: ["11.0.0", "11.0.0", "11.0.0", "11.8.0"],
|
|
1169
|
-
12: ["12.0.0", "12.0.0", "12.0.0", "12.0.0", "12.11.0", "12.17.0", "12.19.0", "12.22.0"],
|
|
1170
|
-
13: ["13.0.0", "13.0.0", "13.0.0", "13.0.0", "13.0.0"],
|
|
1171
|
-
14: ["14.0.0", "14.0.0", "14.0.0", "14.0.0", "14.0.0", "14.0.0", "14.12.0", "14.17.0"],
|
|
1172
|
-
15: ["15.0.0", "15.0.0", "15.0.0", "15.0.0", "15.0.0", "15.0.0", "15.0.0", "15.12.0"]
|
|
1173
|
-
};
|
|
1174
|
-
const max = Math.max(...Object.keys(support).map((k) => parseInt(k, 10)));
|
|
1175
|
-
if (major > max)
|
|
1176
|
-
return major + ".0.0";
|
|
1177
|
-
if (support[major] == null)
|
|
1178
|
-
return null;
|
|
1179
|
-
let required = support[major][napi - 1] || null;
|
|
1180
|
-
return required;
|
|
1181
|
-
}
|
|
1182
|
-
function cmp_version(ver1, ver2) {
|
|
1183
|
-
ver1 = String(ver1).replace(/-.*$/, "").split(".").reduce((acc, v, idx) => acc + parseInt(v, 10) * Math.pow(10, 2 * (5 - idx)), 0);
|
|
1184
|
-
ver2 = String(ver2).replace(/-.*$/, "").split(".").reduce((acc, v, idx) => acc + parseInt(v, 10) * Math.pow(10, 2 * (5 - idx)), 0);
|
|
1185
|
-
let cmp = Math.min(Math.max(ver1 - ver2, -1), 1);
|
|
1186
|
-
return cmp;
|
|
1187
|
-
}
|
|
1188
|
-
module2.exports = {
|
|
1189
|
-
download_http,
|
|
1190
|
-
extract_targz,
|
|
1191
|
-
path_is_absolute,
|
|
1192
|
-
path_has_dotdot,
|
|
1193
|
-
sync_files,
|
|
1194
|
-
determine_arch: determine_arch2,
|
|
1195
|
-
unlink_recursive,
|
|
1196
|
-
get_napi_version: get_napi_version2,
|
|
1197
|
-
cmp_version
|
|
1198
|
-
};
|
|
1199
|
-
}
|
|
1200
|
-
});
|
|
1201
|
-
var require_package = __commonJS({
|
|
1202
|
-
"bin/Koffi/package/src/koffi/package.json"(exports2, module2) {
|
|
1203
|
-
module2.exports = {
|
|
1204
|
-
name: "koffi",
|
|
1205
|
-
version: "2.15.0",
|
|
1206
|
-
description: "Fast and simple C FFI (foreign function interface) for Node.js",
|
|
1207
|
-
keywords: [
|
|
1208
|
-
"foreign",
|
|
1209
|
-
"function",
|
|
1210
|
-
"interface",
|
|
1211
|
-
"ffi",
|
|
1212
|
-
"binding",
|
|
1213
|
-
"c",
|
|
1214
|
-
"napi"
|
|
1215
|
-
],
|
|
1216
|
-
repository: {
|
|
1217
|
-
type: "git",
|
|
1218
|
-
url: "https://github.com/Koromix/koffi"
|
|
1219
|
-
},
|
|
1220
|
-
homepage: "https://koffi.dev/",
|
|
1221
|
-
author: {
|
|
1222
|
-
name: "Niels Martign\xE8ne",
|
|
1223
|
-
email: "niels.martignene@protonmail.com",
|
|
1224
|
-
url: "https://koromix.dev/"
|
|
1225
|
-
},
|
|
1226
|
-
main: "./index.js",
|
|
1227
|
-
types: "./index.d.ts",
|
|
1228
|
-
scripts: {
|
|
1229
|
-
test: "node tools/koffi.js test",
|
|
1230
|
-
prepack: `echo 'Use "npm run package" instead' && false`,
|
|
1231
|
-
prepublishOnly: `echo 'Use "npm run package" instead' && false`,
|
|
1232
|
-
package: "node tools/koffi.js build"
|
|
1233
|
-
},
|
|
1234
|
-
license: "MIT",
|
|
1235
|
-
cnoke: {
|
|
1236
|
-
api: "../../vendor/node-api-headers",
|
|
1237
|
-
output: "../../bin/Koffi/{{ platform }}_{{ arch }}",
|
|
1238
|
-
node: 16,
|
|
1239
|
-
napi: 8,
|
|
1240
|
-
require: "./index.js"
|
|
1241
|
-
},
|
|
1242
|
-
funding: "https://buymeacoffee.com/koromix"
|
|
1243
|
-
};
|
|
1244
|
-
}
|
|
1245
|
-
});
|
|
1246
|
-
var require_init = __commonJS({
|
|
1247
|
-
"bin/Koffi/package/src/koffi/src/init.js"(exports$1, module) {
|
|
1248
|
-
var fs = __require("fs");
|
|
1249
|
-
var path = __require("path");
|
|
1250
|
-
var util = __require("util");
|
|
1251
|
-
var { get_napi_version, determine_arch } = require_tools();
|
|
1252
|
-
var pkg = require_package();
|
|
1253
|
-
function detect() {
|
|
1254
|
-
if (process.versions.napi == null || process.versions.napi < pkg.cnoke.napi) {
|
|
1255
|
-
let major = parseInt(process.versions.node, 10);
|
|
1256
|
-
let required = get_napi_version(pkg.cnoke.napi, major);
|
|
1257
|
-
if (required != null) {
|
|
1258
|
-
throw new Error(`This engine is based on Node ${process.versions.node}, but ${pkg.name} requires Node >= ${required} in the Node ${major}.x branch (N-API >= ${pkg.cnoke.napi})`);
|
|
1259
|
-
} else {
|
|
1260
|
-
throw new Error(`This engine is based on Node ${process.versions.node}, but ${pkg.name} does not support the Node ${major}.x branch (N-API < ${pkg.cnoke.napi})`);
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
let arch = determine_arch();
|
|
1264
|
-
let triplet3 = `${process.platform}_${arch}`;
|
|
1265
|
-
return triplet3;
|
|
1266
|
-
}
|
|
1267
|
-
function init(triplet, native) {
|
|
1268
|
-
if (native == null) {
|
|
1269
|
-
let roots = [path.join(__dirname, "..")];
|
|
1270
|
-
let triplets = [triplet];
|
|
1271
|
-
if (process.resourcesPath != null)
|
|
1272
|
-
roots.push(process.resourcesPath);
|
|
1273
|
-
if (triplet.startsWith("linux_")) {
|
|
1274
|
-
let musl = triplet.replace(/^linux_/, "musl_");
|
|
1275
|
-
triplets.push(musl);
|
|
1276
|
-
}
|
|
1277
|
-
let filenames = roots.flatMap((root) => triplets.flatMap((triplet3) => [
|
|
1278
|
-
`${root}/build/koffi/${triplet3}/koffi.node`,
|
|
1279
|
-
`${root}/koffi/${triplet3}/koffi.node`,
|
|
1280
|
-
`${root}/node_modules/koffi/build/koffi/${triplet3}/koffi.node`,
|
|
1281
|
-
`${root}/../../bin/Koffi/${triplet3}/koffi.node`
|
|
1282
|
-
]));
|
|
1283
|
-
let first_err = null;
|
|
1284
|
-
for (let filename of filenames) {
|
|
1285
|
-
if (!fs.existsSync(filename))
|
|
1286
|
-
continue;
|
|
1287
|
-
try {
|
|
1288
|
-
native = eval("require")(filename);
|
|
1289
|
-
} catch (err) {
|
|
1290
|
-
if (first_err == null)
|
|
1291
|
-
first_err = err;
|
|
1292
|
-
continue;
|
|
1293
|
-
}
|
|
1294
|
-
break;
|
|
1295
|
-
}
|
|
1296
|
-
if (first_err != null)
|
|
1297
|
-
throw first_err;
|
|
1298
|
-
}
|
|
1299
|
-
if (native == null)
|
|
1300
|
-
throw new Error("Cannot find the native Koffi module; did you bundle it correctly?");
|
|
1301
|
-
if (native.version != pkg.version)
|
|
1302
|
-
throw new Error("Mismatched native Koffi modules");
|
|
1303
|
-
let mod = wrap(native);
|
|
1304
|
-
return mod;
|
|
1305
|
-
}
|
|
1306
|
-
function wrap(native3) {
|
|
1307
|
-
let obj = {
|
|
1308
|
-
...native3,
|
|
1309
|
-
// Deprecated functions
|
|
1310
|
-
handle: util.deprecate(native3.opaque, "The koffi.handle() function was deprecated in Koffi 2.1, use koffi.opaque() instead", "KOFFI001"),
|
|
1311
|
-
callback: util.deprecate(native3.proto, "The koffi.callback() function was deprecated in Koffi 2.4, use koffi.proto() instead", "KOFFI002")
|
|
1312
|
-
};
|
|
1313
|
-
obj.load = (...args) => {
|
|
1314
|
-
let lib = native3.load(...args);
|
|
1315
|
-
lib.cdecl = util.deprecate((...args2) => lib.func("__cdecl", ...args2), "The koffi.cdecl() function was deprecated in Koffi 2.7, use koffi.func(...) instead", "KOFFI003");
|
|
1316
|
-
lib.stdcall = util.deprecate((...args2) => lib.func("__stdcall", ...args2), 'The koffi.stdcall() function was deprecated in Koffi 2.7, use koffi.func("__stdcall", ...) instead', "KOFFI004");
|
|
1317
|
-
lib.fastcall = util.deprecate((...args2) => lib.func("__fastcall", ...args2), 'The koffi.fastcall() function was deprecated in Koffi 2.7, use koffi.func("__fastcall", ...) instead', "KOFFI005");
|
|
1318
|
-
lib.thiscall = util.deprecate((...args2) => lib.func("__thiscall", ...args2), 'The koffi.thiscall() function was deprecated in Koffi 2.7, use koffi.func("__thiscall", ...) instead', "KOFFI006");
|
|
1319
|
-
return lib;
|
|
1320
|
-
};
|
|
1321
|
-
return obj;
|
|
1322
|
-
}
|
|
1323
|
-
module.exports = {
|
|
1324
|
-
detect,
|
|
1325
|
-
init
|
|
1326
|
-
};
|
|
1327
|
-
}
|
|
1328
|
-
});
|
|
1329
|
-
var { detect: detect2, init: init2 } = require_init();
|
|
1330
|
-
var triplet2 = detect2();
|
|
1331
|
-
var native2 = null;
|
|
1332
|
-
try {
|
|
1333
|
-
switch (triplet2) {
|
|
1334
|
-
case "darwin_arm64":
|
|
1335
|
-
{
|
|
1336
|
-
native2 = require_koffi();
|
|
1337
|
-
}
|
|
1338
|
-
break;
|
|
1339
|
-
case "darwin_x64":
|
|
1340
|
-
{
|
|
1341
|
-
native2 = require_koffi2();
|
|
1342
|
-
}
|
|
1343
|
-
break;
|
|
1344
|
-
case "freebsd_arm64":
|
|
1345
|
-
{
|
|
1346
|
-
native2 = require_koffi3();
|
|
1347
|
-
}
|
|
1348
|
-
break;
|
|
1349
|
-
case "freebsd_ia32":
|
|
1350
|
-
{
|
|
1351
|
-
native2 = require_koffi4();
|
|
1352
|
-
}
|
|
1353
|
-
break;
|
|
1354
|
-
case "freebsd_x64":
|
|
1355
|
-
{
|
|
1356
|
-
native2 = require_koffi5();
|
|
1357
|
-
}
|
|
1358
|
-
break;
|
|
1359
|
-
case "linux_armhf":
|
|
1360
|
-
{
|
|
1361
|
-
native2 = require_koffi6();
|
|
1362
|
-
}
|
|
1363
|
-
break;
|
|
1364
|
-
case "linux_arm64":
|
|
1365
|
-
{
|
|
1366
|
-
native2 = require_koffi7();
|
|
1367
|
-
}
|
|
1368
|
-
break;
|
|
1369
|
-
case "linux_ia32":
|
|
1370
|
-
{
|
|
1371
|
-
native2 = require_koffi8();
|
|
1372
|
-
}
|
|
1373
|
-
break;
|
|
1374
|
-
case "linux_loong64":
|
|
1375
|
-
{
|
|
1376
|
-
native2 = require_koffi9();
|
|
1377
|
-
}
|
|
1378
|
-
break;
|
|
1379
|
-
case "linux_riscv64d":
|
|
1380
|
-
{
|
|
1381
|
-
native2 = require_koffi10();
|
|
1382
|
-
}
|
|
1383
|
-
break;
|
|
1384
|
-
case "linux_x64":
|
|
1385
|
-
{
|
|
1386
|
-
native2 = require_koffi11();
|
|
1387
|
-
}
|
|
1388
|
-
break;
|
|
1389
|
-
case "openbsd_ia32":
|
|
1390
|
-
{
|
|
1391
|
-
native2 = require_koffi12();
|
|
1392
|
-
}
|
|
1393
|
-
break;
|
|
1394
|
-
case "openbsd_x64":
|
|
1395
|
-
{
|
|
1396
|
-
native2 = require_koffi13();
|
|
1397
|
-
}
|
|
1398
|
-
break;
|
|
1399
|
-
case "win32_arm64":
|
|
1400
|
-
{
|
|
1401
|
-
native2 = require_koffi14();
|
|
1402
|
-
}
|
|
1403
|
-
break;
|
|
1404
|
-
case "win32_ia32":
|
|
1405
|
-
{
|
|
1406
|
-
native2 = require_koffi15();
|
|
1407
|
-
}
|
|
1408
|
-
break;
|
|
1409
|
-
case "win32_x64":
|
|
1410
|
-
{
|
|
1411
|
-
native2 = require_koffi16();
|
|
1412
|
-
}
|
|
1413
|
-
break;
|
|
1414
|
-
}
|
|
1415
|
-
} catch {
|
|
1416
|
-
try {
|
|
1417
|
-
switch (triplet2) {
|
|
1418
|
-
case "linux_arm64":
|
|
1419
|
-
{
|
|
1420
|
-
native2 = require_koffi17();
|
|
1421
|
-
}
|
|
1422
|
-
break;
|
|
1423
|
-
case "linux_x64":
|
|
1424
|
-
{
|
|
1425
|
-
native2 = require_koffi18();
|
|
1426
|
-
}
|
|
1427
|
-
break;
|
|
1428
|
-
}
|
|
1429
|
-
} catch {
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1432
|
-
var mod2 = init2(triplet2, native2);
|
|
1433
|
-
module.exports = mod2;
|
|
1434
|
-
}
|
|
1435
|
-
});
|
|
1436
|
-
|
|
1437
|
-
// src/ffi/node-runtime.ts
|
|
1438
|
-
var node_runtime_exports = {};
|
|
1439
|
-
__export(node_runtime_exports, {
|
|
1440
|
-
NodeRuntime: () => NodeRuntime
|
|
1441
|
-
});
|
|
1442
|
-
var NodeRuntime;
|
|
1443
|
-
var init_node_runtime = __esm({
|
|
1444
|
-
"src/ffi/node-runtime.ts"() {
|
|
1445
|
-
init_runtime_interface();
|
|
1446
|
-
NodeRuntime = class extends BaseTaskerRuntime {
|
|
1447
|
-
name = "node";
|
|
1448
|
-
lib = null;
|
|
1449
|
-
// biome-ignore lint/suspicious/noExplicitAny: koffi module type
|
|
1450
|
-
koffi = null;
|
|
1451
|
-
get isLoaded() {
|
|
1452
|
-
return this.lib !== null;
|
|
1453
|
-
}
|
|
1454
|
-
async load(libraryPath) {
|
|
1455
|
-
if (this.lib !== null) {
|
|
1456
|
-
return;
|
|
1457
|
-
}
|
|
1458
|
-
const koffiModule = await Promise.resolve().then(() => __toESM(require_koffi19()));
|
|
1459
|
-
this.koffi = koffiModule.default ?? koffiModule;
|
|
1460
|
-
const lib = this.koffi.load(libraryPath);
|
|
1461
|
-
this.lib = {
|
|
1462
|
-
get_version: lib.func("void* get_version()"),
|
|
1463
|
-
get_rust_version: lib.func("void* get_rust_version()"),
|
|
1464
|
-
health_check: lib.func("int health_check()"),
|
|
1465
|
-
is_worker_running: lib.func("int is_worker_running()"),
|
|
1466
|
-
bootstrap_worker: lib.func("void* bootstrap_worker(str)"),
|
|
1467
|
-
get_worker_status: lib.func("void* get_worker_status()"),
|
|
1468
|
-
stop_worker: lib.func("void* stop_worker()"),
|
|
1469
|
-
transition_to_graceful_shutdown: lib.func("void* transition_to_graceful_shutdown()"),
|
|
1470
|
-
poll_step_events: lib.func("void* poll_step_events()"),
|
|
1471
|
-
poll_in_process_events: lib.func("void* poll_in_process_events()"),
|
|
1472
|
-
complete_step_event: lib.func("int complete_step_event(str, str)"),
|
|
1473
|
-
checkpoint_yield_step_event: lib.func("int checkpoint_yield_step_event(str, str)"),
|
|
1474
|
-
get_ffi_dispatch_metrics: lib.func("void* get_ffi_dispatch_metrics()"),
|
|
1475
|
-
check_starvation_warnings: lib.func("void check_starvation_warnings()"),
|
|
1476
|
-
cleanup_timeouts: lib.func("void cleanup_timeouts()"),
|
|
1477
|
-
log_error: lib.func("void log_error(str, str)"),
|
|
1478
|
-
log_warn: lib.func("void log_warn(str, str)"),
|
|
1479
|
-
log_info: lib.func("void log_info(str, str)"),
|
|
1480
|
-
log_debug: lib.func("void log_debug(str, str)"),
|
|
1481
|
-
log_trace: lib.func("void log_trace(str, str)"),
|
|
1482
|
-
free_rust_string: lib.func("void free_rust_string(void*)"),
|
|
1483
|
-
// Client API functions (TAS-231)
|
|
1484
|
-
client_create_task: lib.func("void* client_create_task(str)"),
|
|
1485
|
-
client_get_task: lib.func("void* client_get_task(str)"),
|
|
1486
|
-
client_list_tasks: lib.func("void* client_list_tasks(str)"),
|
|
1487
|
-
client_cancel_task: lib.func("void* client_cancel_task(str)"),
|
|
1488
|
-
client_list_task_steps: lib.func("void* client_list_task_steps(str)"),
|
|
1489
|
-
client_get_step: lib.func("void* client_get_step(str, str)"),
|
|
1490
|
-
client_get_step_audit_history: lib.func("void* client_get_step_audit_history(str, str)"),
|
|
1491
|
-
client_health_check: lib.func("void* client_health_check()")
|
|
1492
|
-
};
|
|
1493
|
-
}
|
|
1494
|
-
unload() {
|
|
1495
|
-
this.lib = null;
|
|
1496
|
-
this.koffi = null;
|
|
1497
|
-
}
|
|
1498
|
-
ensureLoaded() {
|
|
1499
|
-
if (!this.lib) {
|
|
1500
|
-
throw new Error("Native library not loaded. Call load() first.");
|
|
1501
|
-
}
|
|
1502
|
-
return this.lib;
|
|
1503
|
-
}
|
|
1504
|
-
/**
|
|
1505
|
-
* Read a C string from a pointer and free the Rust-allocated memory.
|
|
1506
|
-
*
|
|
1507
|
-
* Uses koffi.decode with 'char' type and -1 length for null-terminated strings.
|
|
1508
|
-
*/
|
|
1509
|
-
readAndFreeRustString(ptr) {
|
|
1510
|
-
if (!ptr) return null;
|
|
1511
|
-
const lib = this.ensureLoaded();
|
|
1512
|
-
const str = this.koffi.decode(ptr, "char", -1);
|
|
1513
|
-
lib.free_rust_string(ptr);
|
|
1514
|
-
return str;
|
|
1515
|
-
}
|
|
1516
|
-
getVersion() {
|
|
1517
|
-
const lib = this.ensureLoaded();
|
|
1518
|
-
const ptr = lib.get_version();
|
|
1519
|
-
return this.readAndFreeRustString(ptr) ?? "unknown";
|
|
1520
|
-
}
|
|
1521
|
-
getRustVersion() {
|
|
1522
|
-
const lib = this.ensureLoaded();
|
|
1523
|
-
const ptr = lib.get_rust_version();
|
|
1524
|
-
return this.readAndFreeRustString(ptr) ?? "unknown";
|
|
1525
|
-
}
|
|
1526
|
-
healthCheck() {
|
|
1527
|
-
const lib = this.ensureLoaded();
|
|
1528
|
-
return lib.health_check() === 1;
|
|
1529
|
-
}
|
|
1530
|
-
bootstrapWorker(config) {
|
|
1531
|
-
const lib = this.ensureLoaded();
|
|
1532
|
-
const configJson = config ? this.toJson(config) : null;
|
|
1533
|
-
const ptr = lib.bootstrap_worker(configJson);
|
|
1534
|
-
const jsonStr = this.readAndFreeRustString(ptr);
|
|
1535
|
-
const parsed = this.parseJson(jsonStr);
|
|
1536
|
-
return parsed ?? {
|
|
1537
|
-
success: false,
|
|
1538
|
-
status: "error",
|
|
1539
|
-
message: "Failed to parse bootstrap result",
|
|
1540
|
-
error: "Invalid JSON response"
|
|
1541
|
-
};
|
|
1542
|
-
}
|
|
1543
|
-
isWorkerRunning() {
|
|
1544
|
-
const lib = this.ensureLoaded();
|
|
1545
|
-
return lib.is_worker_running() === 1;
|
|
1546
|
-
}
|
|
1547
|
-
getWorkerStatus() {
|
|
1548
|
-
const lib = this.ensureLoaded();
|
|
1549
|
-
const ptr = lib.get_worker_status();
|
|
1550
|
-
const jsonStr = this.readAndFreeRustString(ptr);
|
|
1551
|
-
const parsed = this.parseJson(jsonStr);
|
|
1552
|
-
return parsed ?? { success: false, running: false };
|
|
1553
|
-
}
|
|
1554
|
-
stopWorker() {
|
|
1555
|
-
const lib = this.ensureLoaded();
|
|
1556
|
-
const ptr = lib.stop_worker();
|
|
1557
|
-
const jsonStr = this.readAndFreeRustString(ptr);
|
|
1558
|
-
const parsed = this.parseJson(jsonStr);
|
|
1559
|
-
return parsed ?? {
|
|
1560
|
-
success: false,
|
|
1561
|
-
status: "error",
|
|
1562
|
-
message: "Failed to parse stop result",
|
|
1563
|
-
error: "Invalid JSON response"
|
|
1564
|
-
};
|
|
1565
|
-
}
|
|
1566
|
-
transitionToGracefulShutdown() {
|
|
1567
|
-
const lib = this.ensureLoaded();
|
|
1568
|
-
const ptr = lib.transition_to_graceful_shutdown();
|
|
1569
|
-
const jsonStr = this.readAndFreeRustString(ptr);
|
|
1570
|
-
const parsed = this.parseJson(jsonStr);
|
|
1571
|
-
return parsed ?? {
|
|
1572
|
-
success: false,
|
|
1573
|
-
status: "error",
|
|
1574
|
-
message: "Failed to parse shutdown result",
|
|
1575
|
-
error: "Invalid JSON response"
|
|
1576
|
-
};
|
|
1577
|
-
}
|
|
1578
|
-
pollStepEvents() {
|
|
1579
|
-
const lib = this.ensureLoaded();
|
|
1580
|
-
const ptr = lib.poll_step_events();
|
|
1581
|
-
if (!ptr) return null;
|
|
1582
|
-
const jsonStr = this.readAndFreeRustString(ptr);
|
|
1583
|
-
return this.parseJson(jsonStr);
|
|
1584
|
-
}
|
|
1585
|
-
pollInProcessEvents() {
|
|
1586
|
-
const lib = this.ensureLoaded();
|
|
1587
|
-
const ptr = lib.poll_in_process_events();
|
|
1588
|
-
if (!ptr) return null;
|
|
1589
|
-
const jsonStr = this.readAndFreeRustString(ptr);
|
|
1590
|
-
return this.parseJson(jsonStr);
|
|
1591
|
-
}
|
|
1592
|
-
completeStepEvent(eventId, result) {
|
|
1593
|
-
const lib = this.ensureLoaded();
|
|
1594
|
-
return lib.complete_step_event(eventId, this.toJson(result)) === 1;
|
|
1595
|
-
}
|
|
1596
|
-
checkpointYieldStepEvent(eventId, checkpointData) {
|
|
1597
|
-
const lib = this.ensureLoaded();
|
|
1598
|
-
return lib.checkpoint_yield_step_event(eventId, this.toJson(checkpointData)) === 1;
|
|
1599
|
-
}
|
|
1600
|
-
getFfiDispatchMetrics() {
|
|
1601
|
-
const lib = this.ensureLoaded();
|
|
1602
|
-
const ptr = lib.get_ffi_dispatch_metrics();
|
|
1603
|
-
const jsonStr = this.readAndFreeRustString(ptr);
|
|
1604
|
-
const parsed = this.parseJson(jsonStr);
|
|
1605
|
-
if (parsed && typeof parsed.pending_count === "number") {
|
|
1606
|
-
return parsed;
|
|
1607
|
-
}
|
|
1608
|
-
return {
|
|
1609
|
-
pending_count: 0,
|
|
1610
|
-
starvation_detected: false,
|
|
1611
|
-
starving_event_count: 0,
|
|
1612
|
-
oldest_pending_age_ms: null,
|
|
1613
|
-
newest_pending_age_ms: null,
|
|
1614
|
-
oldest_event_id: null
|
|
1615
|
-
};
|
|
1616
|
-
}
|
|
1617
|
-
checkStarvationWarnings() {
|
|
1618
|
-
const lib = this.ensureLoaded();
|
|
1619
|
-
lib.check_starvation_warnings();
|
|
1620
|
-
}
|
|
1621
|
-
cleanupTimeouts() {
|
|
1622
|
-
const lib = this.ensureLoaded();
|
|
1623
|
-
lib.cleanup_timeouts();
|
|
1624
|
-
}
|
|
1625
|
-
logError(message, fields) {
|
|
1626
|
-
const lib = this.ensureLoaded();
|
|
1627
|
-
lib.log_error(message, fields ? this.toJson(fields) : null);
|
|
1628
|
-
}
|
|
1629
|
-
logWarn(message, fields) {
|
|
1630
|
-
const lib = this.ensureLoaded();
|
|
1631
|
-
lib.log_warn(message, fields ? this.toJson(fields) : null);
|
|
1632
|
-
}
|
|
1633
|
-
logInfo(message, fields) {
|
|
1634
|
-
const lib = this.ensureLoaded();
|
|
1635
|
-
lib.log_info(message, fields ? this.toJson(fields) : null);
|
|
1636
|
-
}
|
|
1637
|
-
logDebug(message, fields) {
|
|
1638
|
-
const lib = this.ensureLoaded();
|
|
1639
|
-
lib.log_debug(message, fields ? this.toJson(fields) : null);
|
|
1640
|
-
}
|
|
1641
|
-
logTrace(message, fields) {
|
|
1642
|
-
const lib = this.ensureLoaded();
|
|
1643
|
-
lib.log_trace(message, fields ? this.toJson(fields) : null);
|
|
1644
|
-
}
|
|
1645
|
-
// ==========================================================================
|
|
1646
|
-
// Client API Operations (TAS-231)
|
|
1647
|
-
// ==========================================================================
|
|
1648
|
-
parseClientResult(ptr) {
|
|
1649
|
-
const jsonStr = this.readAndFreeRustString(ptr);
|
|
1650
|
-
const parsed = this.parseJson(jsonStr);
|
|
1651
|
-
return parsed ?? {
|
|
1652
|
-
success: false,
|
|
1653
|
-
data: null,
|
|
1654
|
-
error: "Failed to parse client result",
|
|
1655
|
-
recoverable: null
|
|
1656
|
-
};
|
|
1657
|
-
}
|
|
1658
|
-
clientCreateTask(requestJson) {
|
|
1659
|
-
const lib = this.ensureLoaded();
|
|
1660
|
-
const ptr = lib.client_create_task(requestJson);
|
|
1661
|
-
return this.parseClientResult(ptr);
|
|
1662
|
-
}
|
|
1663
|
-
clientGetTask(taskUuid) {
|
|
1664
|
-
const lib = this.ensureLoaded();
|
|
1665
|
-
const ptr = lib.client_get_task(taskUuid);
|
|
1666
|
-
return this.parseClientResult(ptr);
|
|
1667
|
-
}
|
|
1668
|
-
clientListTasks(paramsJson) {
|
|
1669
|
-
const lib = this.ensureLoaded();
|
|
1670
|
-
const ptr = lib.client_list_tasks(paramsJson);
|
|
1671
|
-
return this.parseClientResult(ptr);
|
|
1672
|
-
}
|
|
1673
|
-
clientCancelTask(taskUuid) {
|
|
1674
|
-
const lib = this.ensureLoaded();
|
|
1675
|
-
const ptr = lib.client_cancel_task(taskUuid);
|
|
1676
|
-
return this.parseClientResult(ptr);
|
|
1677
|
-
}
|
|
1678
|
-
clientListTaskSteps(taskUuid) {
|
|
1679
|
-
const lib = this.ensureLoaded();
|
|
1680
|
-
const ptr = lib.client_list_task_steps(taskUuid);
|
|
1681
|
-
return this.parseClientResult(ptr);
|
|
1682
|
-
}
|
|
1683
|
-
clientGetStep(taskUuid, stepUuid) {
|
|
1684
|
-
const lib = this.ensureLoaded();
|
|
1685
|
-
const ptr = lib.client_get_step(taskUuid, stepUuid);
|
|
1686
|
-
return this.parseClientResult(ptr);
|
|
1687
|
-
}
|
|
1688
|
-
clientGetStepAuditHistory(taskUuid, stepUuid) {
|
|
1689
|
-
const lib = this.ensureLoaded();
|
|
1690
|
-
const ptr = lib.client_get_step_audit_history(taskUuid, stepUuid);
|
|
1691
|
-
return this.parseClientResult(ptr);
|
|
1692
|
-
}
|
|
1693
|
-
clientHealthCheck() {
|
|
1694
|
-
const lib = this.ensureLoaded();
|
|
1695
|
-
const ptr = lib.client_health_check();
|
|
1696
|
-
return this.parseClientResult(ptr);
|
|
1697
|
-
}
|
|
1698
|
-
};
|
|
1699
|
-
}
|
|
1700
|
-
});
|
|
1701
|
-
|
|
1702
|
-
// src/ffi/index.ts
|
|
1703
|
-
init_deno_runtime();
|
|
1704
|
-
|
|
1705
|
-
// src/ffi/runtime.ts
|
|
1706
|
-
var cachedRuntimeType = null;
|
|
1707
|
-
function detectRuntime() {
|
|
1708
|
-
if (cachedRuntimeType !== null) {
|
|
1709
|
-
return cachedRuntimeType;
|
|
1710
|
-
}
|
|
1711
|
-
if (typeof globalThis !== "undefined" && "Bun" in globalThis) {
|
|
1712
|
-
cachedRuntimeType = "bun";
|
|
1713
|
-
return "bun";
|
|
1714
|
-
}
|
|
1715
|
-
if (typeof globalThis !== "undefined" && "Deno" in globalThis) {
|
|
1716
|
-
cachedRuntimeType = "deno";
|
|
1717
|
-
return "deno";
|
|
1718
|
-
}
|
|
1719
|
-
if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
|
1720
|
-
cachedRuntimeType = "node";
|
|
1721
|
-
return "node";
|
|
1722
|
-
}
|
|
1723
|
-
cachedRuntimeType = "unknown";
|
|
1724
|
-
return "unknown";
|
|
1725
|
-
}
|
|
1726
|
-
function isBun() {
|
|
1727
|
-
return detectRuntime() === "bun";
|
|
1728
|
-
}
|
|
1729
|
-
function isNode() {
|
|
1730
|
-
return detectRuntime() === "node";
|
|
1731
|
-
}
|
|
1732
|
-
function isDeno() {
|
|
1733
|
-
return detectRuntime() === "deno";
|
|
1734
|
-
}
|
|
1735
|
-
function getRuntimeInfo() {
|
|
1736
|
-
const type = detectRuntime();
|
|
1737
|
-
switch (type) {
|
|
1738
|
-
case "bun": {
|
|
1739
|
-
const Bun = globalThis.Bun;
|
|
1740
|
-
return {
|
|
1741
|
-
type: "bun",
|
|
1742
|
-
version: Bun?.version ?? "unknown",
|
|
1743
|
-
platform: process?.platform ?? "unknown",
|
|
1744
|
-
arch: process?.arch ?? "unknown"
|
|
1745
|
-
};
|
|
1746
|
-
}
|
|
1747
|
-
case "deno": {
|
|
1748
|
-
const Deno2 = globalThis.Deno;
|
|
1749
|
-
return {
|
|
1750
|
-
type: "deno",
|
|
1751
|
-
version: Deno2?.version?.deno ?? "unknown",
|
|
1752
|
-
platform: Deno2?.build?.os ?? "unknown",
|
|
1753
|
-
arch: Deno2?.build?.arch ?? "unknown"
|
|
1754
|
-
};
|
|
1755
|
-
}
|
|
1756
|
-
case "node":
|
|
1757
|
-
return {
|
|
1758
|
-
type: "node",
|
|
1759
|
-
version: process.versions.node,
|
|
1760
|
-
platform: process.platform,
|
|
1761
|
-
arch: process.arch
|
|
1762
|
-
};
|
|
1763
|
-
default:
|
|
1764
|
-
return {
|
|
1765
|
-
type: "unknown",
|
|
1766
|
-
version: "unknown",
|
|
1767
|
-
platform: "unknown",
|
|
1768
|
-
arch: "unknown"
|
|
1769
|
-
};
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
function getLibraryFilename() {
|
|
1773
|
-
const platform = process?.platform ?? "unknown";
|
|
1774
|
-
switch (platform) {
|
|
1775
|
-
case "darwin":
|
|
1776
|
-
return "libtasker_ts.dylib";
|
|
1777
|
-
case "linux":
|
|
1778
|
-
return "libtasker_ts.so";
|
|
1779
|
-
case "win32":
|
|
1780
|
-
return "tasker_ts.dll";
|
|
1781
|
-
default:
|
|
1782
|
-
throw new Error(`Unsupported platform: ${platform}`);
|
|
1783
|
-
}
|
|
1784
|
-
}
|
|
1785
|
-
function getLibraryPath(basePath) {
|
|
1786
|
-
const envPath = process.env.TASKER_FFI_LIBRARY_PATH;
|
|
1787
|
-
if (envPath) {
|
|
1788
|
-
return envPath;
|
|
1789
|
-
}
|
|
1790
|
-
if (basePath) {
|
|
1791
|
-
return `${basePath}/${getLibraryFilename()}`;
|
|
1792
|
-
}
|
|
1793
|
-
throw new Error(
|
|
1794
|
-
"FFI library path not configured. Set TASKER_FFI_LIBRARY_PATH environment variable.\nExample: export TASKER_FFI_LIBRARY_PATH=/path/to/target/debug/libtasker_ts.dylib"
|
|
1795
|
-
);
|
|
1796
|
-
}
|
|
1797
|
-
|
|
1798
|
-
// src/ffi/ffi-layer.ts
|
|
1799
11
|
var FfiLayer = class _FfiLayer {
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
configuredLibraryPath;
|
|
1804
|
-
/**
|
|
1805
|
-
* Create a new FfiLayer.
|
|
1806
|
-
*
|
|
1807
|
-
* @param config - Optional configuration for runtime type and library path
|
|
1808
|
-
*/
|
|
12
|
+
module = null;
|
|
13
|
+
modulePath = null;
|
|
14
|
+
configuredModulePath;
|
|
1809
15
|
constructor(config = {}) {
|
|
1810
|
-
this.
|
|
1811
|
-
this.configuredLibraryPath = config.libraryPath;
|
|
16
|
+
this.configuredModulePath = config.modulePath;
|
|
1812
17
|
}
|
|
1813
18
|
/**
|
|
1814
|
-
* Load the
|
|
1815
|
-
*
|
|
1816
|
-
* Discovers and loads the native library for the current runtime.
|
|
19
|
+
* Load the napi-rs native module.
|
|
1817
20
|
*
|
|
1818
|
-
* @param customPath - Optional override for
|
|
1819
|
-
* @throws Error if
|
|
21
|
+
* @param customPath - Optional override for module path
|
|
22
|
+
* @throws Error if module not found or failed to load
|
|
1820
23
|
*/
|
|
1821
24
|
async load(customPath) {
|
|
1822
|
-
if (this.
|
|
25
|
+
if (this.module) {
|
|
1823
26
|
return;
|
|
1824
27
|
}
|
|
1825
|
-
const
|
|
1826
|
-
if (!
|
|
28
|
+
const path = customPath ?? this.configuredModulePath ?? this.discoverModulePath();
|
|
29
|
+
if (!path) {
|
|
1827
30
|
throw new Error(
|
|
1828
|
-
`
|
|
31
|
+
`napi-rs native module not found. No bundled .node file matches this platform, and TASKER_FFI_MODULE_PATH is not set.
|
|
1829
32
|
Current platform: ${process.platform}-${process.arch}
|
|
1830
|
-
Supported: linux-x64,
|
|
1831
|
-
Override: export
|
|
33
|
+
Supported: linux-x64, darwin-arm64
|
|
34
|
+
Override: export TASKER_FFI_MODULE_PATH=/path/to/tasker_ts.linux-x64-gnu.node`
|
|
1832
35
|
);
|
|
1833
36
|
}
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
this.
|
|
37
|
+
const nativeModule = __require(path);
|
|
38
|
+
this.module = nativeModule;
|
|
39
|
+
this.modulePath = path;
|
|
1837
40
|
}
|
|
1838
41
|
/**
|
|
1839
|
-
* Unload the
|
|
1840
|
-
*
|
|
1841
|
-
* Safe to call even if not loaded.
|
|
42
|
+
* Unload the native module and release resources.
|
|
1842
43
|
*/
|
|
1843
44
|
async unload() {
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
}
|
|
1847
|
-
this.runtime = null;
|
|
1848
|
-
this.libraryPath = null;
|
|
45
|
+
this.module = null;
|
|
46
|
+
this.modulePath = null;
|
|
1849
47
|
}
|
|
1850
48
|
/**
|
|
1851
|
-
* Check if the
|
|
49
|
+
* Check if the native module is loaded.
|
|
1852
50
|
*/
|
|
1853
51
|
isLoaded() {
|
|
1854
|
-
return this.
|
|
52
|
+
return this.module !== null;
|
|
1855
53
|
}
|
|
1856
54
|
/**
|
|
1857
|
-
* Get the loaded
|
|
55
|
+
* Get the loaded napi-rs module.
|
|
1858
56
|
*
|
|
1859
|
-
* @throws Error if
|
|
57
|
+
* @throws Error if module is not loaded
|
|
1860
58
|
*/
|
|
1861
|
-
|
|
1862
|
-
if (!this.
|
|
59
|
+
getModule() {
|
|
60
|
+
if (!this.module) {
|
|
1863
61
|
throw new Error("FFI not loaded. Call load() first.");
|
|
1864
62
|
}
|
|
1865
|
-
return this.
|
|
63
|
+
return this.module;
|
|
1866
64
|
}
|
|
1867
65
|
/**
|
|
1868
|
-
*
|
|
66
|
+
* Backward-compatible alias for getModule().
|
|
67
|
+
*
|
|
68
|
+
* @deprecated Use getModule() instead
|
|
1869
69
|
*/
|
|
1870
|
-
|
|
1871
|
-
return this.
|
|
70
|
+
getRuntime() {
|
|
71
|
+
return this.getModule();
|
|
1872
72
|
}
|
|
1873
73
|
/**
|
|
1874
|
-
* Get the
|
|
74
|
+
* Get the path to the loaded module.
|
|
1875
75
|
*/
|
|
1876
|
-
|
|
1877
|
-
return this.
|
|
76
|
+
getModulePath() {
|
|
77
|
+
return this.modulePath;
|
|
1878
78
|
}
|
|
1879
79
|
/**
|
|
1880
|
-
* Find the
|
|
1881
|
-
*
|
|
1882
|
-
* Static method for finding the library path without creating an instance.
|
|
1883
|
-
* Useful for test utilities and pre-flight checks.
|
|
80
|
+
* Find the napi-rs module path.
|
|
1884
81
|
*
|
|
1885
82
|
* Resolution order:
|
|
1886
|
-
* 1.
|
|
1887
|
-
* 2. Bundled
|
|
1888
|
-
*
|
|
1889
|
-
* @param _callerDir Deprecated parameter, kept for API compatibility
|
|
1890
|
-
* @returns Path to the library if found and exists, null otherwise
|
|
83
|
+
* 1. TASKER_FFI_MODULE_PATH environment variable (explicit override, for unusual setups)
|
|
84
|
+
* 2. Bundled .node file in package directory (standard path — `napi build --platform` places it here)
|
|
1891
85
|
*/
|
|
1892
|
-
static
|
|
1893
|
-
const envPath = process.env.
|
|
86
|
+
static findModulePath() {
|
|
87
|
+
const envPath = process.env.TASKER_FFI_MODULE_PATH;
|
|
1894
88
|
if (envPath) {
|
|
1895
89
|
if (!existsSync(envPath)) {
|
|
1896
|
-
console.warn(`
|
|
90
|
+
console.warn(`TASKER_FFI_MODULE_PATH is set to "${envPath}" but the file does not exist`);
|
|
1897
91
|
return null;
|
|
1898
92
|
}
|
|
1899
93
|
return envPath;
|
|
1900
94
|
}
|
|
1901
|
-
const bundledPath =
|
|
95
|
+
const bundledPath = findBundledNodeModule();
|
|
1902
96
|
if (bundledPath && existsSync(bundledPath)) {
|
|
1903
97
|
return bundledPath;
|
|
1904
98
|
}
|
|
1905
99
|
return null;
|
|
1906
100
|
}
|
|
1907
101
|
/**
|
|
1908
|
-
*
|
|
102
|
+
* Backward-compatible alias for findModulePath().
|
|
1909
103
|
*
|
|
1910
|
-
*
|
|
104
|
+
* @deprecated Use findModulePath() instead
|
|
1911
105
|
*/
|
|
1912
|
-
|
|
1913
|
-
return _FfiLayer.
|
|
106
|
+
static findLibraryPath(_callerDir) {
|
|
107
|
+
return _FfiLayer.findModulePath();
|
|
1914
108
|
}
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
*
|
|
1918
|
-
* NOTE: We use koffi (NodeRuntime) for both Node.js and Bun.
|
|
1919
|
-
* koffi is stable and works with both runtimes via Node-API.
|
|
1920
|
-
* See: https://bun.sh/docs/runtime/node-api
|
|
1921
|
-
*/
|
|
1922
|
-
async createRuntime() {
|
|
1923
|
-
switch (this.runtimeType) {
|
|
1924
|
-
case "bun":
|
|
1925
|
-
case "node": {
|
|
1926
|
-
const { NodeRuntime: NodeRuntime2 } = await Promise.resolve().then(() => (init_node_runtime(), node_runtime_exports));
|
|
1927
|
-
return new NodeRuntime2();
|
|
1928
|
-
}
|
|
1929
|
-
case "deno": {
|
|
1930
|
-
const { DenoRuntime: DenoRuntime2 } = await Promise.resolve().then(() => (init_deno_runtime(), deno_runtime_exports));
|
|
1931
|
-
return new DenoRuntime2();
|
|
1932
|
-
}
|
|
1933
|
-
default:
|
|
1934
|
-
throw new Error(
|
|
1935
|
-
`Unsupported runtime: ${this.runtimeType}. Tasker TypeScript worker requires Bun, Node.js, or Deno.`
|
|
1936
|
-
);
|
|
1937
|
-
}
|
|
109
|
+
discoverModulePath() {
|
|
110
|
+
return _FfiLayer.findModulePath();
|
|
1938
111
|
}
|
|
1939
112
|
};
|
|
1940
|
-
var
|
|
1941
|
-
"linux-x64": "
|
|
1942
|
-
"
|
|
1943
|
-
"darwin-
|
|
113
|
+
var BUNDLED_NODE_MODULES = {
|
|
114
|
+
"linux-x64": "tasker_ts.linux-x64-gnu.node",
|
|
115
|
+
"darwin-arm64": "tasker_ts.darwin-arm64.node",
|
|
116
|
+
"darwin-x64": "tasker_ts.darwin-x64.node"
|
|
1944
117
|
};
|
|
1945
|
-
function
|
|
118
|
+
function findBundledNodeModule() {
|
|
1946
119
|
const key = `${process.platform}-${process.arch}`;
|
|
1947
|
-
const
|
|
1948
|
-
if (!
|
|
120
|
+
const filename = BUNDLED_NODE_MODULES[key];
|
|
121
|
+
if (!filename) {
|
|
1949
122
|
return null;
|
|
1950
123
|
}
|
|
1951
124
|
let dir = dirname(fileURLToPath(import.meta.url));
|
|
1952
125
|
for (let i = 0; i < 5; i++) {
|
|
1953
|
-
const candidate = join(dir,
|
|
126
|
+
const candidate = join(dir, filename);
|
|
1954
127
|
if (existsSync(candidate)) return candidate;
|
|
128
|
+
const nativeCandidate = join(dir, "native", filename);
|
|
129
|
+
if (existsSync(nativeCandidate)) return nativeCandidate;
|
|
1955
130
|
const parent = dirname(dir);
|
|
1956
131
|
if (parent === dir) break;
|
|
1957
132
|
dir = parent;
|
|
@@ -1959,10 +134,6 @@ function findBundledNativeLibrary() {
|
|
|
1959
134
|
return null;
|
|
1960
135
|
}
|
|
1961
136
|
|
|
1962
|
-
|
|
1963
|
-
init_node_runtime();
|
|
1964
|
-
init_runtime_interface();
|
|
1965
|
-
|
|
1966
|
-
export { BaseTaskerRuntime, DenoRuntime, FfiLayer, NodeRuntime, detectRuntime, getLibraryPath, getRuntimeInfo, isBun, isDeno, isNode };
|
|
137
|
+
export { FfiLayer };
|
|
1967
138
|
//# sourceMappingURL=index.js.map
|
|
1968
139
|
//# sourceMappingURL=index.js.map
|