@tasker-systems/tasker 0.1.3 → 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 +47 -86
- 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 -242
- package/dist/ffi/index.js +66 -1896
- 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 +622 -2491
- 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/index.js
CHANGED
|
@@ -5,12 +5,8 @@ import { dirname, join } from 'path';
|
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
import { readdir } from 'fs/promises';
|
|
7
7
|
|
|
8
|
-
var __create = Object.create;
|
|
9
8
|
var __defProp = Object.defineProperty;
|
|
10
|
-
var
|
|
11
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
12
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
10
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
15
11
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
16
12
|
}) : x)(function(x) {
|
|
@@ -18,1689 +14,12 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
18
14
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
19
15
|
});
|
|
20
16
|
var __esm = (fn, res) => function __init() {
|
|
21
|
-
return fn && (res = (0, fn[
|
|
17
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
18
|
+
};
|
|
19
|
+
var __export = (target, all) => {
|
|
20
|
+
for (var name in all)
|
|
21
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
22
22
|
};
|
|
23
|
-
var __commonJS2 = (cb, mod3) => function __require2() {
|
|
24
|
-
return mod3 || (0, cb[__getOwnPropNames2(cb)[0]])((mod3 = { exports: {} }).exports, mod3), mod3.exports;
|
|
25
|
-
};
|
|
26
|
-
var __export = (target, all) => {
|
|
27
|
-
for (var name in all)
|
|
28
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
29
|
-
};
|
|
30
|
-
var __copyProps = (to, from, except, desc) => {
|
|
31
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
32
|
-
for (let key of __getOwnPropNames2(from))
|
|
33
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
34
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
35
|
-
}
|
|
36
|
-
return to;
|
|
37
|
-
};
|
|
38
|
-
var __toESM = (mod3, isNodeMode, target) => (target = mod3 != null ? __create(__getProtoOf(mod3)) : {}, __copyProps(
|
|
39
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
40
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
41
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
42
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
43
|
-
__defProp(target, "default", { value: mod3, enumerable: true }) ,
|
|
44
|
-
mod3
|
|
45
|
-
));
|
|
46
|
-
|
|
47
|
-
// src/ffi/runtime-interface.ts
|
|
48
|
-
var BaseTaskerRuntime;
|
|
49
|
-
var init_runtime_interface = __esm({
|
|
50
|
-
"src/ffi/runtime-interface.ts"() {
|
|
51
|
-
BaseTaskerRuntime = class {
|
|
52
|
-
/**
|
|
53
|
-
* Helper to parse JSON string from FFI
|
|
54
|
-
*/
|
|
55
|
-
parseJson(jsonStr) {
|
|
56
|
-
if (jsonStr === null || jsonStr === "") {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
try {
|
|
60
|
-
return JSON.parse(jsonStr);
|
|
61
|
-
} catch {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Helper to stringify JSON for FFI
|
|
67
|
-
*/
|
|
68
|
-
toJson(value) {
|
|
69
|
-
return JSON.stringify(value);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// node_modules/koffi/build/koffi/darwin_arm64/koffi.node
|
|
76
|
-
var koffi_default;
|
|
77
|
-
var init_koffi = __esm({
|
|
78
|
-
"node_modules/koffi/build/koffi/darwin_arm64/koffi.node"() {
|
|
79
|
-
koffi_default = "./koffi-X7JMBSZH.node";
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/darwin_arm64/koffi.node
|
|
84
|
-
var require_koffi = __commonJS2({
|
|
85
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/darwin_arm64/koffi.node"(exports2, module2) {
|
|
86
|
-
init_koffi();
|
|
87
|
-
try {
|
|
88
|
-
module2.exports = __require(koffi_default);
|
|
89
|
-
} catch {
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
// node_modules/koffi/build/koffi/darwin_x64/koffi.node
|
|
95
|
-
var koffi_default2;
|
|
96
|
-
var init_koffi2 = __esm({
|
|
97
|
-
"node_modules/koffi/build/koffi/darwin_x64/koffi.node"() {
|
|
98
|
-
koffi_default2 = "./koffi-OMHWL3D6.node";
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/darwin_x64/koffi.node
|
|
103
|
-
var require_koffi2 = __commonJS2({
|
|
104
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/darwin_x64/koffi.node"(exports2, module2) {
|
|
105
|
-
init_koffi2();
|
|
106
|
-
try {
|
|
107
|
-
module2.exports = __require(koffi_default2);
|
|
108
|
-
} catch {
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
// node_modules/koffi/build/koffi/freebsd_arm64/koffi.node
|
|
114
|
-
var koffi_default3;
|
|
115
|
-
var init_koffi3 = __esm({
|
|
116
|
-
"node_modules/koffi/build/koffi/freebsd_arm64/koffi.node"() {
|
|
117
|
-
koffi_default3 = "./koffi-AVDVVSXH.node";
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/freebsd_arm64/koffi.node
|
|
122
|
-
var require_koffi3 = __commonJS2({
|
|
123
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/freebsd_arm64/koffi.node"(exports2, module2) {
|
|
124
|
-
init_koffi3();
|
|
125
|
-
try {
|
|
126
|
-
module2.exports = __require(koffi_default3);
|
|
127
|
-
} catch {
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
// node_modules/koffi/build/koffi/freebsd_ia32/koffi.node
|
|
133
|
-
var koffi_default4;
|
|
134
|
-
var init_koffi4 = __esm({
|
|
135
|
-
"node_modules/koffi/build/koffi/freebsd_ia32/koffi.node"() {
|
|
136
|
-
koffi_default4 = "./koffi-GG4SDSYA.node";
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/freebsd_ia32/koffi.node
|
|
141
|
-
var require_koffi4 = __commonJS2({
|
|
142
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/freebsd_ia32/koffi.node"(exports2, module2) {
|
|
143
|
-
init_koffi4();
|
|
144
|
-
try {
|
|
145
|
-
module2.exports = __require(koffi_default4);
|
|
146
|
-
} catch {
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
// node_modules/koffi/build/koffi/freebsd_x64/koffi.node
|
|
152
|
-
var koffi_default5;
|
|
153
|
-
var init_koffi5 = __esm({
|
|
154
|
-
"node_modules/koffi/build/koffi/freebsd_x64/koffi.node"() {
|
|
155
|
-
koffi_default5 = "./koffi-AHHUCM3C.node";
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/freebsd_x64/koffi.node
|
|
160
|
-
var require_koffi5 = __commonJS2({
|
|
161
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/freebsd_x64/koffi.node"(exports2, module2) {
|
|
162
|
-
init_koffi5();
|
|
163
|
-
try {
|
|
164
|
-
module2.exports = __require(koffi_default5);
|
|
165
|
-
} catch {
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
// node_modules/koffi/build/koffi/linux_armhf/koffi.node
|
|
171
|
-
var koffi_default6;
|
|
172
|
-
var init_koffi6 = __esm({
|
|
173
|
-
"node_modules/koffi/build/koffi/linux_armhf/koffi.node"() {
|
|
174
|
-
koffi_default6 = "./koffi-YNQDUF3Q.node";
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_armhf/koffi.node
|
|
179
|
-
var require_koffi6 = __commonJS2({
|
|
180
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_armhf/koffi.node"(exports2, module2) {
|
|
181
|
-
init_koffi6();
|
|
182
|
-
try {
|
|
183
|
-
module2.exports = __require(koffi_default6);
|
|
184
|
-
} catch {
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
// node_modules/koffi/build/koffi/linux_arm64/koffi.node
|
|
190
|
-
var koffi_default7;
|
|
191
|
-
var init_koffi7 = __esm({
|
|
192
|
-
"node_modules/koffi/build/koffi/linux_arm64/koffi.node"() {
|
|
193
|
-
koffi_default7 = "./koffi-SE4ZI36U.node";
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_arm64/koffi.node
|
|
198
|
-
var require_koffi7 = __commonJS2({
|
|
199
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_arm64/koffi.node"(exports2, module2) {
|
|
200
|
-
init_koffi7();
|
|
201
|
-
try {
|
|
202
|
-
module2.exports = __require(koffi_default7);
|
|
203
|
-
} catch {
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
// node_modules/koffi/build/koffi/linux_ia32/koffi.node
|
|
209
|
-
var koffi_default8;
|
|
210
|
-
var init_koffi8 = __esm({
|
|
211
|
-
"node_modules/koffi/build/koffi/linux_ia32/koffi.node"() {
|
|
212
|
-
koffi_default8 = "./koffi-LOH6WKRQ.node";
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_ia32/koffi.node
|
|
217
|
-
var require_koffi8 = __commonJS2({
|
|
218
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_ia32/koffi.node"(exports2, module2) {
|
|
219
|
-
init_koffi8();
|
|
220
|
-
try {
|
|
221
|
-
module2.exports = __require(koffi_default8);
|
|
222
|
-
} catch {
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
// node_modules/koffi/build/koffi/linux_loong64/koffi.node
|
|
228
|
-
var koffi_default9;
|
|
229
|
-
var init_koffi9 = __esm({
|
|
230
|
-
"node_modules/koffi/build/koffi/linux_loong64/koffi.node"() {
|
|
231
|
-
koffi_default9 = "./koffi-QKY2KSXW.node";
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_loong64/koffi.node
|
|
236
|
-
var require_koffi9 = __commonJS2({
|
|
237
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_loong64/koffi.node"(exports2, module2) {
|
|
238
|
-
init_koffi9();
|
|
239
|
-
try {
|
|
240
|
-
module2.exports = __require(koffi_default9);
|
|
241
|
-
} catch {
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
// node_modules/koffi/build/koffi/linux_riscv64d/koffi.node
|
|
247
|
-
var koffi_default10;
|
|
248
|
-
var init_koffi10 = __esm({
|
|
249
|
-
"node_modules/koffi/build/koffi/linux_riscv64d/koffi.node"() {
|
|
250
|
-
koffi_default10 = "./koffi-X3YT67KE.node";
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_riscv64d/koffi.node
|
|
255
|
-
var require_koffi10 = __commonJS2({
|
|
256
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_riscv64d/koffi.node"(exports2, module2) {
|
|
257
|
-
init_koffi10();
|
|
258
|
-
try {
|
|
259
|
-
module2.exports = __require(koffi_default10);
|
|
260
|
-
} catch {
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
// node_modules/koffi/build/koffi/linux_x64/koffi.node
|
|
266
|
-
var koffi_default11;
|
|
267
|
-
var init_koffi11 = __esm({
|
|
268
|
-
"node_modules/koffi/build/koffi/linux_x64/koffi.node"() {
|
|
269
|
-
koffi_default11 = "./koffi-G4D35B2D.node";
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_x64/koffi.node
|
|
274
|
-
var require_koffi11 = __commonJS2({
|
|
275
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/linux_x64/koffi.node"(exports2, module2) {
|
|
276
|
-
init_koffi11();
|
|
277
|
-
try {
|
|
278
|
-
module2.exports = __require(koffi_default11);
|
|
279
|
-
} catch {
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
// node_modules/koffi/build/koffi/openbsd_ia32/koffi.node
|
|
285
|
-
var koffi_default12;
|
|
286
|
-
var init_koffi12 = __esm({
|
|
287
|
-
"node_modules/koffi/build/koffi/openbsd_ia32/koffi.node"() {
|
|
288
|
-
koffi_default12 = "./koffi-LUY2JHJP.node";
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/openbsd_ia32/koffi.node
|
|
293
|
-
var require_koffi12 = __commonJS2({
|
|
294
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/openbsd_ia32/koffi.node"(exports2, module2) {
|
|
295
|
-
init_koffi12();
|
|
296
|
-
try {
|
|
297
|
-
module2.exports = __require(koffi_default12);
|
|
298
|
-
} catch {
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
// node_modules/koffi/build/koffi/openbsd_x64/koffi.node
|
|
304
|
-
var koffi_default13;
|
|
305
|
-
var init_koffi13 = __esm({
|
|
306
|
-
"node_modules/koffi/build/koffi/openbsd_x64/koffi.node"() {
|
|
307
|
-
koffi_default13 = "./koffi-ROB3FRHA.node";
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/openbsd_x64/koffi.node
|
|
312
|
-
var require_koffi13 = __commonJS2({
|
|
313
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/openbsd_x64/koffi.node"(exports2, module2) {
|
|
314
|
-
init_koffi13();
|
|
315
|
-
try {
|
|
316
|
-
module2.exports = __require(koffi_default13);
|
|
317
|
-
} catch {
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
// node_modules/koffi/build/koffi/win32_arm64/koffi.node
|
|
323
|
-
var koffi_default14;
|
|
324
|
-
var init_koffi14 = __esm({
|
|
325
|
-
"node_modules/koffi/build/koffi/win32_arm64/koffi.node"() {
|
|
326
|
-
koffi_default14 = "./koffi-GOENU54R.node";
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/win32_arm64/koffi.node
|
|
331
|
-
var require_koffi14 = __commonJS2({
|
|
332
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/win32_arm64/koffi.node"(exports2, module2) {
|
|
333
|
-
init_koffi14();
|
|
334
|
-
try {
|
|
335
|
-
module2.exports = __require(koffi_default14);
|
|
336
|
-
} catch {
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
// node_modules/koffi/build/koffi/win32_ia32/koffi.node
|
|
342
|
-
var koffi_default15;
|
|
343
|
-
var init_koffi15 = __esm({
|
|
344
|
-
"node_modules/koffi/build/koffi/win32_ia32/koffi.node"() {
|
|
345
|
-
koffi_default15 = "./koffi-KFZAXWPQ.node";
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/win32_ia32/koffi.node
|
|
350
|
-
var require_koffi15 = __commonJS2({
|
|
351
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/win32_ia32/koffi.node"(exports2, module2) {
|
|
352
|
-
init_koffi15();
|
|
353
|
-
try {
|
|
354
|
-
module2.exports = __require(koffi_default15);
|
|
355
|
-
} catch {
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
// node_modules/koffi/build/koffi/win32_x64/koffi.node
|
|
361
|
-
var koffi_default16;
|
|
362
|
-
var init_koffi16 = __esm({
|
|
363
|
-
"node_modules/koffi/build/koffi/win32_x64/koffi.node"() {
|
|
364
|
-
koffi_default16 = "./koffi-IDX6JEDH.node";
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/win32_x64/koffi.node
|
|
369
|
-
var require_koffi16 = __commonJS2({
|
|
370
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/win32_x64/koffi.node"(exports2, module2) {
|
|
371
|
-
init_koffi16();
|
|
372
|
-
try {
|
|
373
|
-
module2.exports = __require(koffi_default16);
|
|
374
|
-
} catch {
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
// node_modules/koffi/build/koffi/musl_arm64/koffi.node
|
|
380
|
-
var koffi_default17;
|
|
381
|
-
var init_koffi17 = __esm({
|
|
382
|
-
"node_modules/koffi/build/koffi/musl_arm64/koffi.node"() {
|
|
383
|
-
koffi_default17 = "./koffi-3HFAASOB.node";
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/musl_arm64/koffi.node
|
|
388
|
-
var require_koffi17 = __commonJS2({
|
|
389
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/musl_arm64/koffi.node"(exports2, module2) {
|
|
390
|
-
init_koffi17();
|
|
391
|
-
try {
|
|
392
|
-
module2.exports = __require(koffi_default17);
|
|
393
|
-
} catch {
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
// node_modules/koffi/build/koffi/musl_x64/koffi.node
|
|
399
|
-
var koffi_default18;
|
|
400
|
-
var init_koffi18 = __esm({
|
|
401
|
-
"node_modules/koffi/build/koffi/musl_x64/koffi.node"() {
|
|
402
|
-
koffi_default18 = "./koffi-BMO5K7B3.node";
|
|
403
|
-
}
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
// node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/musl_x64/koffi.node
|
|
407
|
-
var require_koffi18 = __commonJS2({
|
|
408
|
-
"node-file:/home/runner/work/tasker-core/tasker-core/workers/typescript/node_modules/koffi/build/koffi/musl_x64/koffi.node"(exports2, module2) {
|
|
409
|
-
init_koffi18();
|
|
410
|
-
try {
|
|
411
|
-
module2.exports = __require(koffi_default18);
|
|
412
|
-
} catch {
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
// node_modules/koffi/index.js
|
|
418
|
-
var require_koffi19 = __commonJS2({
|
|
419
|
-
"node_modules/koffi/index.js"(exports$1, module) {
|
|
420
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
421
|
-
var __commonJS = (cb, mod3) => function __require2() {
|
|
422
|
-
return mod3 || (0, cb[__getOwnPropNames(cb)[0]])((mod3 = { exports: {} }).exports, mod3), mod3.exports;
|
|
423
|
-
};
|
|
424
|
-
var require_tools = __commonJS({
|
|
425
|
-
"bin/Koffi/package/src/cnoke/src/tools.js"(exports2, module2) {
|
|
426
|
-
var crypto2 = __require("crypto");
|
|
427
|
-
var fs2 = __require("fs");
|
|
428
|
-
var http = __require("https");
|
|
429
|
-
var path2 = __require("path");
|
|
430
|
-
var zlib = __require("zlib");
|
|
431
|
-
async function download_http(url, dest) {
|
|
432
|
-
console.log(">> Downloading " + url);
|
|
433
|
-
let [tmp_name, file] = open_temporary_stream(dest);
|
|
434
|
-
try {
|
|
435
|
-
await new Promise((resolve, reject) => {
|
|
436
|
-
let request = http.get(url, (response) => {
|
|
437
|
-
if (response.statusCode != 200) {
|
|
438
|
-
let err = new Error(`Download failed: ${response.statusMessage} [${response.statusCode}]`);
|
|
439
|
-
err.code = response.statusCode;
|
|
440
|
-
reject(err);
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
response.pipe(file);
|
|
444
|
-
file.on("finish", () => file.close(() => {
|
|
445
|
-
try {
|
|
446
|
-
fs2.renameSync(file.path, dest);
|
|
447
|
-
} catch (err) {
|
|
448
|
-
if (!fs2.existsSync(dest))
|
|
449
|
-
reject(err);
|
|
450
|
-
}
|
|
451
|
-
resolve();
|
|
452
|
-
}));
|
|
453
|
-
});
|
|
454
|
-
request.on("error", reject);
|
|
455
|
-
file.on("error", reject);
|
|
456
|
-
});
|
|
457
|
-
} catch (err) {
|
|
458
|
-
file.close();
|
|
459
|
-
try {
|
|
460
|
-
fs2.unlinkSync(tmp_name);
|
|
461
|
-
} catch (err2) {
|
|
462
|
-
if (err2.code != "ENOENT")
|
|
463
|
-
throw err2;
|
|
464
|
-
}
|
|
465
|
-
throw err;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
function open_temporary_stream(prefix) {
|
|
469
|
-
let buf = Buffer.allocUnsafe(4);
|
|
470
|
-
for (; ; ) {
|
|
471
|
-
try {
|
|
472
|
-
crypto2.randomFillSync(buf);
|
|
473
|
-
let suffix = buf.toString("hex").padStart(8, "0");
|
|
474
|
-
let filename2 = `${prefix}.${suffix}`;
|
|
475
|
-
let file = fs2.createWriteStream(filename2, { flags: "wx", mode: 420 });
|
|
476
|
-
return [filename2, file];
|
|
477
|
-
} catch (err) {
|
|
478
|
-
if (err.code != "EEXIST")
|
|
479
|
-
throw err;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
function extract_targz(filename2, dest_dir, strip = 0) {
|
|
484
|
-
let reader = fs2.createReadStream(filename2).pipe(zlib.createGunzip());
|
|
485
|
-
return new Promise((resolve, reject) => {
|
|
486
|
-
let header = null;
|
|
487
|
-
let extended = {};
|
|
488
|
-
reader.on("readable", () => {
|
|
489
|
-
try {
|
|
490
|
-
for (; ; ) {
|
|
491
|
-
if (header == null) {
|
|
492
|
-
let buf = reader.read(512);
|
|
493
|
-
if (buf == null)
|
|
494
|
-
break;
|
|
495
|
-
if (!buf[0])
|
|
496
|
-
continue;
|
|
497
|
-
header = {
|
|
498
|
-
filename: buf.toString("utf-8", 0, 100).replace(/\0/g, ""),
|
|
499
|
-
mode: parseInt(buf.toString("ascii", 100, 109), 8),
|
|
500
|
-
size: parseInt(buf.toString("ascii", 124, 137), 8),
|
|
501
|
-
type: String.fromCharCode(buf[156])
|
|
502
|
-
};
|
|
503
|
-
Object.assign(header, extended);
|
|
504
|
-
extended = {};
|
|
505
|
-
header.filename = header.filename.replace(/\\/g, "/");
|
|
506
|
-
if (!header.filename.length)
|
|
507
|
-
throw new Error(`Insecure empty filename inside TAR archive`);
|
|
508
|
-
if (path_is_absolute(header.filename[0]))
|
|
509
|
-
throw new Error(`Insecure filename starting with / inside TAR archive`);
|
|
510
|
-
if (path_has_dotdot(header.filename))
|
|
511
|
-
throw new Error(`Insecure filename containing '..' inside TAR archive`);
|
|
512
|
-
for (let i = 0; i < strip; i++)
|
|
513
|
-
header.filename = header.filename.substr(header.filename.indexOf("/") + 1);
|
|
514
|
-
}
|
|
515
|
-
let aligned = Math.floor((header.size + 511) / 512) * 512;
|
|
516
|
-
let data = header.size ? reader.read(aligned) : null;
|
|
517
|
-
if (data == null) {
|
|
518
|
-
if (header.size)
|
|
519
|
-
break;
|
|
520
|
-
data = Buffer.alloc(0);
|
|
521
|
-
}
|
|
522
|
-
data = data.subarray(0, header.size);
|
|
523
|
-
if (header.type == "0" || header.type == "7") {
|
|
524
|
-
let filename3 = dest_dir + "/" + header.filename;
|
|
525
|
-
let dirname2 = path2.dirname(filename3);
|
|
526
|
-
fs2.mkdirSync(dirname2, { recursive: true, mode: 493 });
|
|
527
|
-
fs2.writeFileSync(filename3, data, { mode: header.mode });
|
|
528
|
-
} else if (header.type == "5") {
|
|
529
|
-
let filename3 = dest_dir + "/" + header.filename;
|
|
530
|
-
fs2.mkdirSync(filename3, { recursive: true, mode: header.mode });
|
|
531
|
-
} else if (header.type == "L") {
|
|
532
|
-
extended.filename = data.toString("utf-8").replace(/\0/g, "");
|
|
533
|
-
} else if (header.type == "x") {
|
|
534
|
-
let str = data.toString("utf-8");
|
|
535
|
-
try {
|
|
536
|
-
while (str.length) {
|
|
537
|
-
let matches = str.match(/^([0-9]+) ([a-zA-Z0-9\._]+)=(.*)\n/);
|
|
538
|
-
let skip = parseInt(matches[1], 10);
|
|
539
|
-
let key = matches[2];
|
|
540
|
-
let value = matches[3];
|
|
541
|
-
switch (key) {
|
|
542
|
-
case "path":
|
|
543
|
-
{
|
|
544
|
-
extended.filename = value;
|
|
545
|
-
}
|
|
546
|
-
break;
|
|
547
|
-
case "size":
|
|
548
|
-
{
|
|
549
|
-
extended.size = parseInt(value, 10);
|
|
550
|
-
}
|
|
551
|
-
break;
|
|
552
|
-
}
|
|
553
|
-
str = str.substr(skip).trimStart();
|
|
554
|
-
}
|
|
555
|
-
} catch (err) {
|
|
556
|
-
throw new Error("Malformed PAX entry");
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
header = null;
|
|
560
|
-
}
|
|
561
|
-
} catch (err) {
|
|
562
|
-
reject(err);
|
|
563
|
-
}
|
|
564
|
-
});
|
|
565
|
-
reader.on("error", reject);
|
|
566
|
-
reader.on("end", resolve);
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
function path_is_absolute(path3) {
|
|
570
|
-
if (process.platform == "win32" && path3.match(/^[a-zA-Z]:/))
|
|
571
|
-
path3 = path3.substr(2);
|
|
572
|
-
return is_path_separator(path3[0]);
|
|
573
|
-
}
|
|
574
|
-
function path_has_dotdot(path3) {
|
|
575
|
-
let start = 0;
|
|
576
|
-
for (; ; ) {
|
|
577
|
-
let offset = path3.indexOf("..", start);
|
|
578
|
-
if (offset < 0)
|
|
579
|
-
break;
|
|
580
|
-
start = offset + 2;
|
|
581
|
-
if (offset && !is_path_separator(path3[offset - 1]))
|
|
582
|
-
continue;
|
|
583
|
-
if (offset + 2 < path3.length && !is_path_separator(path3[offset + 2]))
|
|
584
|
-
continue;
|
|
585
|
-
return true;
|
|
586
|
-
}
|
|
587
|
-
return false;
|
|
588
|
-
}
|
|
589
|
-
function is_path_separator(c) {
|
|
590
|
-
if (c == "/")
|
|
591
|
-
return true;
|
|
592
|
-
if (process.platform == "win32" && c == "\\")
|
|
593
|
-
return true;
|
|
594
|
-
return false;
|
|
595
|
-
}
|
|
596
|
-
function sync_files(src_dir, dest_dir) {
|
|
597
|
-
let keep = /* @__PURE__ */ new Set();
|
|
598
|
-
{
|
|
599
|
-
let entries = fs2.readdirSync(src_dir, { withFileTypes: true });
|
|
600
|
-
for (let entry of entries) {
|
|
601
|
-
if (!entry.isFile())
|
|
602
|
-
continue;
|
|
603
|
-
keep.add(entry.name);
|
|
604
|
-
fs2.copyFileSync(src_dir + `/${entry.name}`, dest_dir + `/${entry.name}`);
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
{
|
|
608
|
-
let entries = fs2.readdirSync(dest_dir, { withFileTypes: true });
|
|
609
|
-
for (let entry of entries) {
|
|
610
|
-
if (!entry.isFile())
|
|
611
|
-
continue;
|
|
612
|
-
if (keep.has(entry.name))
|
|
613
|
-
continue;
|
|
614
|
-
fs2.unlinkSync(dest_dir + `/${entry.name}`);
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
function determine_arch2() {
|
|
619
|
-
let arch = process.arch;
|
|
620
|
-
if (arch == "riscv32" || arch == "riscv64") {
|
|
621
|
-
let buf = read_file_header(process.execPath, 512);
|
|
622
|
-
let header = decode_elf_header(buf);
|
|
623
|
-
let float_abi = header.e_flags & 6;
|
|
624
|
-
switch (float_abi) {
|
|
625
|
-
case 0:
|
|
626
|
-
break;
|
|
627
|
-
case 2:
|
|
628
|
-
{
|
|
629
|
-
arch += "f";
|
|
630
|
-
}
|
|
631
|
-
break;
|
|
632
|
-
case 4:
|
|
633
|
-
{
|
|
634
|
-
arch += "d";
|
|
635
|
-
}
|
|
636
|
-
break;
|
|
637
|
-
case 6:
|
|
638
|
-
{
|
|
639
|
-
arch += "q";
|
|
640
|
-
}
|
|
641
|
-
break;
|
|
642
|
-
}
|
|
643
|
-
} else if (arch == "arm") {
|
|
644
|
-
let buf = read_file_header(process.execPath, 512);
|
|
645
|
-
let header = decode_elf_header(buf);
|
|
646
|
-
if (header.e_flags & 1024) {
|
|
647
|
-
arch += "hf";
|
|
648
|
-
} else if (header.e_flags & 512) {
|
|
649
|
-
arch += "sf";
|
|
650
|
-
} else {
|
|
651
|
-
throw new Error("Unknown ARM floating-point ABI");
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
return arch;
|
|
655
|
-
}
|
|
656
|
-
function read_file_header(filename2, read) {
|
|
657
|
-
try {
|
|
658
|
-
let fd2 = fs2.openSync(filename2);
|
|
659
|
-
let buf = Buffer.allocUnsafe(read);
|
|
660
|
-
let len = fs2.readSync(fd2, buf);
|
|
661
|
-
return buf.subarray(0, len);
|
|
662
|
-
} finally {
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
function decode_elf_header(buf) {
|
|
666
|
-
let header = {};
|
|
667
|
-
if (buf.length < 16)
|
|
668
|
-
throw new Error("Truncated header");
|
|
669
|
-
if (buf[0] != 127 || buf[1] != 69 || buf[2] != 76 || buf[3] != 70)
|
|
670
|
-
throw new Error("Invalid magic number");
|
|
671
|
-
if (buf[6] != 1)
|
|
672
|
-
throw new Error("Invalid ELF version");
|
|
673
|
-
if (buf[5] != 1)
|
|
674
|
-
throw new Error("Big-endian architectures are not supported");
|
|
675
|
-
let machine = buf.readUInt16LE(18);
|
|
676
|
-
switch (machine) {
|
|
677
|
-
case 3:
|
|
678
|
-
{
|
|
679
|
-
header.e_machine = "ia32";
|
|
680
|
-
}
|
|
681
|
-
break;
|
|
682
|
-
case 40:
|
|
683
|
-
{
|
|
684
|
-
header.e_machine = "arm";
|
|
685
|
-
}
|
|
686
|
-
break;
|
|
687
|
-
case 62:
|
|
688
|
-
{
|
|
689
|
-
header.e_machine = "amd64";
|
|
690
|
-
}
|
|
691
|
-
break;
|
|
692
|
-
case 183:
|
|
693
|
-
{
|
|
694
|
-
header.e_machine = "arm64";
|
|
695
|
-
}
|
|
696
|
-
break;
|
|
697
|
-
case 243:
|
|
698
|
-
{
|
|
699
|
-
switch (buf[4]) {
|
|
700
|
-
case 1:
|
|
701
|
-
{
|
|
702
|
-
header.e_machine = "riscv32";
|
|
703
|
-
}
|
|
704
|
-
break;
|
|
705
|
-
case 2:
|
|
706
|
-
{
|
|
707
|
-
header.e_machine = "riscv64";
|
|
708
|
-
}
|
|
709
|
-
break;
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
break;
|
|
713
|
-
case 248:
|
|
714
|
-
{
|
|
715
|
-
switch (buf[4]) {
|
|
716
|
-
case 1:
|
|
717
|
-
{
|
|
718
|
-
header.e_machine = "loong32";
|
|
719
|
-
}
|
|
720
|
-
break;
|
|
721
|
-
case 2:
|
|
722
|
-
{
|
|
723
|
-
header.e_machine = "loong64";
|
|
724
|
-
}
|
|
725
|
-
break;
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
break;
|
|
729
|
-
default:
|
|
730
|
-
throw new Error("Unknown ELF machine type");
|
|
731
|
-
}
|
|
732
|
-
switch (buf[4]) {
|
|
733
|
-
case 1:
|
|
734
|
-
{
|
|
735
|
-
buf = buf.subarray(0, 68);
|
|
736
|
-
if (buf.length < 68)
|
|
737
|
-
throw new Error("Truncated ELF header");
|
|
738
|
-
header.ei_class = 32;
|
|
739
|
-
header.e_flags = buf.readUInt32LE(36);
|
|
740
|
-
}
|
|
741
|
-
break;
|
|
742
|
-
case 2:
|
|
743
|
-
{
|
|
744
|
-
buf = buf.subarray(0, 120);
|
|
745
|
-
if (buf.length < 120)
|
|
746
|
-
throw new Error("Truncated ELF header");
|
|
747
|
-
header.ei_class = 64;
|
|
748
|
-
header.e_flags = buf.readUInt32LE(48);
|
|
749
|
-
}
|
|
750
|
-
break;
|
|
751
|
-
default:
|
|
752
|
-
throw new Error("Invalid ELF class");
|
|
753
|
-
}
|
|
754
|
-
return header;
|
|
755
|
-
}
|
|
756
|
-
function unlink_recursive(path3) {
|
|
757
|
-
try {
|
|
758
|
-
if (fs2.rmSync != null) {
|
|
759
|
-
fs2.rmSync(path3, { recursive: true, maxRetries: process.platform == "win32" ? 3 : 0 });
|
|
760
|
-
} else {
|
|
761
|
-
fs2.rmdirSync(path3, { recursive: true, maxRetries: process.platform == "win32" ? 3 : 0 });
|
|
762
|
-
}
|
|
763
|
-
} catch (err) {
|
|
764
|
-
if (err.code !== "ENOENT")
|
|
765
|
-
throw err;
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
function get_napi_version2(napi, major) {
|
|
769
|
-
if (napi > 8)
|
|
770
|
-
return null;
|
|
771
|
-
const support = {
|
|
772
|
-
6: ["6.14.2", "6.14.2", "6.14.2"],
|
|
773
|
-
8: ["8.6.0", "8.10.0", "8.11.2"],
|
|
774
|
-
9: ["9.0.0", "9.3.0", "9.11.0"],
|
|
775
|
-
10: ["10.0.0", "10.0.0", "10.0.0", "10.16.0", "10.17.0", "10.20.0", "10.23.0"],
|
|
776
|
-
11: ["11.0.0", "11.0.0", "11.0.0", "11.8.0"],
|
|
777
|
-
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"],
|
|
778
|
-
13: ["13.0.0", "13.0.0", "13.0.0", "13.0.0", "13.0.0"],
|
|
779
|
-
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"],
|
|
780
|
-
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"]
|
|
781
|
-
};
|
|
782
|
-
const max = Math.max(...Object.keys(support).map((k) => parseInt(k, 10)));
|
|
783
|
-
if (major > max)
|
|
784
|
-
return major + ".0.0";
|
|
785
|
-
if (support[major] == null)
|
|
786
|
-
return null;
|
|
787
|
-
let required = support[major][napi - 1] || null;
|
|
788
|
-
return required;
|
|
789
|
-
}
|
|
790
|
-
function cmp_version(ver1, ver2) {
|
|
791
|
-
ver1 = String(ver1).replace(/-.*$/, "").split(".").reduce((acc, v, idx) => acc + parseInt(v, 10) * Math.pow(10, 2 * (5 - idx)), 0);
|
|
792
|
-
ver2 = String(ver2).replace(/-.*$/, "").split(".").reduce((acc, v, idx) => acc + parseInt(v, 10) * Math.pow(10, 2 * (5 - idx)), 0);
|
|
793
|
-
let cmp = Math.min(Math.max(ver1 - ver2, -1), 1);
|
|
794
|
-
return cmp;
|
|
795
|
-
}
|
|
796
|
-
module2.exports = {
|
|
797
|
-
download_http,
|
|
798
|
-
extract_targz,
|
|
799
|
-
path_is_absolute,
|
|
800
|
-
path_has_dotdot,
|
|
801
|
-
sync_files,
|
|
802
|
-
determine_arch: determine_arch2,
|
|
803
|
-
unlink_recursive,
|
|
804
|
-
get_napi_version: get_napi_version2,
|
|
805
|
-
cmp_version
|
|
806
|
-
};
|
|
807
|
-
}
|
|
808
|
-
});
|
|
809
|
-
var require_package = __commonJS({
|
|
810
|
-
"bin/Koffi/package/src/koffi/package.json"(exports2, module2) {
|
|
811
|
-
module2.exports = {
|
|
812
|
-
name: "koffi",
|
|
813
|
-
version: "2.15.0",
|
|
814
|
-
description: "Fast and simple C FFI (foreign function interface) for Node.js",
|
|
815
|
-
keywords: [
|
|
816
|
-
"foreign",
|
|
817
|
-
"function",
|
|
818
|
-
"interface",
|
|
819
|
-
"ffi",
|
|
820
|
-
"binding",
|
|
821
|
-
"c",
|
|
822
|
-
"napi"
|
|
823
|
-
],
|
|
824
|
-
repository: {
|
|
825
|
-
type: "git",
|
|
826
|
-
url: "https://github.com/Koromix/koffi"
|
|
827
|
-
},
|
|
828
|
-
homepage: "https://koffi.dev/",
|
|
829
|
-
author: {
|
|
830
|
-
name: "Niels Martign\xE8ne",
|
|
831
|
-
email: "niels.martignene@protonmail.com",
|
|
832
|
-
url: "https://koromix.dev/"
|
|
833
|
-
},
|
|
834
|
-
main: "./index.js",
|
|
835
|
-
types: "./index.d.ts",
|
|
836
|
-
scripts: {
|
|
837
|
-
test: "node tools/koffi.js test",
|
|
838
|
-
prepack: `echo 'Use "npm run package" instead' && false`,
|
|
839
|
-
prepublishOnly: `echo 'Use "npm run package" instead' && false`,
|
|
840
|
-
package: "node tools/koffi.js build"
|
|
841
|
-
},
|
|
842
|
-
license: "MIT",
|
|
843
|
-
cnoke: {
|
|
844
|
-
api: "../../vendor/node-api-headers",
|
|
845
|
-
output: "../../bin/Koffi/{{ platform }}_{{ arch }}",
|
|
846
|
-
node: 16,
|
|
847
|
-
napi: 8,
|
|
848
|
-
require: "./index.js"
|
|
849
|
-
},
|
|
850
|
-
funding: "https://buymeacoffee.com/koromix"
|
|
851
|
-
};
|
|
852
|
-
}
|
|
853
|
-
});
|
|
854
|
-
var require_init = __commonJS({
|
|
855
|
-
"bin/Koffi/package/src/koffi/src/init.js"(exports$1, module) {
|
|
856
|
-
var fs = __require("fs");
|
|
857
|
-
var path = __require("path");
|
|
858
|
-
var util = __require("util");
|
|
859
|
-
var { get_napi_version, determine_arch } = require_tools();
|
|
860
|
-
var pkg = require_package();
|
|
861
|
-
function detect() {
|
|
862
|
-
if (process.versions.napi == null || process.versions.napi < pkg.cnoke.napi) {
|
|
863
|
-
let major = parseInt(process.versions.node, 10);
|
|
864
|
-
let required = get_napi_version(pkg.cnoke.napi, major);
|
|
865
|
-
if (required != null) {
|
|
866
|
-
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})`);
|
|
867
|
-
} else {
|
|
868
|
-
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})`);
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
let arch = determine_arch();
|
|
872
|
-
let triplet3 = `${process.platform}_${arch}`;
|
|
873
|
-
return triplet3;
|
|
874
|
-
}
|
|
875
|
-
function init(triplet, native) {
|
|
876
|
-
if (native == null) {
|
|
877
|
-
let roots = [path.join(__dirname, "..")];
|
|
878
|
-
let triplets = [triplet];
|
|
879
|
-
if (process.resourcesPath != null)
|
|
880
|
-
roots.push(process.resourcesPath);
|
|
881
|
-
if (triplet.startsWith("linux_")) {
|
|
882
|
-
let musl = triplet.replace(/^linux_/, "musl_");
|
|
883
|
-
triplets.push(musl);
|
|
884
|
-
}
|
|
885
|
-
let filenames = roots.flatMap((root) => triplets.flatMap((triplet3) => [
|
|
886
|
-
`${root}/build/koffi/${triplet3}/koffi.node`,
|
|
887
|
-
`${root}/koffi/${triplet3}/koffi.node`,
|
|
888
|
-
`${root}/node_modules/koffi/build/koffi/${triplet3}/koffi.node`,
|
|
889
|
-
`${root}/../../bin/Koffi/${triplet3}/koffi.node`
|
|
890
|
-
]));
|
|
891
|
-
let first_err = null;
|
|
892
|
-
for (let filename of filenames) {
|
|
893
|
-
if (!fs.existsSync(filename))
|
|
894
|
-
continue;
|
|
895
|
-
try {
|
|
896
|
-
native = eval("require")(filename);
|
|
897
|
-
} catch (err) {
|
|
898
|
-
if (first_err == null)
|
|
899
|
-
first_err = err;
|
|
900
|
-
continue;
|
|
901
|
-
}
|
|
902
|
-
break;
|
|
903
|
-
}
|
|
904
|
-
if (first_err != null)
|
|
905
|
-
throw first_err;
|
|
906
|
-
}
|
|
907
|
-
if (native == null)
|
|
908
|
-
throw new Error("Cannot find the native Koffi module; did you bundle it correctly?");
|
|
909
|
-
if (native.version != pkg.version)
|
|
910
|
-
throw new Error("Mismatched native Koffi modules");
|
|
911
|
-
let mod = wrap(native);
|
|
912
|
-
return mod;
|
|
913
|
-
}
|
|
914
|
-
function wrap(native3) {
|
|
915
|
-
let obj = {
|
|
916
|
-
...native3,
|
|
917
|
-
// Deprecated functions
|
|
918
|
-
handle: util.deprecate(native3.opaque, "The koffi.handle() function was deprecated in Koffi 2.1, use koffi.opaque() instead", "KOFFI001"),
|
|
919
|
-
callback: util.deprecate(native3.proto, "The koffi.callback() function was deprecated in Koffi 2.4, use koffi.proto() instead", "KOFFI002")
|
|
920
|
-
};
|
|
921
|
-
obj.load = (...args) => {
|
|
922
|
-
let lib = native3.load(...args);
|
|
923
|
-
lib.cdecl = util.deprecate((...args2) => lib.func("__cdecl", ...args2), "The koffi.cdecl() function was deprecated in Koffi 2.7, use koffi.func(...) instead", "KOFFI003");
|
|
924
|
-
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");
|
|
925
|
-
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");
|
|
926
|
-
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");
|
|
927
|
-
return lib;
|
|
928
|
-
};
|
|
929
|
-
return obj;
|
|
930
|
-
}
|
|
931
|
-
module.exports = {
|
|
932
|
-
detect,
|
|
933
|
-
init
|
|
934
|
-
};
|
|
935
|
-
}
|
|
936
|
-
});
|
|
937
|
-
var { detect: detect2, init: init2 } = require_init();
|
|
938
|
-
var triplet2 = detect2();
|
|
939
|
-
var native2 = null;
|
|
940
|
-
try {
|
|
941
|
-
switch (triplet2) {
|
|
942
|
-
case "darwin_arm64":
|
|
943
|
-
{
|
|
944
|
-
native2 = require_koffi();
|
|
945
|
-
}
|
|
946
|
-
break;
|
|
947
|
-
case "darwin_x64":
|
|
948
|
-
{
|
|
949
|
-
native2 = require_koffi2();
|
|
950
|
-
}
|
|
951
|
-
break;
|
|
952
|
-
case "freebsd_arm64":
|
|
953
|
-
{
|
|
954
|
-
native2 = require_koffi3();
|
|
955
|
-
}
|
|
956
|
-
break;
|
|
957
|
-
case "freebsd_ia32":
|
|
958
|
-
{
|
|
959
|
-
native2 = require_koffi4();
|
|
960
|
-
}
|
|
961
|
-
break;
|
|
962
|
-
case "freebsd_x64":
|
|
963
|
-
{
|
|
964
|
-
native2 = require_koffi5();
|
|
965
|
-
}
|
|
966
|
-
break;
|
|
967
|
-
case "linux_armhf":
|
|
968
|
-
{
|
|
969
|
-
native2 = require_koffi6();
|
|
970
|
-
}
|
|
971
|
-
break;
|
|
972
|
-
case "linux_arm64":
|
|
973
|
-
{
|
|
974
|
-
native2 = require_koffi7();
|
|
975
|
-
}
|
|
976
|
-
break;
|
|
977
|
-
case "linux_ia32":
|
|
978
|
-
{
|
|
979
|
-
native2 = require_koffi8();
|
|
980
|
-
}
|
|
981
|
-
break;
|
|
982
|
-
case "linux_loong64":
|
|
983
|
-
{
|
|
984
|
-
native2 = require_koffi9();
|
|
985
|
-
}
|
|
986
|
-
break;
|
|
987
|
-
case "linux_riscv64d":
|
|
988
|
-
{
|
|
989
|
-
native2 = require_koffi10();
|
|
990
|
-
}
|
|
991
|
-
break;
|
|
992
|
-
case "linux_x64":
|
|
993
|
-
{
|
|
994
|
-
native2 = require_koffi11();
|
|
995
|
-
}
|
|
996
|
-
break;
|
|
997
|
-
case "openbsd_ia32":
|
|
998
|
-
{
|
|
999
|
-
native2 = require_koffi12();
|
|
1000
|
-
}
|
|
1001
|
-
break;
|
|
1002
|
-
case "openbsd_x64":
|
|
1003
|
-
{
|
|
1004
|
-
native2 = require_koffi13();
|
|
1005
|
-
}
|
|
1006
|
-
break;
|
|
1007
|
-
case "win32_arm64":
|
|
1008
|
-
{
|
|
1009
|
-
native2 = require_koffi14();
|
|
1010
|
-
}
|
|
1011
|
-
break;
|
|
1012
|
-
case "win32_ia32":
|
|
1013
|
-
{
|
|
1014
|
-
native2 = require_koffi15();
|
|
1015
|
-
}
|
|
1016
|
-
break;
|
|
1017
|
-
case "win32_x64":
|
|
1018
|
-
{
|
|
1019
|
-
native2 = require_koffi16();
|
|
1020
|
-
}
|
|
1021
|
-
break;
|
|
1022
|
-
}
|
|
1023
|
-
} catch {
|
|
1024
|
-
try {
|
|
1025
|
-
switch (triplet2) {
|
|
1026
|
-
case "linux_arm64":
|
|
1027
|
-
{
|
|
1028
|
-
native2 = require_koffi17();
|
|
1029
|
-
}
|
|
1030
|
-
break;
|
|
1031
|
-
case "linux_x64":
|
|
1032
|
-
{
|
|
1033
|
-
native2 = require_koffi18();
|
|
1034
|
-
}
|
|
1035
|
-
break;
|
|
1036
|
-
}
|
|
1037
|
-
} catch {
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
var mod2 = init2(triplet2, native2);
|
|
1041
|
-
module.exports = mod2;
|
|
1042
|
-
}
|
|
1043
|
-
});
|
|
1044
|
-
|
|
1045
|
-
// src/ffi/node-runtime.ts
|
|
1046
|
-
var node_runtime_exports = {};
|
|
1047
|
-
__export(node_runtime_exports, {
|
|
1048
|
-
NodeRuntime: () => NodeRuntime
|
|
1049
|
-
});
|
|
1050
|
-
var NodeRuntime;
|
|
1051
|
-
var init_node_runtime = __esm({
|
|
1052
|
-
"src/ffi/node-runtime.ts"() {
|
|
1053
|
-
init_runtime_interface();
|
|
1054
|
-
NodeRuntime = class extends BaseTaskerRuntime {
|
|
1055
|
-
name = "node";
|
|
1056
|
-
lib = null;
|
|
1057
|
-
// biome-ignore lint/suspicious/noExplicitAny: koffi module type
|
|
1058
|
-
koffi = null;
|
|
1059
|
-
get isLoaded() {
|
|
1060
|
-
return this.lib !== null;
|
|
1061
|
-
}
|
|
1062
|
-
async load(libraryPath) {
|
|
1063
|
-
if (this.lib !== null) {
|
|
1064
|
-
return;
|
|
1065
|
-
}
|
|
1066
|
-
const koffiModule = await Promise.resolve().then(() => __toESM(require_koffi19()));
|
|
1067
|
-
this.koffi = koffiModule.default ?? koffiModule;
|
|
1068
|
-
const lib = this.koffi.load(libraryPath);
|
|
1069
|
-
this.lib = {
|
|
1070
|
-
get_version: lib.func("void* get_version()"),
|
|
1071
|
-
get_rust_version: lib.func("void* get_rust_version()"),
|
|
1072
|
-
health_check: lib.func("int health_check()"),
|
|
1073
|
-
is_worker_running: lib.func("int is_worker_running()"),
|
|
1074
|
-
bootstrap_worker: lib.func("void* bootstrap_worker(str)"),
|
|
1075
|
-
get_worker_status: lib.func("void* get_worker_status()"),
|
|
1076
|
-
stop_worker: lib.func("void* stop_worker()"),
|
|
1077
|
-
transition_to_graceful_shutdown: lib.func("void* transition_to_graceful_shutdown()"),
|
|
1078
|
-
poll_step_events: lib.func("void* poll_step_events()"),
|
|
1079
|
-
poll_in_process_events: lib.func("void* poll_in_process_events()"),
|
|
1080
|
-
complete_step_event: lib.func("int complete_step_event(str, str)"),
|
|
1081
|
-
checkpoint_yield_step_event: lib.func("int checkpoint_yield_step_event(str, str)"),
|
|
1082
|
-
get_ffi_dispatch_metrics: lib.func("void* get_ffi_dispatch_metrics()"),
|
|
1083
|
-
check_starvation_warnings: lib.func("void check_starvation_warnings()"),
|
|
1084
|
-
cleanup_timeouts: lib.func("void cleanup_timeouts()"),
|
|
1085
|
-
log_error: lib.func("void log_error(str, str)"),
|
|
1086
|
-
log_warn: lib.func("void log_warn(str, str)"),
|
|
1087
|
-
log_info: lib.func("void log_info(str, str)"),
|
|
1088
|
-
log_debug: lib.func("void log_debug(str, str)"),
|
|
1089
|
-
log_trace: lib.func("void log_trace(str, str)"),
|
|
1090
|
-
free_rust_string: lib.func("void free_rust_string(void*)"),
|
|
1091
|
-
// Client API functions (TAS-231)
|
|
1092
|
-
client_create_task: lib.func("void* client_create_task(str)"),
|
|
1093
|
-
client_get_task: lib.func("void* client_get_task(str)"),
|
|
1094
|
-
client_list_tasks: lib.func("void* client_list_tasks(str)"),
|
|
1095
|
-
client_cancel_task: lib.func("void* client_cancel_task(str)"),
|
|
1096
|
-
client_list_task_steps: lib.func("void* client_list_task_steps(str)"),
|
|
1097
|
-
client_get_step: lib.func("void* client_get_step(str, str)"),
|
|
1098
|
-
client_get_step_audit_history: lib.func("void* client_get_step_audit_history(str, str)"),
|
|
1099
|
-
client_health_check: lib.func("void* client_health_check()")
|
|
1100
|
-
};
|
|
1101
|
-
}
|
|
1102
|
-
unload() {
|
|
1103
|
-
this.lib = null;
|
|
1104
|
-
this.koffi = null;
|
|
1105
|
-
}
|
|
1106
|
-
ensureLoaded() {
|
|
1107
|
-
if (!this.lib) {
|
|
1108
|
-
throw new Error("Native library not loaded. Call load() first.");
|
|
1109
|
-
}
|
|
1110
|
-
return this.lib;
|
|
1111
|
-
}
|
|
1112
|
-
/**
|
|
1113
|
-
* Read a C string from a pointer and free the Rust-allocated memory.
|
|
1114
|
-
*
|
|
1115
|
-
* Uses koffi.decode with 'char' type and -1 length for null-terminated strings.
|
|
1116
|
-
*/
|
|
1117
|
-
readAndFreeRustString(ptr) {
|
|
1118
|
-
if (!ptr) return null;
|
|
1119
|
-
const lib = this.ensureLoaded();
|
|
1120
|
-
const str = this.koffi.decode(ptr, "char", -1);
|
|
1121
|
-
lib.free_rust_string(ptr);
|
|
1122
|
-
return str;
|
|
1123
|
-
}
|
|
1124
|
-
getVersion() {
|
|
1125
|
-
const lib = this.ensureLoaded();
|
|
1126
|
-
const ptr = lib.get_version();
|
|
1127
|
-
return this.readAndFreeRustString(ptr) ?? "unknown";
|
|
1128
|
-
}
|
|
1129
|
-
getRustVersion() {
|
|
1130
|
-
const lib = this.ensureLoaded();
|
|
1131
|
-
const ptr = lib.get_rust_version();
|
|
1132
|
-
return this.readAndFreeRustString(ptr) ?? "unknown";
|
|
1133
|
-
}
|
|
1134
|
-
healthCheck() {
|
|
1135
|
-
const lib = this.ensureLoaded();
|
|
1136
|
-
return lib.health_check() === 1;
|
|
1137
|
-
}
|
|
1138
|
-
bootstrapWorker(config) {
|
|
1139
|
-
const lib = this.ensureLoaded();
|
|
1140
|
-
const configJson = config ? this.toJson(config) : null;
|
|
1141
|
-
const ptr = lib.bootstrap_worker(configJson);
|
|
1142
|
-
const jsonStr = this.readAndFreeRustString(ptr);
|
|
1143
|
-
const parsed = this.parseJson(jsonStr);
|
|
1144
|
-
return parsed ?? {
|
|
1145
|
-
success: false,
|
|
1146
|
-
status: "error",
|
|
1147
|
-
message: "Failed to parse bootstrap result",
|
|
1148
|
-
error: "Invalid JSON response"
|
|
1149
|
-
};
|
|
1150
|
-
}
|
|
1151
|
-
isWorkerRunning() {
|
|
1152
|
-
const lib = this.ensureLoaded();
|
|
1153
|
-
return lib.is_worker_running() === 1;
|
|
1154
|
-
}
|
|
1155
|
-
getWorkerStatus() {
|
|
1156
|
-
const lib = this.ensureLoaded();
|
|
1157
|
-
const ptr = lib.get_worker_status();
|
|
1158
|
-
const jsonStr = this.readAndFreeRustString(ptr);
|
|
1159
|
-
const parsed = this.parseJson(jsonStr);
|
|
1160
|
-
return parsed ?? { success: false, running: false };
|
|
1161
|
-
}
|
|
1162
|
-
stopWorker() {
|
|
1163
|
-
const lib = this.ensureLoaded();
|
|
1164
|
-
const ptr = lib.stop_worker();
|
|
1165
|
-
const jsonStr = this.readAndFreeRustString(ptr);
|
|
1166
|
-
const parsed = this.parseJson(jsonStr);
|
|
1167
|
-
return parsed ?? {
|
|
1168
|
-
success: false,
|
|
1169
|
-
status: "error",
|
|
1170
|
-
message: "Failed to parse stop result",
|
|
1171
|
-
error: "Invalid JSON response"
|
|
1172
|
-
};
|
|
1173
|
-
}
|
|
1174
|
-
transitionToGracefulShutdown() {
|
|
1175
|
-
const lib = this.ensureLoaded();
|
|
1176
|
-
const ptr = lib.transition_to_graceful_shutdown();
|
|
1177
|
-
const jsonStr = this.readAndFreeRustString(ptr);
|
|
1178
|
-
const parsed = this.parseJson(jsonStr);
|
|
1179
|
-
return parsed ?? {
|
|
1180
|
-
success: false,
|
|
1181
|
-
status: "error",
|
|
1182
|
-
message: "Failed to parse shutdown result",
|
|
1183
|
-
error: "Invalid JSON response"
|
|
1184
|
-
};
|
|
1185
|
-
}
|
|
1186
|
-
pollStepEvents() {
|
|
1187
|
-
const lib = this.ensureLoaded();
|
|
1188
|
-
const ptr = lib.poll_step_events();
|
|
1189
|
-
if (!ptr) return null;
|
|
1190
|
-
const jsonStr = this.readAndFreeRustString(ptr);
|
|
1191
|
-
return this.parseJson(jsonStr);
|
|
1192
|
-
}
|
|
1193
|
-
pollInProcessEvents() {
|
|
1194
|
-
const lib = this.ensureLoaded();
|
|
1195
|
-
const ptr = lib.poll_in_process_events();
|
|
1196
|
-
if (!ptr) return null;
|
|
1197
|
-
const jsonStr = this.readAndFreeRustString(ptr);
|
|
1198
|
-
return this.parseJson(jsonStr);
|
|
1199
|
-
}
|
|
1200
|
-
completeStepEvent(eventId, result) {
|
|
1201
|
-
const lib = this.ensureLoaded();
|
|
1202
|
-
return lib.complete_step_event(eventId, this.toJson(result)) === 1;
|
|
1203
|
-
}
|
|
1204
|
-
checkpointYieldStepEvent(eventId, checkpointData) {
|
|
1205
|
-
const lib = this.ensureLoaded();
|
|
1206
|
-
return lib.checkpoint_yield_step_event(eventId, this.toJson(checkpointData)) === 1;
|
|
1207
|
-
}
|
|
1208
|
-
getFfiDispatchMetrics() {
|
|
1209
|
-
const lib = this.ensureLoaded();
|
|
1210
|
-
const ptr = lib.get_ffi_dispatch_metrics();
|
|
1211
|
-
const jsonStr = this.readAndFreeRustString(ptr);
|
|
1212
|
-
const parsed = this.parseJson(jsonStr);
|
|
1213
|
-
if (parsed && typeof parsed.pending_count === "number") {
|
|
1214
|
-
return parsed;
|
|
1215
|
-
}
|
|
1216
|
-
return {
|
|
1217
|
-
pending_count: 0,
|
|
1218
|
-
starvation_detected: false,
|
|
1219
|
-
starving_event_count: 0,
|
|
1220
|
-
oldest_pending_age_ms: null,
|
|
1221
|
-
newest_pending_age_ms: null,
|
|
1222
|
-
oldest_event_id: null
|
|
1223
|
-
};
|
|
1224
|
-
}
|
|
1225
|
-
checkStarvationWarnings() {
|
|
1226
|
-
const lib = this.ensureLoaded();
|
|
1227
|
-
lib.check_starvation_warnings();
|
|
1228
|
-
}
|
|
1229
|
-
cleanupTimeouts() {
|
|
1230
|
-
const lib = this.ensureLoaded();
|
|
1231
|
-
lib.cleanup_timeouts();
|
|
1232
|
-
}
|
|
1233
|
-
logError(message, fields) {
|
|
1234
|
-
const lib = this.ensureLoaded();
|
|
1235
|
-
lib.log_error(message, fields ? this.toJson(fields) : null);
|
|
1236
|
-
}
|
|
1237
|
-
logWarn(message, fields) {
|
|
1238
|
-
const lib = this.ensureLoaded();
|
|
1239
|
-
lib.log_warn(message, fields ? this.toJson(fields) : null);
|
|
1240
|
-
}
|
|
1241
|
-
logInfo(message, fields) {
|
|
1242
|
-
const lib = this.ensureLoaded();
|
|
1243
|
-
lib.log_info(message, fields ? this.toJson(fields) : null);
|
|
1244
|
-
}
|
|
1245
|
-
logDebug(message, fields) {
|
|
1246
|
-
const lib = this.ensureLoaded();
|
|
1247
|
-
lib.log_debug(message, fields ? this.toJson(fields) : null);
|
|
1248
|
-
}
|
|
1249
|
-
logTrace(message, fields) {
|
|
1250
|
-
const lib = this.ensureLoaded();
|
|
1251
|
-
lib.log_trace(message, fields ? this.toJson(fields) : null);
|
|
1252
|
-
}
|
|
1253
|
-
// ==========================================================================
|
|
1254
|
-
// Client API Operations (TAS-231)
|
|
1255
|
-
// ==========================================================================
|
|
1256
|
-
parseClientResult(ptr) {
|
|
1257
|
-
const jsonStr = this.readAndFreeRustString(ptr);
|
|
1258
|
-
const parsed = this.parseJson(jsonStr);
|
|
1259
|
-
return parsed ?? {
|
|
1260
|
-
success: false,
|
|
1261
|
-
data: null,
|
|
1262
|
-
error: "Failed to parse client result",
|
|
1263
|
-
recoverable: null
|
|
1264
|
-
};
|
|
1265
|
-
}
|
|
1266
|
-
clientCreateTask(requestJson) {
|
|
1267
|
-
const lib = this.ensureLoaded();
|
|
1268
|
-
const ptr = lib.client_create_task(requestJson);
|
|
1269
|
-
return this.parseClientResult(ptr);
|
|
1270
|
-
}
|
|
1271
|
-
clientGetTask(taskUuid) {
|
|
1272
|
-
const lib = this.ensureLoaded();
|
|
1273
|
-
const ptr = lib.client_get_task(taskUuid);
|
|
1274
|
-
return this.parseClientResult(ptr);
|
|
1275
|
-
}
|
|
1276
|
-
clientListTasks(paramsJson) {
|
|
1277
|
-
const lib = this.ensureLoaded();
|
|
1278
|
-
const ptr = lib.client_list_tasks(paramsJson);
|
|
1279
|
-
return this.parseClientResult(ptr);
|
|
1280
|
-
}
|
|
1281
|
-
clientCancelTask(taskUuid) {
|
|
1282
|
-
const lib = this.ensureLoaded();
|
|
1283
|
-
const ptr = lib.client_cancel_task(taskUuid);
|
|
1284
|
-
return this.parseClientResult(ptr);
|
|
1285
|
-
}
|
|
1286
|
-
clientListTaskSteps(taskUuid) {
|
|
1287
|
-
const lib = this.ensureLoaded();
|
|
1288
|
-
const ptr = lib.client_list_task_steps(taskUuid);
|
|
1289
|
-
return this.parseClientResult(ptr);
|
|
1290
|
-
}
|
|
1291
|
-
clientGetStep(taskUuid, stepUuid) {
|
|
1292
|
-
const lib = this.ensureLoaded();
|
|
1293
|
-
const ptr = lib.client_get_step(taskUuid, stepUuid);
|
|
1294
|
-
return this.parseClientResult(ptr);
|
|
1295
|
-
}
|
|
1296
|
-
clientGetStepAuditHistory(taskUuid, stepUuid) {
|
|
1297
|
-
const lib = this.ensureLoaded();
|
|
1298
|
-
const ptr = lib.client_get_step_audit_history(taskUuid, stepUuid);
|
|
1299
|
-
return this.parseClientResult(ptr);
|
|
1300
|
-
}
|
|
1301
|
-
clientHealthCheck() {
|
|
1302
|
-
const lib = this.ensureLoaded();
|
|
1303
|
-
const ptr = lib.client_health_check();
|
|
1304
|
-
return this.parseClientResult(ptr);
|
|
1305
|
-
}
|
|
1306
|
-
};
|
|
1307
|
-
}
|
|
1308
|
-
});
|
|
1309
|
-
|
|
1310
|
-
// src/ffi/deno-runtime.ts
|
|
1311
|
-
var deno_runtime_exports = {};
|
|
1312
|
-
__export(deno_runtime_exports, {
|
|
1313
|
-
DenoRuntime: () => DenoRuntime
|
|
1314
|
-
});
|
|
1315
|
-
var DenoRuntime;
|
|
1316
|
-
var init_deno_runtime = __esm({
|
|
1317
|
-
"src/ffi/deno-runtime.ts"() {
|
|
1318
|
-
init_runtime_interface();
|
|
1319
|
-
DenoRuntime = class extends BaseTaskerRuntime {
|
|
1320
|
-
name = "deno";
|
|
1321
|
-
lib = null;
|
|
1322
|
-
encoder = new TextEncoder();
|
|
1323
|
-
get isLoaded() {
|
|
1324
|
-
return this.lib !== null;
|
|
1325
|
-
}
|
|
1326
|
-
async load(libraryPath) {
|
|
1327
|
-
if (this.lib !== null) {
|
|
1328
|
-
return;
|
|
1329
|
-
}
|
|
1330
|
-
if (typeof Deno === "undefined") {
|
|
1331
|
-
throw new Error("Deno runtime not detected");
|
|
1332
|
-
}
|
|
1333
|
-
this.lib = Deno.dlopen(libraryPath, {
|
|
1334
|
-
get_version: {
|
|
1335
|
-
parameters: [],
|
|
1336
|
-
result: "pointer"
|
|
1337
|
-
},
|
|
1338
|
-
get_rust_version: {
|
|
1339
|
-
parameters: [],
|
|
1340
|
-
result: "pointer"
|
|
1341
|
-
},
|
|
1342
|
-
health_check: {
|
|
1343
|
-
parameters: [],
|
|
1344
|
-
result: "i32"
|
|
1345
|
-
},
|
|
1346
|
-
is_worker_running: {
|
|
1347
|
-
parameters: [],
|
|
1348
|
-
result: "i32"
|
|
1349
|
-
},
|
|
1350
|
-
bootstrap_worker: {
|
|
1351
|
-
parameters: ["buffer"],
|
|
1352
|
-
result: "pointer"
|
|
1353
|
-
},
|
|
1354
|
-
get_worker_status: {
|
|
1355
|
-
parameters: [],
|
|
1356
|
-
result: "pointer"
|
|
1357
|
-
},
|
|
1358
|
-
stop_worker: {
|
|
1359
|
-
parameters: [],
|
|
1360
|
-
result: "pointer"
|
|
1361
|
-
},
|
|
1362
|
-
transition_to_graceful_shutdown: {
|
|
1363
|
-
parameters: [],
|
|
1364
|
-
result: "pointer"
|
|
1365
|
-
},
|
|
1366
|
-
poll_step_events: {
|
|
1367
|
-
parameters: [],
|
|
1368
|
-
result: "pointer"
|
|
1369
|
-
},
|
|
1370
|
-
poll_in_process_events: {
|
|
1371
|
-
parameters: [],
|
|
1372
|
-
result: "pointer"
|
|
1373
|
-
},
|
|
1374
|
-
complete_step_event: {
|
|
1375
|
-
parameters: ["buffer", "buffer"],
|
|
1376
|
-
result: "i32"
|
|
1377
|
-
},
|
|
1378
|
-
checkpoint_yield_step_event: {
|
|
1379
|
-
parameters: ["buffer", "buffer"],
|
|
1380
|
-
result: "i32"
|
|
1381
|
-
},
|
|
1382
|
-
get_ffi_dispatch_metrics: {
|
|
1383
|
-
parameters: [],
|
|
1384
|
-
result: "pointer"
|
|
1385
|
-
},
|
|
1386
|
-
check_starvation_warnings: {
|
|
1387
|
-
parameters: [],
|
|
1388
|
-
result: "void"
|
|
1389
|
-
},
|
|
1390
|
-
cleanup_timeouts: {
|
|
1391
|
-
parameters: [],
|
|
1392
|
-
result: "void"
|
|
1393
|
-
},
|
|
1394
|
-
log_error: {
|
|
1395
|
-
parameters: ["buffer", "buffer"],
|
|
1396
|
-
result: "void"
|
|
1397
|
-
},
|
|
1398
|
-
log_warn: {
|
|
1399
|
-
parameters: ["buffer", "buffer"],
|
|
1400
|
-
result: "void"
|
|
1401
|
-
},
|
|
1402
|
-
log_info: {
|
|
1403
|
-
parameters: ["buffer", "buffer"],
|
|
1404
|
-
result: "void"
|
|
1405
|
-
},
|
|
1406
|
-
log_debug: {
|
|
1407
|
-
parameters: ["buffer", "buffer"],
|
|
1408
|
-
result: "void"
|
|
1409
|
-
},
|
|
1410
|
-
log_trace: {
|
|
1411
|
-
parameters: ["buffer", "buffer"],
|
|
1412
|
-
result: "void"
|
|
1413
|
-
},
|
|
1414
|
-
free_rust_string: {
|
|
1415
|
-
parameters: ["pointer"],
|
|
1416
|
-
result: "void"
|
|
1417
|
-
},
|
|
1418
|
-
// Client API functions (TAS-231)
|
|
1419
|
-
client_create_task: {
|
|
1420
|
-
parameters: ["buffer"],
|
|
1421
|
-
result: "pointer"
|
|
1422
|
-
},
|
|
1423
|
-
client_get_task: {
|
|
1424
|
-
parameters: ["buffer"],
|
|
1425
|
-
result: "pointer"
|
|
1426
|
-
},
|
|
1427
|
-
client_list_tasks: {
|
|
1428
|
-
parameters: ["buffer"],
|
|
1429
|
-
result: "pointer"
|
|
1430
|
-
},
|
|
1431
|
-
client_cancel_task: {
|
|
1432
|
-
parameters: ["buffer"],
|
|
1433
|
-
result: "pointer"
|
|
1434
|
-
},
|
|
1435
|
-
client_list_task_steps: {
|
|
1436
|
-
parameters: ["buffer"],
|
|
1437
|
-
result: "pointer"
|
|
1438
|
-
},
|
|
1439
|
-
client_get_step: {
|
|
1440
|
-
parameters: ["buffer", "buffer"],
|
|
1441
|
-
result: "pointer"
|
|
1442
|
-
},
|
|
1443
|
-
client_get_step_audit_history: {
|
|
1444
|
-
parameters: ["buffer", "buffer"],
|
|
1445
|
-
result: "pointer"
|
|
1446
|
-
},
|
|
1447
|
-
client_health_check: {
|
|
1448
|
-
parameters: [],
|
|
1449
|
-
result: "pointer"
|
|
1450
|
-
}
|
|
1451
|
-
});
|
|
1452
|
-
}
|
|
1453
|
-
unload() {
|
|
1454
|
-
if (this.lib) {
|
|
1455
|
-
this.lib.close();
|
|
1456
|
-
this.lib = null;
|
|
1457
|
-
}
|
|
1458
|
-
}
|
|
1459
|
-
ensureLoaded() {
|
|
1460
|
-
if (!this.lib) {
|
|
1461
|
-
throw new Error("Native library not loaded. Call load() first.");
|
|
1462
|
-
}
|
|
1463
|
-
return this.lib.symbols;
|
|
1464
|
-
}
|
|
1465
|
-
/**
|
|
1466
|
-
* Creates a null-terminated C string buffer.
|
|
1467
|
-
* With 'buffer' FFI type, we return Uint8Array directly.
|
|
1468
|
-
*/
|
|
1469
|
-
toCString(str) {
|
|
1470
|
-
return this.encoder.encode(`${str}\0`);
|
|
1471
|
-
}
|
|
1472
|
-
// biome-ignore lint/suspicious/noExplicitAny: Deno PointerValue type
|
|
1473
|
-
fromCString(ptr) {
|
|
1474
|
-
if (ptr === null || Deno.UnsafePointer.equals(ptr, null)) {
|
|
1475
|
-
return null;
|
|
1476
|
-
}
|
|
1477
|
-
const view = new Deno.UnsafePointerView(ptr);
|
|
1478
|
-
return view.getCString();
|
|
1479
|
-
}
|
|
1480
|
-
getVersion() {
|
|
1481
|
-
const symbols = this.ensureLoaded();
|
|
1482
|
-
const result = symbols.get_version();
|
|
1483
|
-
const version = this.fromCString(result) ?? "unknown";
|
|
1484
|
-
if (result !== null) symbols.free_rust_string(result);
|
|
1485
|
-
return version;
|
|
1486
|
-
}
|
|
1487
|
-
getRustVersion() {
|
|
1488
|
-
const symbols = this.ensureLoaded();
|
|
1489
|
-
const result = symbols.get_rust_version();
|
|
1490
|
-
const version = this.fromCString(result) ?? "unknown";
|
|
1491
|
-
if (result !== null) symbols.free_rust_string(result);
|
|
1492
|
-
return version;
|
|
1493
|
-
}
|
|
1494
|
-
healthCheck() {
|
|
1495
|
-
const symbols = this.ensureLoaded();
|
|
1496
|
-
return symbols.health_check() === 1;
|
|
1497
|
-
}
|
|
1498
|
-
bootstrapWorker(config) {
|
|
1499
|
-
const symbols = this.ensureLoaded();
|
|
1500
|
-
const configBuf = config ? this.toCString(this.toJson(config)) : null;
|
|
1501
|
-
const result = symbols.bootstrap_worker(configBuf);
|
|
1502
|
-
const jsonStr = this.fromCString(result);
|
|
1503
|
-
if (result !== null) symbols.free_rust_string(result);
|
|
1504
|
-
const parsed = this.parseJson(jsonStr);
|
|
1505
|
-
return parsed ?? {
|
|
1506
|
-
success: false,
|
|
1507
|
-
status: "error",
|
|
1508
|
-
message: "Failed to parse bootstrap result",
|
|
1509
|
-
error: "Invalid JSON response"
|
|
1510
|
-
};
|
|
1511
|
-
}
|
|
1512
|
-
isWorkerRunning() {
|
|
1513
|
-
const symbols = this.ensureLoaded();
|
|
1514
|
-
return symbols.is_worker_running() === 1;
|
|
1515
|
-
}
|
|
1516
|
-
getWorkerStatus() {
|
|
1517
|
-
const symbols = this.ensureLoaded();
|
|
1518
|
-
const result = symbols.get_worker_status();
|
|
1519
|
-
const jsonStr = this.fromCString(result);
|
|
1520
|
-
if (result !== null) symbols.free_rust_string(result);
|
|
1521
|
-
const parsed = this.parseJson(jsonStr);
|
|
1522
|
-
return parsed ?? { success: false, running: false };
|
|
1523
|
-
}
|
|
1524
|
-
stopWorker() {
|
|
1525
|
-
const symbols = this.ensureLoaded();
|
|
1526
|
-
const result = symbols.stop_worker();
|
|
1527
|
-
const jsonStr = this.fromCString(result);
|
|
1528
|
-
if (result !== null) symbols.free_rust_string(result);
|
|
1529
|
-
const parsed = this.parseJson(jsonStr);
|
|
1530
|
-
return parsed ?? {
|
|
1531
|
-
success: false,
|
|
1532
|
-
status: "error",
|
|
1533
|
-
message: "Failed to parse stop result",
|
|
1534
|
-
error: "Invalid JSON response"
|
|
1535
|
-
};
|
|
1536
|
-
}
|
|
1537
|
-
transitionToGracefulShutdown() {
|
|
1538
|
-
const symbols = this.ensureLoaded();
|
|
1539
|
-
const result = symbols.transition_to_graceful_shutdown();
|
|
1540
|
-
const jsonStr = this.fromCString(result);
|
|
1541
|
-
if (result !== null) symbols.free_rust_string(result);
|
|
1542
|
-
const parsed = this.parseJson(jsonStr);
|
|
1543
|
-
return parsed ?? {
|
|
1544
|
-
success: false,
|
|
1545
|
-
status: "error",
|
|
1546
|
-
message: "Failed to parse shutdown result",
|
|
1547
|
-
error: "Invalid JSON response"
|
|
1548
|
-
};
|
|
1549
|
-
}
|
|
1550
|
-
pollStepEvents() {
|
|
1551
|
-
const symbols = this.ensureLoaded();
|
|
1552
|
-
const result = symbols.poll_step_events();
|
|
1553
|
-
if (result === null || Deno.UnsafePointer.equals(result, null)) {
|
|
1554
|
-
return null;
|
|
1555
|
-
}
|
|
1556
|
-
const jsonStr = this.fromCString(result);
|
|
1557
|
-
symbols.free_rust_string(result);
|
|
1558
|
-
return this.parseJson(jsonStr);
|
|
1559
|
-
}
|
|
1560
|
-
pollInProcessEvents() {
|
|
1561
|
-
const symbols = this.ensureLoaded();
|
|
1562
|
-
const result = symbols.poll_in_process_events();
|
|
1563
|
-
if (result === null || Deno.UnsafePointer.equals(result, null)) {
|
|
1564
|
-
return null;
|
|
1565
|
-
}
|
|
1566
|
-
const jsonStr = this.fromCString(result);
|
|
1567
|
-
symbols.free_rust_string(result);
|
|
1568
|
-
return this.parseJson(jsonStr);
|
|
1569
|
-
}
|
|
1570
|
-
completeStepEvent(eventId, result) {
|
|
1571
|
-
const symbols = this.ensureLoaded();
|
|
1572
|
-
const eventIdBuf = this.toCString(eventId);
|
|
1573
|
-
const resultJsonBuf = this.toCString(this.toJson(result));
|
|
1574
|
-
return symbols.complete_step_event(eventIdBuf, resultJsonBuf) === 1;
|
|
1575
|
-
}
|
|
1576
|
-
checkpointYieldStepEvent(eventId, checkpointData) {
|
|
1577
|
-
const symbols = this.ensureLoaded();
|
|
1578
|
-
const eventIdBuf = this.toCString(eventId);
|
|
1579
|
-
const checkpointJsonBuf = this.toCString(this.toJson(checkpointData));
|
|
1580
|
-
return symbols.checkpoint_yield_step_event(eventIdBuf, checkpointJsonBuf) === 1;
|
|
1581
|
-
}
|
|
1582
|
-
getFfiDispatchMetrics() {
|
|
1583
|
-
const symbols = this.ensureLoaded();
|
|
1584
|
-
const result = symbols.get_ffi_dispatch_metrics();
|
|
1585
|
-
const jsonStr = this.fromCString(result);
|
|
1586
|
-
if (result !== null) symbols.free_rust_string(result);
|
|
1587
|
-
const parsed = this.parseJson(jsonStr);
|
|
1588
|
-
if (parsed && typeof parsed.pending_count === "number") {
|
|
1589
|
-
return parsed;
|
|
1590
|
-
}
|
|
1591
|
-
return {
|
|
1592
|
-
pending_count: 0,
|
|
1593
|
-
starvation_detected: false,
|
|
1594
|
-
starving_event_count: 0,
|
|
1595
|
-
oldest_pending_age_ms: null,
|
|
1596
|
-
newest_pending_age_ms: null,
|
|
1597
|
-
oldest_event_id: null
|
|
1598
|
-
};
|
|
1599
|
-
}
|
|
1600
|
-
checkStarvationWarnings() {
|
|
1601
|
-
const symbols = this.ensureLoaded();
|
|
1602
|
-
symbols.check_starvation_warnings();
|
|
1603
|
-
}
|
|
1604
|
-
cleanupTimeouts() {
|
|
1605
|
-
const symbols = this.ensureLoaded();
|
|
1606
|
-
symbols.cleanup_timeouts();
|
|
1607
|
-
}
|
|
1608
|
-
logError(message, fields) {
|
|
1609
|
-
const symbols = this.ensureLoaded();
|
|
1610
|
-
const msgBuf = this.toCString(message);
|
|
1611
|
-
const fieldsBuf = fields ? this.toCString(this.toJson(fields)) : null;
|
|
1612
|
-
symbols.log_error(msgBuf, fieldsBuf);
|
|
1613
|
-
}
|
|
1614
|
-
logWarn(message, fields) {
|
|
1615
|
-
const symbols = this.ensureLoaded();
|
|
1616
|
-
const msgBuf = this.toCString(message);
|
|
1617
|
-
const fieldsBuf = fields ? this.toCString(this.toJson(fields)) : null;
|
|
1618
|
-
symbols.log_warn(msgBuf, fieldsBuf);
|
|
1619
|
-
}
|
|
1620
|
-
logInfo(message, fields) {
|
|
1621
|
-
const symbols = this.ensureLoaded();
|
|
1622
|
-
const msgBuf = this.toCString(message);
|
|
1623
|
-
const fieldsBuf = fields ? this.toCString(this.toJson(fields)) : null;
|
|
1624
|
-
symbols.log_info(msgBuf, fieldsBuf);
|
|
1625
|
-
}
|
|
1626
|
-
logDebug(message, fields) {
|
|
1627
|
-
const symbols = this.ensureLoaded();
|
|
1628
|
-
const msgBuf = this.toCString(message);
|
|
1629
|
-
const fieldsBuf = fields ? this.toCString(this.toJson(fields)) : null;
|
|
1630
|
-
symbols.log_debug(msgBuf, fieldsBuf);
|
|
1631
|
-
}
|
|
1632
|
-
logTrace(message, fields) {
|
|
1633
|
-
const symbols = this.ensureLoaded();
|
|
1634
|
-
const msgBuf = this.toCString(message);
|
|
1635
|
-
const fieldsBuf = fields ? this.toCString(this.toJson(fields)) : null;
|
|
1636
|
-
symbols.log_trace(msgBuf, fieldsBuf);
|
|
1637
|
-
}
|
|
1638
|
-
// ==========================================================================
|
|
1639
|
-
// Client API Operations (TAS-231)
|
|
1640
|
-
// ==========================================================================
|
|
1641
|
-
parseClientResult(result) {
|
|
1642
|
-
const jsonStr = this.fromCString(result);
|
|
1643
|
-
if (result !== null) this.ensureLoaded().free_rust_string(result);
|
|
1644
|
-
const parsed = this.parseJson(jsonStr);
|
|
1645
|
-
return parsed ?? {
|
|
1646
|
-
success: false,
|
|
1647
|
-
data: null,
|
|
1648
|
-
error: "Failed to parse client result",
|
|
1649
|
-
recoverable: null
|
|
1650
|
-
};
|
|
1651
|
-
}
|
|
1652
|
-
clientCreateTask(requestJson) {
|
|
1653
|
-
const symbols = this.ensureLoaded();
|
|
1654
|
-
const buf = this.toCString(requestJson);
|
|
1655
|
-
const result = symbols.client_create_task(buf);
|
|
1656
|
-
return this.parseClientResult(result);
|
|
1657
|
-
}
|
|
1658
|
-
clientGetTask(taskUuid) {
|
|
1659
|
-
const symbols = this.ensureLoaded();
|
|
1660
|
-
const buf = this.toCString(taskUuid);
|
|
1661
|
-
const result = symbols.client_get_task(buf);
|
|
1662
|
-
return this.parseClientResult(result);
|
|
1663
|
-
}
|
|
1664
|
-
clientListTasks(paramsJson) {
|
|
1665
|
-
const symbols = this.ensureLoaded();
|
|
1666
|
-
const buf = this.toCString(paramsJson);
|
|
1667
|
-
const result = symbols.client_list_tasks(buf);
|
|
1668
|
-
return this.parseClientResult(result);
|
|
1669
|
-
}
|
|
1670
|
-
clientCancelTask(taskUuid) {
|
|
1671
|
-
const symbols = this.ensureLoaded();
|
|
1672
|
-
const buf = this.toCString(taskUuid);
|
|
1673
|
-
const result = symbols.client_cancel_task(buf);
|
|
1674
|
-
return this.parseClientResult(result);
|
|
1675
|
-
}
|
|
1676
|
-
clientListTaskSteps(taskUuid) {
|
|
1677
|
-
const symbols = this.ensureLoaded();
|
|
1678
|
-
const buf = this.toCString(taskUuid);
|
|
1679
|
-
const result = symbols.client_list_task_steps(buf);
|
|
1680
|
-
return this.parseClientResult(result);
|
|
1681
|
-
}
|
|
1682
|
-
clientGetStep(taskUuid, stepUuid) {
|
|
1683
|
-
const symbols = this.ensureLoaded();
|
|
1684
|
-
const tBuf = this.toCString(taskUuid);
|
|
1685
|
-
const sBuf = this.toCString(stepUuid);
|
|
1686
|
-
const result = symbols.client_get_step(tBuf, sBuf);
|
|
1687
|
-
return this.parseClientResult(result);
|
|
1688
|
-
}
|
|
1689
|
-
clientGetStepAuditHistory(taskUuid, stepUuid) {
|
|
1690
|
-
const symbols = this.ensureLoaded();
|
|
1691
|
-
const tBuf = this.toCString(taskUuid);
|
|
1692
|
-
const sBuf = this.toCString(stepUuid);
|
|
1693
|
-
const result = symbols.client_get_step_audit_history(tBuf, sBuf);
|
|
1694
|
-
return this.parseClientResult(result);
|
|
1695
|
-
}
|
|
1696
|
-
clientHealthCheck() {
|
|
1697
|
-
const symbols = this.ensureLoaded();
|
|
1698
|
-
const result = symbols.client_health_check();
|
|
1699
|
-
return this.parseClientResult(result);
|
|
1700
|
-
}
|
|
1701
|
-
};
|
|
1702
|
-
}
|
|
1703
|
-
});
|
|
1704
23
|
|
|
1705
24
|
// src/registry/resolvers/explicit-mapping.ts
|
|
1706
25
|
var explicit_mapping_exports = {};
|
|
@@ -1849,8 +168,8 @@ var init_class_lookup = __esm({
|
|
|
1849
168
|
}
|
|
1850
169
|
const modulePath = definition.callable;
|
|
1851
170
|
try {
|
|
1852
|
-
const
|
|
1853
|
-
const handlerClass = this.findHandlerClass(
|
|
171
|
+
const module = await import(modulePath);
|
|
172
|
+
const handlerClass = this.findHandlerClass(module);
|
|
1854
173
|
if (!handlerClass) {
|
|
1855
174
|
return null;
|
|
1856
175
|
}
|
|
@@ -1866,11 +185,11 @@ var init_class_lookup = __esm({
|
|
|
1866
185
|
/**
|
|
1867
186
|
* Find a handler class in a module's exports.
|
|
1868
187
|
*/
|
|
1869
|
-
findHandlerClass(
|
|
1870
|
-
if (this.isHandlerClass(
|
|
1871
|
-
return
|
|
188
|
+
findHandlerClass(module) {
|
|
189
|
+
if (this.isHandlerClass(module.default)) {
|
|
190
|
+
return module.default;
|
|
1872
191
|
}
|
|
1873
|
-
for (const [, exported] of Object.entries(
|
|
192
|
+
for (const [, exported] of Object.entries(module)) {
|
|
1874
193
|
if (this.isHandlerClass(exported)) {
|
|
1875
194
|
return exported;
|
|
1876
195
|
}
|
|
@@ -1904,96 +223,52 @@ function toFfiBootstrapConfig(config) {
|
|
|
1904
223
|
return {};
|
|
1905
224
|
}
|
|
1906
225
|
const result = {};
|
|
1907
|
-
if (config.
|
|
1908
|
-
|
|
1909
|
-
}
|
|
1910
|
-
if (config.logLevel !== void 0) {
|
|
1911
|
-
result.log_level = config.logLevel;
|
|
1912
|
-
}
|
|
1913
|
-
if (config.databaseUrl !== void 0) {
|
|
1914
|
-
result.database_url = config.databaseUrl;
|
|
1915
|
-
}
|
|
1916
|
-
if (config.namespace !== void 0) {
|
|
1917
|
-
result.namespace = config.namespace;
|
|
1918
|
-
}
|
|
1919
|
-
if (config.configPath !== void 0) {
|
|
1920
|
-
result.config_path = config.configPath;
|
|
1921
|
-
}
|
|
226
|
+
if (config.namespace !== void 0) result.namespace = config.namespace;
|
|
227
|
+
if (config.configPath !== void 0) result.configPath = config.configPath;
|
|
1922
228
|
return result;
|
|
1923
229
|
}
|
|
1924
230
|
function fromFfiBootstrapResult(result) {
|
|
1925
|
-
const
|
|
231
|
+
const out = {
|
|
1926
232
|
success: result.success,
|
|
1927
233
|
status: result.status,
|
|
1928
234
|
message: result.message
|
|
1929
235
|
};
|
|
1930
|
-
if (result.
|
|
1931
|
-
|
|
1932
|
-
}
|
|
1933
|
-
if (result.error !== void 0) {
|
|
1934
|
-
converted.error = result.error;
|
|
1935
|
-
}
|
|
1936
|
-
return converted;
|
|
236
|
+
if (result.workerId != null) out.workerId = result.workerId;
|
|
237
|
+
return out;
|
|
1937
238
|
}
|
|
1938
239
|
function fromFfiWorkerStatus(status) {
|
|
1939
|
-
const
|
|
240
|
+
const out = {
|
|
1940
241
|
success: status.success,
|
|
1941
242
|
running: status.running
|
|
1942
243
|
};
|
|
1943
|
-
if (status.status
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
converted.workerId = status.worker_id;
|
|
1948
|
-
}
|
|
1949
|
-
if (status.environment !== void 0) {
|
|
1950
|
-
converted.environment = status.environment;
|
|
1951
|
-
}
|
|
1952
|
-
if (status.worker_core_status !== void 0) {
|
|
1953
|
-
converted.workerCoreStatus = status.worker_core_status;
|
|
1954
|
-
}
|
|
1955
|
-
if (status.web_api_enabled !== void 0) {
|
|
1956
|
-
converted.webApiEnabled = status.web_api_enabled;
|
|
1957
|
-
}
|
|
1958
|
-
if (status.supported_namespaces !== void 0) {
|
|
1959
|
-
converted.supportedNamespaces = status.supported_namespaces;
|
|
1960
|
-
}
|
|
1961
|
-
if (status.database_pool_size !== void 0) {
|
|
1962
|
-
converted.databasePoolSize = status.database_pool_size;
|
|
1963
|
-
}
|
|
1964
|
-
if (status.database_pool_idle !== void 0) {
|
|
1965
|
-
converted.databasePoolIdle = status.database_pool_idle;
|
|
1966
|
-
}
|
|
1967
|
-
return converted;
|
|
244
|
+
if (status.status != null) out.status = status.status;
|
|
245
|
+
if (status.workerId != null) out.workerId = status.workerId;
|
|
246
|
+
if (status.environment != null) out.environment = status.environment;
|
|
247
|
+
return out;
|
|
1968
248
|
}
|
|
1969
249
|
function fromFfiStopResult(result) {
|
|
1970
|
-
const
|
|
250
|
+
const out = {
|
|
1971
251
|
success: result.success,
|
|
1972
|
-
status: result.
|
|
1973
|
-
message: result.
|
|
252
|
+
status: result.running ? "stopped" : "not_running",
|
|
253
|
+
message: result.status ?? "Worker stopped"
|
|
1974
254
|
};
|
|
1975
|
-
if (result.
|
|
1976
|
-
|
|
1977
|
-
}
|
|
1978
|
-
if (result.error !== void 0) {
|
|
1979
|
-
converted.error = result.error;
|
|
1980
|
-
}
|
|
1981
|
-
return converted;
|
|
255
|
+
if (result.workerId != null) out.workerId = result.workerId;
|
|
256
|
+
return out;
|
|
1982
257
|
}
|
|
1983
258
|
|
|
1984
259
|
// src/bootstrap/bootstrap.ts
|
|
1985
|
-
async function bootstrapWorker(config,
|
|
260
|
+
async function bootstrapWorker(config, module) {
|
|
1986
261
|
try {
|
|
1987
|
-
if (!
|
|
262
|
+
if (!module) {
|
|
1988
263
|
return {
|
|
1989
264
|
success: false,
|
|
1990
265
|
status: "error",
|
|
1991
|
-
message: "
|
|
1992
|
-
error: "
|
|
266
|
+
message: "Module not loaded. Ensure the FFI library is available.",
|
|
267
|
+
error: "Module not loaded"
|
|
1993
268
|
};
|
|
1994
269
|
}
|
|
1995
270
|
const ffiConfig = toFfiBootstrapConfig(config);
|
|
1996
|
-
const ffiResult =
|
|
271
|
+
const ffiResult = module.bootstrapWorker(ffiConfig);
|
|
1997
272
|
return fromFfiBootstrapResult(ffiResult);
|
|
1998
273
|
} catch (error) {
|
|
1999
274
|
return {
|
|
@@ -2004,16 +279,16 @@ async function bootstrapWorker(config, runtime) {
|
|
|
2004
279
|
};
|
|
2005
280
|
}
|
|
2006
281
|
}
|
|
2007
|
-
function stopWorker(
|
|
2008
|
-
if (!
|
|
282
|
+
function stopWorker(module) {
|
|
283
|
+
if (!module) {
|
|
2009
284
|
return {
|
|
2010
285
|
success: true,
|
|
2011
286
|
status: "not_running",
|
|
2012
|
-
message: "
|
|
287
|
+
message: "Module not loaded"
|
|
2013
288
|
};
|
|
2014
289
|
}
|
|
2015
290
|
try {
|
|
2016
|
-
const ffiResult =
|
|
291
|
+
const ffiResult = module.stopWorker();
|
|
2017
292
|
return fromFfiStopResult(ffiResult);
|
|
2018
293
|
} catch (error) {
|
|
2019
294
|
return {
|
|
@@ -2024,8 +299,8 @@ function stopWorker(runtime) {
|
|
|
2024
299
|
};
|
|
2025
300
|
}
|
|
2026
301
|
}
|
|
2027
|
-
function getWorkerStatus(
|
|
2028
|
-
if (!
|
|
302
|
+
function getWorkerStatus(module) {
|
|
303
|
+
if (!module) {
|
|
2029
304
|
return {
|
|
2030
305
|
success: false,
|
|
2031
306
|
running: false,
|
|
@@ -2033,7 +308,7 @@ function getWorkerStatus(runtime) {
|
|
|
2033
308
|
};
|
|
2034
309
|
}
|
|
2035
310
|
try {
|
|
2036
|
-
const ffiStatus =
|
|
311
|
+
const ffiStatus = module.getWorkerStatus();
|
|
2037
312
|
return fromFfiWorkerStatus(ffiStatus);
|
|
2038
313
|
} catch (_error) {
|
|
2039
314
|
return {
|
|
@@ -2043,16 +318,16 @@ function getWorkerStatus(runtime) {
|
|
|
2043
318
|
};
|
|
2044
319
|
}
|
|
2045
320
|
}
|
|
2046
|
-
function transitionToGracefulShutdown(
|
|
2047
|
-
if (!
|
|
321
|
+
function transitionToGracefulShutdown(module) {
|
|
322
|
+
if (!module) {
|
|
2048
323
|
return {
|
|
2049
324
|
success: true,
|
|
2050
325
|
status: "not_running",
|
|
2051
|
-
message: "
|
|
326
|
+
message: "Module not loaded"
|
|
2052
327
|
};
|
|
2053
328
|
}
|
|
2054
329
|
try {
|
|
2055
|
-
const ffiResult =
|
|
330
|
+
const ffiResult = module.transitionToGracefulShutdown();
|
|
2056
331
|
return fromFfiStopResult(ffiResult);
|
|
2057
332
|
} catch (error) {
|
|
2058
333
|
return {
|
|
@@ -2063,42 +338,42 @@ function transitionToGracefulShutdown(runtime) {
|
|
|
2063
338
|
};
|
|
2064
339
|
}
|
|
2065
340
|
}
|
|
2066
|
-
function isWorkerRunning(
|
|
2067
|
-
if (!
|
|
341
|
+
function isWorkerRunning(module) {
|
|
342
|
+
if (!module) {
|
|
2068
343
|
return false;
|
|
2069
344
|
}
|
|
2070
345
|
try {
|
|
2071
|
-
return
|
|
346
|
+
return module.isWorkerRunning();
|
|
2072
347
|
} catch {
|
|
2073
348
|
return false;
|
|
2074
349
|
}
|
|
2075
350
|
}
|
|
2076
|
-
function getVersion(
|
|
2077
|
-
if (!
|
|
2078
|
-
return "unknown (
|
|
351
|
+
function getVersion(module) {
|
|
352
|
+
if (!module) {
|
|
353
|
+
return "unknown (module not loaded)";
|
|
2079
354
|
}
|
|
2080
355
|
try {
|
|
2081
|
-
return
|
|
356
|
+
return module.getVersion();
|
|
2082
357
|
} catch {
|
|
2083
358
|
return "unknown";
|
|
2084
359
|
}
|
|
2085
360
|
}
|
|
2086
|
-
function getRustVersion(
|
|
2087
|
-
if (!
|
|
2088
|
-
return "unknown (
|
|
361
|
+
function getRustVersion(module) {
|
|
362
|
+
if (!module) {
|
|
363
|
+
return "unknown (module not loaded)";
|
|
2089
364
|
}
|
|
2090
365
|
try {
|
|
2091
|
-
return
|
|
366
|
+
return module.getRustVersion();
|
|
2092
367
|
} catch {
|
|
2093
368
|
return "unknown";
|
|
2094
369
|
}
|
|
2095
370
|
}
|
|
2096
|
-
function healthCheck(
|
|
2097
|
-
if (!
|
|
371
|
+
function healthCheck(module) {
|
|
372
|
+
if (!module) {
|
|
2098
373
|
return false;
|
|
2099
374
|
}
|
|
2100
375
|
try {
|
|
2101
|
-
return
|
|
376
|
+
return module.healthCheck();
|
|
2102
377
|
} catch {
|
|
2103
378
|
return false;
|
|
2104
379
|
}
|
|
@@ -2123,7 +398,7 @@ var TaskerClient = class {
|
|
|
2123
398
|
* Create a task via the orchestration API.
|
|
2124
399
|
*
|
|
2125
400
|
* @param options - Task creation options (only `name` is required)
|
|
2126
|
-
* @returns Typed task response
|
|
401
|
+
* @returns Typed task response data
|
|
2127
402
|
* @throws TaskerClientError if the operation fails
|
|
2128
403
|
*/
|
|
2129
404
|
createTask(options) {
|
|
@@ -2133,45 +408,45 @@ var TaskerClient = class {
|
|
|
2133
408
|
version: options.version ?? "1.0.0",
|
|
2134
409
|
context: options.context ?? {},
|
|
2135
410
|
initiator: options.initiator ?? "tasker-core-typescript",
|
|
2136
|
-
|
|
411
|
+
sourceSystem: options.sourceSystem ?? "tasker-core",
|
|
2137
412
|
reason: options.reason ?? "Task requested",
|
|
2138
|
-
tags: options.tags ?? []
|
|
2139
|
-
requested_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2140
|
-
options: null,
|
|
2141
|
-
priority: options.priority ?? null,
|
|
2142
|
-
correlation_id: options.correlationId ?? crypto.randomUUID(),
|
|
2143
|
-
parent_correlation_id: options.parentCorrelationId ?? null,
|
|
2144
|
-
idempotency_key: options.idempotencyKey ?? null
|
|
413
|
+
tags: options.tags ?? []
|
|
2145
414
|
};
|
|
2146
|
-
|
|
415
|
+
if (options.priority !== void 0) request.priority = options.priority;
|
|
416
|
+
if (options.correlationId !== void 0) request.correlationId = options.correlationId;
|
|
417
|
+
else request.correlationId = crypto.randomUUID();
|
|
418
|
+
if (options.parentCorrelationId !== void 0)
|
|
419
|
+
request.parentCorrelationId = options.parentCorrelationId;
|
|
420
|
+
if (options.idempotencyKey !== void 0) request.idempotencyKey = options.idempotencyKey;
|
|
421
|
+
const result = this.getModule().clientCreateTask(request);
|
|
2147
422
|
return this.unwrap(result);
|
|
2148
423
|
}
|
|
2149
424
|
/**
|
|
2150
425
|
* Get a task by UUID.
|
|
2151
426
|
*
|
|
2152
427
|
* @param taskUuid - The task UUID
|
|
2153
|
-
* @returns Typed task response
|
|
428
|
+
* @returns Typed task response data
|
|
2154
429
|
* @throws TaskerClientError if the operation fails
|
|
2155
430
|
*/
|
|
2156
431
|
getTask(taskUuid) {
|
|
2157
|
-
const result = this.
|
|
432
|
+
const result = this.getModule().clientGetTask(taskUuid);
|
|
2158
433
|
return this.unwrap(result);
|
|
2159
434
|
}
|
|
2160
435
|
/**
|
|
2161
436
|
* List tasks with optional filtering and pagination.
|
|
2162
437
|
*
|
|
2163
438
|
* @param options - Filtering and pagination options
|
|
2164
|
-
* @returns Typed task list response
|
|
439
|
+
* @returns Typed task list response data
|
|
2165
440
|
* @throws TaskerClientError if the operation fails
|
|
2166
441
|
*/
|
|
2167
442
|
listTasks(options = {}) {
|
|
2168
443
|
const params = {
|
|
2169
444
|
limit: options.limit ?? 50,
|
|
2170
|
-
offset: options.offset ?? 0
|
|
2171
|
-
namespace: options.namespace ?? null,
|
|
2172
|
-
status: options.status ?? null
|
|
445
|
+
offset: options.offset ?? 0
|
|
2173
446
|
};
|
|
2174
|
-
|
|
447
|
+
if (options.namespace !== void 0) params.namespace = options.namespace;
|
|
448
|
+
if (options.status !== void 0) params.status = options.status;
|
|
449
|
+
const result = this.getModule().clientListTasks(params);
|
|
2175
450
|
return this.unwrap(result);
|
|
2176
451
|
}
|
|
2177
452
|
/**
|
|
@@ -2181,18 +456,18 @@ var TaskerClient = class {
|
|
|
2181
456
|
* @throws TaskerClientError if the operation fails
|
|
2182
457
|
*/
|
|
2183
458
|
cancelTask(taskUuid) {
|
|
2184
|
-
const result = this.
|
|
459
|
+
const result = this.getModule().clientCancelTask(taskUuid);
|
|
2185
460
|
this.unwrap(result);
|
|
2186
461
|
}
|
|
2187
462
|
/**
|
|
2188
463
|
* List workflow steps for a task.
|
|
2189
464
|
*
|
|
2190
465
|
* @param taskUuid - The task UUID
|
|
2191
|
-
* @returns Array of
|
|
466
|
+
* @returns Array of step data
|
|
2192
467
|
* @throws TaskerClientError if the operation fails
|
|
2193
468
|
*/
|
|
2194
469
|
listTaskSteps(taskUuid) {
|
|
2195
|
-
const result = this.
|
|
470
|
+
const result = this.getModule().clientListTaskSteps(taskUuid);
|
|
2196
471
|
return this.unwrap(result);
|
|
2197
472
|
}
|
|
2198
473
|
/**
|
|
@@ -2200,11 +475,11 @@ var TaskerClient = class {
|
|
|
2200
475
|
*
|
|
2201
476
|
* @param taskUuid - The task UUID
|
|
2202
477
|
* @param stepUuid - The step UUID
|
|
2203
|
-
* @returns Typed step response
|
|
478
|
+
* @returns Typed step response data
|
|
2204
479
|
* @throws TaskerClientError if the operation fails
|
|
2205
480
|
*/
|
|
2206
481
|
getStep(taskUuid, stepUuid) {
|
|
2207
|
-
const result = this.
|
|
482
|
+
const result = this.getModule().clientGetStep(taskUuid, stepUuid);
|
|
2208
483
|
return this.unwrap(result);
|
|
2209
484
|
}
|
|
2210
485
|
/**
|
|
@@ -2212,25 +487,25 @@ var TaskerClient = class {
|
|
|
2212
487
|
*
|
|
2213
488
|
* @param taskUuid - The task UUID
|
|
2214
489
|
* @param stepUuid - The step UUID
|
|
2215
|
-
* @returns Array of
|
|
490
|
+
* @returns Array of audit history entries
|
|
2216
491
|
* @throws TaskerClientError if the operation fails
|
|
2217
492
|
*/
|
|
2218
493
|
getStepAuditHistory(taskUuid, stepUuid) {
|
|
2219
|
-
const result = this.
|
|
494
|
+
const result = this.getModule().clientGetStepAuditHistory(taskUuid, stepUuid);
|
|
2220
495
|
return this.unwrap(result);
|
|
2221
496
|
}
|
|
2222
497
|
/**
|
|
2223
498
|
* Check orchestration API health.
|
|
2224
499
|
*
|
|
2225
|
-
* @returns Typed health response
|
|
500
|
+
* @returns Typed health response data
|
|
2226
501
|
* @throws TaskerClientError if the operation fails
|
|
2227
502
|
*/
|
|
2228
503
|
healthCheck() {
|
|
2229
|
-
const result = this.
|
|
504
|
+
const result = this.getModule().clientHealthCheck();
|
|
2230
505
|
return this.unwrap(result);
|
|
2231
506
|
}
|
|
2232
507
|
/**
|
|
2233
|
-
* Unwrap a
|
|
508
|
+
* Unwrap a NapiClientResult envelope, throwing on error.
|
|
2234
509
|
*/
|
|
2235
510
|
unwrap(result) {
|
|
2236
511
|
if (!result.success) {
|
|
@@ -2242,10 +517,10 @@ var TaskerClient = class {
|
|
|
2242
517
|
return result.data;
|
|
2243
518
|
}
|
|
2244
519
|
/**
|
|
2245
|
-
* Get the
|
|
520
|
+
* Get the napi-rs module from the layer.
|
|
2246
521
|
*/
|
|
2247
|
-
|
|
2248
|
-
return this.ffiLayer.
|
|
522
|
+
getModule() {
|
|
523
|
+
return this.ffiLayer.getModule();
|
|
2249
524
|
}
|
|
2250
525
|
};
|
|
2251
526
|
|
|
@@ -2454,7 +729,7 @@ if (process.env.TASKER_ENV !== "production") {
|
|
|
2454
729
|
}
|
|
2455
730
|
var log = pino(loggerOptions);
|
|
2456
731
|
var EventPoller = class {
|
|
2457
|
-
|
|
732
|
+
module;
|
|
2458
733
|
config;
|
|
2459
734
|
emitter;
|
|
2460
735
|
state = "stopped";
|
|
@@ -2467,12 +742,12 @@ var EventPoller = class {
|
|
|
2467
742
|
/**
|
|
2468
743
|
* Create a new EventPoller.
|
|
2469
744
|
*
|
|
2470
|
-
* @param
|
|
745
|
+
* @param module - The napi-rs module for polling events
|
|
2471
746
|
* @param emitter - The event emitter to dispatch events to (required, no fallback)
|
|
2472
747
|
* @param config - Optional configuration for polling behavior
|
|
2473
748
|
*/
|
|
2474
|
-
constructor(
|
|
2475
|
-
this.
|
|
749
|
+
constructor(module, emitter, config = {}) {
|
|
750
|
+
this.module = module;
|
|
2476
751
|
this.emitter = emitter;
|
|
2477
752
|
this.config = {
|
|
2478
753
|
pollIntervalMs: config.pollIntervalMs ?? 10,
|
|
@@ -2539,13 +814,6 @@ var EventPoller = class {
|
|
|
2539
814
|
log.debug({ component: "event-poller" }, "Already running, returning early");
|
|
2540
815
|
return;
|
|
2541
816
|
}
|
|
2542
|
-
log.debug(
|
|
2543
|
-
{ component: "event-poller", runtimeLoaded: this.runtime.isLoaded },
|
|
2544
|
-
"Checking runtime.isLoaded"
|
|
2545
|
-
);
|
|
2546
|
-
if (!this.runtime.isLoaded) {
|
|
2547
|
-
throw new Error("Runtime not loaded. Call runtime.load() first.");
|
|
2548
|
-
}
|
|
2549
817
|
this.state = "running";
|
|
2550
818
|
this.pollCount = 0;
|
|
2551
819
|
this.cycleCount = 0;
|
|
@@ -2606,17 +874,17 @@ var EventPoller = class {
|
|
|
2606
874
|
try {
|
|
2607
875
|
let eventsProcessed = 0;
|
|
2608
876
|
for (let i = 0; i < this.config.maxEventsPerCycle; i++) {
|
|
2609
|
-
const event = this.
|
|
877
|
+
const event = this.module.pollStepEvents();
|
|
2610
878
|
if (event === null) {
|
|
2611
879
|
break;
|
|
2612
880
|
}
|
|
2613
881
|
eventsProcessed++;
|
|
2614
|
-
const handlerCallable = event.
|
|
882
|
+
const handlerCallable = event.stepDefinition.handlerCallable;
|
|
2615
883
|
log.info(
|
|
2616
884
|
{
|
|
2617
885
|
component: "event-poller",
|
|
2618
886
|
operation: "event_received",
|
|
2619
|
-
stepUuid: event.
|
|
887
|
+
stepUuid: event.stepUuid,
|
|
2620
888
|
handlerCallable,
|
|
2621
889
|
eventIndex: i
|
|
2622
890
|
},
|
|
@@ -2628,7 +896,7 @@ var EventPoller = class {
|
|
|
2628
896
|
this.checkStarvation();
|
|
2629
897
|
}
|
|
2630
898
|
if (this.pollCount % this.config.cleanupInterval === 0) {
|
|
2631
|
-
this.
|
|
899
|
+
this.module.cleanupTimeouts();
|
|
2632
900
|
}
|
|
2633
901
|
if (this.pollCount % this.config.metricsInterval === 0) {
|
|
2634
902
|
this.emitMetrics();
|
|
@@ -2649,12 +917,12 @@ var EventPoller = class {
|
|
|
2649
917
|
* Handle a step event
|
|
2650
918
|
*/
|
|
2651
919
|
handleStepEvent(event) {
|
|
2652
|
-
const handlerCallable = event.
|
|
920
|
+
const handlerCallable = event.stepDefinition.handlerCallable;
|
|
2653
921
|
log.debug(
|
|
2654
922
|
{
|
|
2655
923
|
component: "event-poller",
|
|
2656
924
|
operation: "handle_step_event",
|
|
2657
|
-
stepUuid: event.
|
|
925
|
+
stepUuid: event.stepUuid,
|
|
2658
926
|
handlerCallable,
|
|
2659
927
|
hasCallback: !!this.stepEventCallback
|
|
2660
928
|
},
|
|
@@ -2665,7 +933,7 @@ var EventPoller = class {
|
|
|
2665
933
|
{
|
|
2666
934
|
component: "event-poller",
|
|
2667
935
|
emitterInstanceId: this.emitter.getInstanceId(),
|
|
2668
|
-
stepUuid: event.
|
|
936
|
+
stepUuid: event.stepUuid,
|
|
2669
937
|
listenerCount: listenerCountBefore,
|
|
2670
938
|
eventName: StepEventNames.STEP_EXECUTION_RECEIVED
|
|
2671
939
|
},
|
|
@@ -2679,7 +947,7 @@ var EventPoller = class {
|
|
|
2679
947
|
log.info(
|
|
2680
948
|
{
|
|
2681
949
|
component: "event-poller",
|
|
2682
|
-
stepUuid: event.
|
|
950
|
+
stepUuid: event.stepUuid,
|
|
2683
951
|
emitResult,
|
|
2684
952
|
listenerCountAfter: this.emitter.listenerCount(StepEventNames.STEP_EXECUTION_RECEIVED),
|
|
2685
953
|
eventName: StepEventNames.STEP_EXECUTION_RECEIVED
|
|
@@ -2690,7 +958,7 @@ var EventPoller = class {
|
|
|
2690
958
|
log.error(
|
|
2691
959
|
{
|
|
2692
960
|
component: "event-poller",
|
|
2693
|
-
stepUuid: event.
|
|
961
|
+
stepUuid: event.stepUuid,
|
|
2694
962
|
error: emitError instanceof Error ? emitError.message : String(emitError),
|
|
2695
963
|
stack: emitError instanceof Error ? emitError.stack : void 0
|
|
2696
964
|
},
|
|
@@ -2699,7 +967,7 @@ var EventPoller = class {
|
|
|
2699
967
|
}
|
|
2700
968
|
if (this.stepEventCallback) {
|
|
2701
969
|
log.debug(
|
|
2702
|
-
{ component: "event-poller", stepUuid: event.
|
|
970
|
+
{ component: "event-poller", stepUuid: event.stepUuid },
|
|
2703
971
|
"Invoking step event callback"
|
|
2704
972
|
);
|
|
2705
973
|
this.stepEventCallback(event).catch((error) => {
|
|
@@ -2707,7 +975,7 @@ var EventPoller = class {
|
|
|
2707
975
|
});
|
|
2708
976
|
} else {
|
|
2709
977
|
log.warn(
|
|
2710
|
-
{ component: "event-poller", stepUuid: event.
|
|
978
|
+
{ component: "event-poller", stepUuid: event.stepUuid },
|
|
2711
979
|
"No step event callback registered!"
|
|
2712
980
|
);
|
|
2713
981
|
}
|
|
@@ -2717,9 +985,9 @@ var EventPoller = class {
|
|
|
2717
985
|
*/
|
|
2718
986
|
checkStarvation() {
|
|
2719
987
|
try {
|
|
2720
|
-
this.
|
|
2721
|
-
const metrics = this.
|
|
2722
|
-
if (metrics.
|
|
988
|
+
this.module.checkStarvationWarnings();
|
|
989
|
+
const metrics = this.module.getFfiDispatchMetrics();
|
|
990
|
+
if (metrics.starvationDetected) {
|
|
2723
991
|
this.emitter.emitStarvationDetected(metrics);
|
|
2724
992
|
}
|
|
2725
993
|
} catch (error) {
|
|
@@ -2731,7 +999,7 @@ var EventPoller = class {
|
|
|
2731
999
|
*/
|
|
2732
1000
|
emitMetrics() {
|
|
2733
1001
|
try {
|
|
2734
|
-
const metrics = this.
|
|
1002
|
+
const metrics = this.module.getFfiDispatchMetrics();
|
|
2735
1003
|
this.emitter.emitMetricsUpdated(metrics);
|
|
2736
1004
|
if (this.metricsCallback) {
|
|
2737
1005
|
this.metricsCallback(metrics);
|
|
@@ -2756,20 +1024,17 @@ var EventPoller = class {
|
|
|
2756
1024
|
}
|
|
2757
1025
|
}
|
|
2758
1026
|
};
|
|
2759
|
-
function createEventPoller(
|
|
2760
|
-
return new EventPoller(
|
|
1027
|
+
function createEventPoller(module, emitter, config) {
|
|
1028
|
+
return new EventPoller(module, emitter, config);
|
|
2761
1029
|
}
|
|
2762
1030
|
|
|
2763
1031
|
// src/logging/index.ts
|
|
2764
|
-
var
|
|
2765
|
-
function setLoggingRuntime(
|
|
2766
|
-
|
|
1032
|
+
var installedModule = null;
|
|
1033
|
+
function setLoggingRuntime(module) {
|
|
1034
|
+
installedModule = module;
|
|
2767
1035
|
}
|
|
2768
|
-
function
|
|
2769
|
-
|
|
2770
|
-
return installedRuntime;
|
|
2771
|
-
}
|
|
2772
|
-
return null;
|
|
1036
|
+
function getLoggingModule() {
|
|
1037
|
+
return installedModule;
|
|
2773
1038
|
}
|
|
2774
1039
|
function toFfiFields(fields) {
|
|
2775
1040
|
if (!fields) {
|
|
@@ -2789,61 +1054,61 @@ function fallbackLog(level, message, fields) {
|
|
|
2789
1054
|
console.log(`[${timestamp}] ${level.toUpperCase()}: ${message}${fieldsStr}`);
|
|
2790
1055
|
}
|
|
2791
1056
|
function logError(message, fields) {
|
|
2792
|
-
const
|
|
2793
|
-
if (!
|
|
1057
|
+
const module = getLoggingModule();
|
|
1058
|
+
if (!module) {
|
|
2794
1059
|
fallbackLog("error", message, fields);
|
|
2795
1060
|
return;
|
|
2796
1061
|
}
|
|
2797
1062
|
try {
|
|
2798
|
-
|
|
1063
|
+
module.logError(message, toFfiFields(fields));
|
|
2799
1064
|
} catch {
|
|
2800
1065
|
fallbackLog("error", message, fields);
|
|
2801
1066
|
}
|
|
2802
1067
|
}
|
|
2803
1068
|
function logWarn(message, fields) {
|
|
2804
|
-
const
|
|
2805
|
-
if (!
|
|
1069
|
+
const module = getLoggingModule();
|
|
1070
|
+
if (!module) {
|
|
2806
1071
|
fallbackLog("warn", message, fields);
|
|
2807
1072
|
return;
|
|
2808
1073
|
}
|
|
2809
1074
|
try {
|
|
2810
|
-
|
|
1075
|
+
module.logWarn(message, toFfiFields(fields));
|
|
2811
1076
|
} catch {
|
|
2812
1077
|
fallbackLog("warn", message, fields);
|
|
2813
1078
|
}
|
|
2814
1079
|
}
|
|
2815
1080
|
function logInfo(message, fields) {
|
|
2816
|
-
const
|
|
2817
|
-
if (!
|
|
1081
|
+
const module = getLoggingModule();
|
|
1082
|
+
if (!module) {
|
|
2818
1083
|
fallbackLog("info", message, fields);
|
|
2819
1084
|
return;
|
|
2820
1085
|
}
|
|
2821
1086
|
try {
|
|
2822
|
-
|
|
1087
|
+
module.logInfo(message, toFfiFields(fields));
|
|
2823
1088
|
} catch {
|
|
2824
1089
|
fallbackLog("info", message, fields);
|
|
2825
1090
|
}
|
|
2826
1091
|
}
|
|
2827
1092
|
function logDebug(message, fields) {
|
|
2828
|
-
const
|
|
2829
|
-
if (!
|
|
1093
|
+
const module = getLoggingModule();
|
|
1094
|
+
if (!module) {
|
|
2830
1095
|
fallbackLog("debug", message, fields);
|
|
2831
1096
|
return;
|
|
2832
1097
|
}
|
|
2833
1098
|
try {
|
|
2834
|
-
|
|
1099
|
+
module.logDebug(message, toFfiFields(fields));
|
|
2835
1100
|
} catch {
|
|
2836
1101
|
fallbackLog("debug", message, fields);
|
|
2837
1102
|
}
|
|
2838
1103
|
}
|
|
2839
1104
|
function logTrace(message, fields) {
|
|
2840
|
-
const
|
|
2841
|
-
if (!
|
|
1105
|
+
const module = getLoggingModule();
|
|
1106
|
+
if (!module) {
|
|
2842
1107
|
fallbackLog("trace", message, fields);
|
|
2843
1108
|
return;
|
|
2844
1109
|
}
|
|
2845
1110
|
try {
|
|
2846
|
-
|
|
1111
|
+
module.logTrace(message, toFfiFields(fields));
|
|
2847
1112
|
} catch {
|
|
2848
1113
|
fallbackLog("trace", message, fields);
|
|
2849
1114
|
}
|
|
@@ -2862,6 +1127,22 @@ function createLogger(defaultFields) {
|
|
|
2862
1127
|
};
|
|
2863
1128
|
}
|
|
2864
1129
|
|
|
1130
|
+
// src/types/error-type.ts
|
|
1131
|
+
var ErrorType = /* @__PURE__ */ ((ErrorType2) => {
|
|
1132
|
+
ErrorType2["PERMANENT_ERROR"] = "permanent_error";
|
|
1133
|
+
ErrorType2["RETRYABLE_ERROR"] = "retryable_error";
|
|
1134
|
+
ErrorType2["VALIDATION_ERROR"] = "validation_error";
|
|
1135
|
+
ErrorType2["TIMEOUT"] = "timeout";
|
|
1136
|
+
ErrorType2["HANDLER_ERROR"] = "handler_error";
|
|
1137
|
+
return ErrorType2;
|
|
1138
|
+
})(ErrorType || {});
|
|
1139
|
+
function isStandardErrorType(errorType) {
|
|
1140
|
+
return Object.values(ErrorType).includes(errorType);
|
|
1141
|
+
}
|
|
1142
|
+
function isTypicallyRetryable(errorType) {
|
|
1143
|
+
return ["retryable_error" /* RETRYABLE_ERROR */, "timeout" /* TIMEOUT */].includes(errorType);
|
|
1144
|
+
}
|
|
1145
|
+
|
|
2865
1146
|
// src/types/step-context.ts
|
|
2866
1147
|
var StepContext = class _StepContext {
|
|
2867
1148
|
/** The original FFI step event */
|
|
@@ -2878,9 +1159,9 @@ var StepContext = class _StepContext {
|
|
|
2878
1159
|
inputData;
|
|
2879
1160
|
/** Results from dependent steps */
|
|
2880
1161
|
dependencyResults;
|
|
2881
|
-
/** Handler-specific configuration (from
|
|
1162
|
+
/** Handler-specific configuration (from stepDefinition.handlerInitialization) */
|
|
2882
1163
|
stepConfig;
|
|
2883
|
-
/** Step-specific inputs (from
|
|
1164
|
+
/** Step-specific inputs (from workflowStep.inputs, used for batch cursor config) */
|
|
2884
1165
|
stepInputs;
|
|
2885
1166
|
/** Current retry attempt number */
|
|
2886
1167
|
retryCount;
|
|
@@ -2902,16 +1183,15 @@ var StepContext = class _StepContext {
|
|
|
2902
1183
|
/**
|
|
2903
1184
|
* Create a StepContext from an FFI event.
|
|
2904
1185
|
*
|
|
2905
|
-
*
|
|
2906
|
-
* the task_sequence_step payload.
|
|
1186
|
+
* TAS-290: All field access uses camelCase (napi-rs auto-converts).
|
|
2907
1187
|
*
|
|
2908
1188
|
* The FFI data structure mirrors the Ruby TaskSequenceStepWrapper:
|
|
2909
1189
|
* - task.context -> inputData (task context with user inputs)
|
|
2910
|
-
* -
|
|
2911
|
-
* -
|
|
2912
|
-
* -
|
|
2913
|
-
* -
|
|
2914
|
-
* -
|
|
1190
|
+
* - dependencyResults -> results from parent steps
|
|
1191
|
+
* - stepDefinition.handlerInitialization -> stepConfig
|
|
1192
|
+
* - workflowStep.attempts -> retryCount
|
|
1193
|
+
* - workflowStep.maxAttempts -> maxRetries
|
|
1194
|
+
* - workflowStep.inputs -> stepInputs
|
|
2915
1195
|
*
|
|
2916
1196
|
* @param event - The FFI step event
|
|
2917
1197
|
* @param handlerName - Name of the handler to execute
|
|
@@ -2920,19 +1200,18 @@ var StepContext = class _StepContext {
|
|
|
2920
1200
|
static fromFfiEvent(event, handlerName) {
|
|
2921
1201
|
const task = event.task ?? {};
|
|
2922
1202
|
const inputData = task.context ?? {};
|
|
2923
|
-
const dependencyResults = event.
|
|
2924
|
-
const stepDefinition = event.
|
|
2925
|
-
const
|
|
2926
|
-
const
|
|
2927
|
-
const workflowStep = event.workflow_step ?? {};
|
|
1203
|
+
const dependencyResults = event.dependencyResults ?? {};
|
|
1204
|
+
const stepDefinition = event.stepDefinition ?? {};
|
|
1205
|
+
const stepConfig = stepDefinition.handlerInitialization ?? {};
|
|
1206
|
+
const workflowStep = event.workflowStep ?? {};
|
|
2928
1207
|
const retryCount = workflowStep.attempts ?? 0;
|
|
2929
|
-
const maxRetries = workflowStep.
|
|
1208
|
+
const maxRetries = workflowStep.maxAttempts ?? 3;
|
|
2930
1209
|
const stepInputs = workflowStep.inputs ?? {};
|
|
2931
1210
|
return new _StepContext({
|
|
2932
1211
|
event,
|
|
2933
|
-
taskUuid: event.
|
|
2934
|
-
stepUuid: event.
|
|
2935
|
-
correlationId: event.
|
|
1212
|
+
taskUuid: event.taskUuid,
|
|
1213
|
+
stepUuid: event.stepUuid,
|
|
1214
|
+
correlationId: event.correlationId,
|
|
2936
1215
|
handlerName,
|
|
2937
1216
|
inputData,
|
|
2938
1217
|
dependencyResults,
|
|
@@ -3043,12 +1322,12 @@ var StepContext = class _StepContext {
|
|
|
3043
1322
|
* const value = context.getDependencyField('step_1', 'data', 'items');
|
|
3044
1323
|
* ```
|
|
3045
1324
|
*/
|
|
3046
|
-
getDependencyField(stepName, ...
|
|
1325
|
+
getDependencyField(stepName, ...path) {
|
|
3047
1326
|
let result = this.getDependencyResult(stepName);
|
|
3048
1327
|
if (result === null || result === void 0) {
|
|
3049
1328
|
return null;
|
|
3050
1329
|
}
|
|
3051
|
-
for (const key of
|
|
1330
|
+
for (const key of path) {
|
|
3052
1331
|
if (typeof result !== "object" || result === null) {
|
|
3053
1332
|
return null;
|
|
3054
1333
|
}
|
|
@@ -3062,10 +1341,14 @@ var StepContext = class _StepContext {
|
|
|
3062
1341
|
/**
|
|
3063
1342
|
* Get the raw checkpoint data from the workflow step.
|
|
3064
1343
|
*
|
|
1344
|
+
* Note: Checkpoint data from the database uses snake_case keys
|
|
1345
|
+
* (cursor, items_processed, accumulated_results) because it's stored
|
|
1346
|
+
* as a serde_json::Value that passes through napi-rs as-is.
|
|
1347
|
+
*
|
|
3065
1348
|
* @returns The checkpoint data object or null if not set
|
|
3066
1349
|
*/
|
|
3067
1350
|
get checkpoint() {
|
|
3068
|
-
const workflowStep = this.event.
|
|
1351
|
+
const workflowStep = this.event.workflowStep ?? {};
|
|
3069
1352
|
return workflowStep.checkpoint ?? null;
|
|
3070
1353
|
}
|
|
3071
1354
|
/**
|
|
@@ -3165,6 +1448,130 @@ var StepContext = class _StepContext {
|
|
|
3165
1448
|
}
|
|
3166
1449
|
};
|
|
3167
1450
|
|
|
1451
|
+
// src/types/step-handler-result.ts
|
|
1452
|
+
var StepHandlerResult = class _StepHandlerResult {
|
|
1453
|
+
/** Whether the handler executed successfully */
|
|
1454
|
+
success;
|
|
1455
|
+
/** Handler output data (success case) */
|
|
1456
|
+
result;
|
|
1457
|
+
/** Error message (failure case) */
|
|
1458
|
+
errorMessage;
|
|
1459
|
+
/** Error type/category for classification */
|
|
1460
|
+
errorType;
|
|
1461
|
+
/** Optional application-specific error code */
|
|
1462
|
+
errorCode;
|
|
1463
|
+
/** Whether the error is retryable */
|
|
1464
|
+
retryable;
|
|
1465
|
+
/** Additional execution metadata */
|
|
1466
|
+
metadata;
|
|
1467
|
+
/** Orchestration metadata for workflow coordination hints (e.g., backoff, headers) */
|
|
1468
|
+
orchestrationMetadata;
|
|
1469
|
+
constructor(params) {
|
|
1470
|
+
this.success = params.success;
|
|
1471
|
+
this.result = params.result ?? null;
|
|
1472
|
+
this.errorMessage = params.errorMessage ?? null;
|
|
1473
|
+
this.errorType = params.errorType ?? null;
|
|
1474
|
+
this.errorCode = params.errorCode ?? null;
|
|
1475
|
+
this.retryable = params.retryable ?? true;
|
|
1476
|
+
this.metadata = params.metadata ?? {};
|
|
1477
|
+
this.orchestrationMetadata = params.orchestrationMetadata ?? null;
|
|
1478
|
+
}
|
|
1479
|
+
/**
|
|
1480
|
+
* Create a successful handler result.
|
|
1481
|
+
*
|
|
1482
|
+
* This is the primary factory method for creating success results.
|
|
1483
|
+
* Aligned with Ruby and Python worker APIs.
|
|
1484
|
+
*
|
|
1485
|
+
* @param result - The handler output data
|
|
1486
|
+
* @param metadata - Optional additional metadata
|
|
1487
|
+
* @returns A StepHandlerResult indicating success
|
|
1488
|
+
*
|
|
1489
|
+
* @example
|
|
1490
|
+
* ```typescript
|
|
1491
|
+
* return StepHandlerResult.success(
|
|
1492
|
+
* { processed: 100, skipped: 5 }
|
|
1493
|
+
* );
|
|
1494
|
+
* ```
|
|
1495
|
+
*/
|
|
1496
|
+
static success(result, metadata) {
|
|
1497
|
+
return new _StepHandlerResult({
|
|
1498
|
+
success: true,
|
|
1499
|
+
result,
|
|
1500
|
+
metadata: metadata ?? {}
|
|
1501
|
+
});
|
|
1502
|
+
}
|
|
1503
|
+
/**
|
|
1504
|
+
* Create a failure handler result.
|
|
1505
|
+
*
|
|
1506
|
+
* @param message - Human-readable error message
|
|
1507
|
+
* @param errorType - Error type/category for classification. Use ErrorType enum.
|
|
1508
|
+
* @param retryable - Whether the error is retryable (default: true)
|
|
1509
|
+
* @param metadata - Optional additional metadata
|
|
1510
|
+
* @param errorCode - Optional application-specific error code
|
|
1511
|
+
* @returns A StepHandlerResult indicating failure
|
|
1512
|
+
*
|
|
1513
|
+
* @example
|
|
1514
|
+
* ```typescript
|
|
1515
|
+
* return StepHandlerResult.failure(
|
|
1516
|
+
* 'Invalid input format',
|
|
1517
|
+
* ErrorType.VALIDATION_ERROR,
|
|
1518
|
+
* false
|
|
1519
|
+
* );
|
|
1520
|
+
* ```
|
|
1521
|
+
*
|
|
1522
|
+
* @example With error code
|
|
1523
|
+
* ```typescript
|
|
1524
|
+
* return StepHandlerResult.failure(
|
|
1525
|
+
* 'Gateway timeout',
|
|
1526
|
+
* ErrorType.TIMEOUT,
|
|
1527
|
+
* true,
|
|
1528
|
+
* { duration_ms: 30000 },
|
|
1529
|
+
* 'GATEWAY_TIMEOUT'
|
|
1530
|
+
* );
|
|
1531
|
+
* ```
|
|
1532
|
+
*/
|
|
1533
|
+
static failure(message, errorType = "handler_error" /* HANDLER_ERROR */, retryable = true, metadata, errorCode) {
|
|
1534
|
+
return new _StepHandlerResult({
|
|
1535
|
+
success: false,
|
|
1536
|
+
errorMessage: message,
|
|
1537
|
+
// ErrorType enum values are already strings, so this works directly
|
|
1538
|
+
errorType,
|
|
1539
|
+
errorCode: errorCode ?? null,
|
|
1540
|
+
retryable,
|
|
1541
|
+
metadata: metadata ?? {}
|
|
1542
|
+
});
|
|
1543
|
+
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Check if this result indicates success.
|
|
1546
|
+
*/
|
|
1547
|
+
isSuccess() {
|
|
1548
|
+
return this.success;
|
|
1549
|
+
}
|
|
1550
|
+
/**
|
|
1551
|
+
* Check if this result indicates failure.
|
|
1552
|
+
*/
|
|
1553
|
+
isFailure() {
|
|
1554
|
+
return !this.success;
|
|
1555
|
+
}
|
|
1556
|
+
/**
|
|
1557
|
+
* Convert to JSON for serialization.
|
|
1558
|
+
*
|
|
1559
|
+
* Uses snake_case keys to match the Rust FFI contract.
|
|
1560
|
+
*/
|
|
1561
|
+
toJSON() {
|
|
1562
|
+
return {
|
|
1563
|
+
success: this.success,
|
|
1564
|
+
result: this.result,
|
|
1565
|
+
error_message: this.errorMessage,
|
|
1566
|
+
error_type: this.errorType,
|
|
1567
|
+
error_code: this.errorCode,
|
|
1568
|
+
retryable: this.retryable,
|
|
1569
|
+
metadata: this.metadata,
|
|
1570
|
+
orchestration_metadata: this.orchestrationMetadata
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1573
|
+
};
|
|
1574
|
+
|
|
3168
1575
|
// src/subscriber/step-execution-subscriber.ts
|
|
3169
1576
|
var loggerOptions2 = {
|
|
3170
1577
|
name: "step-subscriber",
|
|
@@ -3180,7 +1587,7 @@ var pinoLog = pino(loggerOptions2);
|
|
|
3180
1587
|
var StepExecutionSubscriber = class {
|
|
3181
1588
|
emitter;
|
|
3182
1589
|
registry;
|
|
3183
|
-
|
|
1590
|
+
module;
|
|
3184
1591
|
workerId;
|
|
3185
1592
|
maxConcurrent;
|
|
3186
1593
|
handlerTimeoutMs;
|
|
@@ -3193,13 +1600,13 @@ var StepExecutionSubscriber = class {
|
|
|
3193
1600
|
*
|
|
3194
1601
|
* @param emitter - The event emitter to subscribe to (required, no fallback)
|
|
3195
1602
|
* @param registry - The handler registry for resolving step handlers
|
|
3196
|
-
* @param
|
|
1603
|
+
* @param module - The napi-rs module for submitting results (required, no fallback)
|
|
3197
1604
|
* @param config - Optional configuration for execution behavior
|
|
3198
1605
|
*/
|
|
3199
|
-
constructor(emitter, registry,
|
|
1606
|
+
constructor(emitter, registry, module, config = {}) {
|
|
3200
1607
|
this.emitter = emitter;
|
|
3201
1608
|
this.registry = registry;
|
|
3202
|
-
this.
|
|
1609
|
+
this.module = module;
|
|
3203
1610
|
this.workerId = config.workerId ?? `typescript-worker-${process.pid}`;
|
|
3204
1611
|
this.maxConcurrent = config.maxConcurrent ?? 10;
|
|
3205
1612
|
this.handlerTimeoutMs = config.handlerTimeoutMs ?? 3e5;
|
|
@@ -3236,8 +1643,8 @@ var StepExecutionSubscriber = class {
|
|
|
3236
1643
|
pinoLog.info(
|
|
3237
1644
|
{
|
|
3238
1645
|
component: "subscriber",
|
|
3239
|
-
eventId: payload.event.
|
|
3240
|
-
stepUuid: payload.event.
|
|
1646
|
+
eventId: payload.event.eventId,
|
|
1647
|
+
stepUuid: payload.event.stepUuid
|
|
3241
1648
|
},
|
|
3242
1649
|
"Received step event in subscriber callback!"
|
|
3243
1650
|
);
|
|
@@ -3337,7 +1744,7 @@ var StepExecutionSubscriber = class {
|
|
|
3337
1744
|
pinoLog.info(
|
|
3338
1745
|
{
|
|
3339
1746
|
component: "subscriber",
|
|
3340
|
-
eventId: event.
|
|
1747
|
+
eventId: event.eventId,
|
|
3341
1748
|
running: this.running,
|
|
3342
1749
|
activeHandlers: this.activeHandlers,
|
|
3343
1750
|
maxConcurrent: this.maxConcurrent
|
|
@@ -3346,7 +1753,7 @@ var StepExecutionSubscriber = class {
|
|
|
3346
1753
|
);
|
|
3347
1754
|
if (!this.running) {
|
|
3348
1755
|
pinoLog.warn(
|
|
3349
|
-
{ component: "subscriber", eventId: event.
|
|
1756
|
+
{ component: "subscriber", eventId: event.eventId },
|
|
3350
1757
|
"Received event while stopped, ignoring"
|
|
3351
1758
|
);
|
|
3352
1759
|
return;
|
|
@@ -3363,14 +1770,14 @@ var StepExecutionSubscriber = class {
|
|
|
3363
1770
|
return;
|
|
3364
1771
|
}
|
|
3365
1772
|
pinoLog.info(
|
|
3366
|
-
{ component: "subscriber", eventId: event.
|
|
1773
|
+
{ component: "subscriber", eventId: event.eventId },
|
|
3367
1774
|
"About to call processEvent()"
|
|
3368
1775
|
);
|
|
3369
1776
|
this.processEvent(event).catch((error) => {
|
|
3370
1777
|
pinoLog.error(
|
|
3371
1778
|
{
|
|
3372
1779
|
component: "subscriber",
|
|
3373
|
-
eventId: event.
|
|
1780
|
+
eventId: event.eventId,
|
|
3374
1781
|
error: error instanceof Error ? error.message : String(error),
|
|
3375
1782
|
stack: error instanceof Error ? error.stack : void 0
|
|
3376
1783
|
},
|
|
@@ -3380,37 +1787,65 @@ var StepExecutionSubscriber = class {
|
|
|
3380
1787
|
}
|
|
3381
1788
|
/**
|
|
3382
1789
|
* Process a step execution event.
|
|
1790
|
+
*
|
|
1791
|
+
* All paths produce a StepHandlerResult — the handler's result or a
|
|
1792
|
+
* system-level failure. This mirrors Python's pattern where system errors
|
|
1793
|
+
* (handler not found, timeout, uncaught exception) become
|
|
1794
|
+
* StepHandlerResult.failure() with appropriate error_type and retryable.
|
|
3383
1795
|
*/
|
|
3384
1796
|
async processEvent(event) {
|
|
3385
|
-
pinoLog.info({ component: "subscriber", eventId: event.
|
|
1797
|
+
pinoLog.info({ component: "subscriber", eventId: event.eventId }, "processEvent() starting");
|
|
3386
1798
|
this.activeHandlers++;
|
|
3387
1799
|
const startTime = Date.now();
|
|
1800
|
+
const { handlerResult, handlerName, handlerWasInvoked } = await this.resolveAndExecuteHandler(event);
|
|
1801
|
+
const executionTimeMs = Date.now() - startTime;
|
|
1802
|
+
await this.submitResult(event, handlerResult, executionTimeMs);
|
|
1803
|
+
this.emitCompletionEvents(
|
|
1804
|
+
event,
|
|
1805
|
+
handlerResult,
|
|
1806
|
+
handlerName,
|
|
1807
|
+
executionTimeMs,
|
|
1808
|
+
handlerWasInvoked
|
|
1809
|
+
);
|
|
1810
|
+
this.activeHandlers--;
|
|
1811
|
+
}
|
|
1812
|
+
/**
|
|
1813
|
+
* Resolve handler from registry and execute it, returning a StepHandlerResult.
|
|
1814
|
+
*
|
|
1815
|
+
* System-level failures (no handler name, handler not found, uncaught exception)
|
|
1816
|
+
* are converted to StepHandlerResult.failure() with appropriate error_type and
|
|
1817
|
+
* retryable — the caller always gets a result, never an exception.
|
|
1818
|
+
*/
|
|
1819
|
+
async resolveAndExecuteHandler(event) {
|
|
1820
|
+
let handlerName = null;
|
|
3388
1821
|
try {
|
|
3389
|
-
|
|
1822
|
+
handlerName = this.extractHandlerName(event);
|
|
3390
1823
|
pinoLog.info(
|
|
3391
|
-
{ component: "subscriber", eventId: event.
|
|
1824
|
+
{ component: "subscriber", eventId: event.eventId, handlerName },
|
|
3392
1825
|
"Extracted handler name"
|
|
3393
1826
|
);
|
|
3394
1827
|
if (!handlerName) {
|
|
3395
1828
|
pinoLog.error(
|
|
3396
|
-
{ component: "subscriber", eventId: event.
|
|
1829
|
+
{ component: "subscriber", eventId: event.eventId },
|
|
3397
1830
|
"No handler name found!"
|
|
3398
1831
|
);
|
|
3399
|
-
|
|
3400
|
-
|
|
1832
|
+
return {
|
|
1833
|
+
handlerResult: StepHandlerResult.failure(
|
|
1834
|
+
"No handler name found in step definition",
|
|
1835
|
+
"permanent_error" /* PERMANENT_ERROR */,
|
|
1836
|
+
false
|
|
1837
|
+
),
|
|
1838
|
+
handlerName,
|
|
1839
|
+
handlerWasInvoked: false
|
|
1840
|
+
};
|
|
3401
1841
|
}
|
|
3402
1842
|
pinoLog.info(
|
|
3403
|
-
{
|
|
3404
|
-
component: "subscriber",
|
|
3405
|
-
eventId: event.event_id,
|
|
3406
|
-
stepUuid: event.step_uuid,
|
|
3407
|
-
handlerName
|
|
3408
|
-
},
|
|
1843
|
+
{ component: "subscriber", eventId: event.eventId, stepUuid: event.stepUuid, handlerName },
|
|
3409
1844
|
"Processing step event"
|
|
3410
1845
|
);
|
|
3411
1846
|
this.emitter.emit(StepEventNames.STEP_EXECUTION_STARTED, {
|
|
3412
|
-
eventId: event.
|
|
3413
|
-
stepUuid: event.
|
|
1847
|
+
eventId: event.eventId,
|
|
1848
|
+
stepUuid: event.stepUuid,
|
|
3414
1849
|
handlerName,
|
|
3415
1850
|
timestamp: /* @__PURE__ */ new Date()
|
|
3416
1851
|
});
|
|
@@ -3422,64 +1857,80 @@ var StepExecutionSubscriber = class {
|
|
|
3422
1857
|
);
|
|
3423
1858
|
if (!handler) {
|
|
3424
1859
|
pinoLog.error({ component: "subscriber", handlerName }, "Handler not found in registry!");
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
{ component: "subscriber", handlerName },
|
|
3432
|
-
"StepContext created, executing handler"
|
|
3433
|
-
);
|
|
3434
|
-
const result = await this.executeWithTimeout(
|
|
3435
|
-
() => handler.call(context),
|
|
3436
|
-
this.handlerTimeoutMs
|
|
3437
|
-
);
|
|
3438
|
-
pinoLog.info(
|
|
3439
|
-
{ component: "subscriber", handlerName, success: result.success },
|
|
3440
|
-
"Handler execution completed"
|
|
3441
|
-
);
|
|
3442
|
-
const executionTimeMs = Date.now() - startTime;
|
|
3443
|
-
await this.submitResult(event, result, executionTimeMs);
|
|
3444
|
-
if (result.success) {
|
|
3445
|
-
this.emitter.emit(StepEventNames.STEP_EXECUTION_COMPLETED, {
|
|
3446
|
-
eventId: event.event_id,
|
|
3447
|
-
stepUuid: event.step_uuid,
|
|
3448
|
-
handlerName,
|
|
3449
|
-
executionTimeMs,
|
|
3450
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
3451
|
-
});
|
|
3452
|
-
} else {
|
|
3453
|
-
this.emitter.emit(StepEventNames.STEP_EXECUTION_FAILED, {
|
|
3454
|
-
eventId: event.event_id,
|
|
3455
|
-
stepUuid: event.step_uuid,
|
|
1860
|
+
return {
|
|
1861
|
+
handlerResult: StepHandlerResult.failure(
|
|
1862
|
+
`Handler not found: ${handlerName}`,
|
|
1863
|
+
"handler_not_found",
|
|
1864
|
+
false
|
|
1865
|
+
),
|
|
3456
1866
|
handlerName,
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
3460
|
-
});
|
|
1867
|
+
handlerWasInvoked: false
|
|
1868
|
+
};
|
|
3461
1869
|
}
|
|
3462
|
-
this.
|
|
1870
|
+
return await this.invokeHandler(event, handler, handlerName);
|
|
3463
1871
|
} catch (error) {
|
|
3464
|
-
this.errorCount++;
|
|
3465
1872
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1873
|
+
const errorTypeName = error instanceof Error ? error.constructor.name : "Error";
|
|
3466
1874
|
logError("Handler execution failed", {
|
|
3467
1875
|
component: "subscriber",
|
|
3468
|
-
event_id: event.
|
|
3469
|
-
step_uuid: event.
|
|
1876
|
+
event_id: event.eventId,
|
|
1877
|
+
step_uuid: event.stepUuid,
|
|
3470
1878
|
error_message: errorMessage
|
|
3471
1879
|
});
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
1880
|
+
return {
|
|
1881
|
+
handlerResult: StepHandlerResult.failure(errorMessage, errorTypeName, true, {
|
|
1882
|
+
traceback: error instanceof Error ? error.stack : void 0
|
|
1883
|
+
}),
|
|
1884
|
+
handlerName,
|
|
1885
|
+
handlerWasInvoked: false
|
|
1886
|
+
};
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
/**
|
|
1890
|
+
* Create context and invoke the handler, returning its result.
|
|
1891
|
+
*
|
|
1892
|
+
* handlerWasInvoked is true only if the handler returned (not threw).
|
|
1893
|
+
*/
|
|
1894
|
+
async invokeHandler(event, handler, handlerName) {
|
|
1895
|
+
pinoLog.info({ component: "subscriber", handlerName }, "Creating StepContext from FFI event");
|
|
1896
|
+
const context = StepContext.fromFfiEvent(event, handlerName);
|
|
1897
|
+
pinoLog.info(
|
|
1898
|
+
{ component: "subscriber", handlerName },
|
|
1899
|
+
"StepContext created, executing handler"
|
|
1900
|
+
);
|
|
1901
|
+
const handlerResult = await this.executeWithTimeout(
|
|
1902
|
+
() => handler.call(context),
|
|
1903
|
+
this.handlerTimeoutMs
|
|
1904
|
+
);
|
|
1905
|
+
pinoLog.info(
|
|
1906
|
+
{ component: "subscriber", handlerName, success: handlerResult.success },
|
|
1907
|
+
"Handler execution completed"
|
|
1908
|
+
);
|
|
1909
|
+
return { handlerResult, handlerName, handlerWasInvoked: true };
|
|
1910
|
+
}
|
|
1911
|
+
/**
|
|
1912
|
+
* Update counters and emit observability events after step completion.
|
|
1913
|
+
*
|
|
1914
|
+
* A handler returning failure() is still "processed" — the handler ran and
|
|
1915
|
+
* gave a definitive answer. Only system-level errors (handler not found,
|
|
1916
|
+
* timeout, uncaught exception) count as "errors".
|
|
1917
|
+
*/
|
|
1918
|
+
emitCompletionEvents(event, handlerResult, handlerName, executionTimeMs, handlerWasInvoked) {
|
|
1919
|
+
const name = handlerName ?? "unknown";
|
|
1920
|
+
if (handlerResult.success || handlerWasInvoked) {
|
|
1921
|
+
this.processedCount++;
|
|
1922
|
+
} else {
|
|
1923
|
+
this.errorCount++;
|
|
3482
1924
|
}
|
|
1925
|
+
const eventName = handlerResult.success ? StepEventNames.STEP_EXECUTION_COMPLETED : StepEventNames.STEP_EXECUTION_FAILED;
|
|
1926
|
+
this.emitter.emit(eventName, {
|
|
1927
|
+
eventId: event.eventId,
|
|
1928
|
+
stepUuid: event.stepUuid,
|
|
1929
|
+
handlerName: name,
|
|
1930
|
+
...handlerResult.success ? {} : { error: handlerResult.errorMessage },
|
|
1931
|
+
executionTimeMs,
|
|
1932
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1933
|
+
});
|
|
3483
1934
|
}
|
|
3484
1935
|
/**
|
|
3485
1936
|
* Execute a function with a timeout.
|
|
@@ -3498,18 +1949,10 @@ var StepExecutionSubscriber = class {
|
|
|
3498
1949
|
/**
|
|
3499
1950
|
* Extract handler name from FFI event.
|
|
3500
1951
|
*
|
|
3501
|
-
*
|
|
1952
|
+
* TAS-290: With napi-rs, handler callable is flattened to stepDefinition.handlerCallable
|
|
3502
1953
|
*/
|
|
3503
1954
|
extractHandlerName(event) {
|
|
3504
|
-
|
|
3505
|
-
if (!stepDefinition) {
|
|
3506
|
-
return null;
|
|
3507
|
-
}
|
|
3508
|
-
const handler = stepDefinition.handler;
|
|
3509
|
-
if (!handler) {
|
|
3510
|
-
return null;
|
|
3511
|
-
}
|
|
3512
|
-
return handler.callable || null;
|
|
1955
|
+
return event.stepDefinition?.handlerCallable || null;
|
|
3513
1956
|
}
|
|
3514
1957
|
/**
|
|
3515
1958
|
* Submit a handler result via FFI.
|
|
@@ -3518,23 +1961,13 @@ var StepExecutionSubscriber = class {
|
|
|
3518
1961
|
* instead of the normal completion path.
|
|
3519
1962
|
*/
|
|
3520
1963
|
async submitResult(event, result, executionTimeMs) {
|
|
3521
|
-
pinoLog.info(
|
|
3522
|
-
{ component: "subscriber", eventId: event.event_id, runtimeLoaded: this.runtime.isLoaded },
|
|
3523
|
-
"submitResult() called"
|
|
3524
|
-
);
|
|
3525
|
-
if (!this.runtime.isLoaded) {
|
|
3526
|
-
pinoLog.error(
|
|
3527
|
-
{ component: "subscriber", eventId: event.event_id },
|
|
3528
|
-
"Cannot submit result: runtime not loaded!"
|
|
3529
|
-
);
|
|
3530
|
-
return;
|
|
3531
|
-
}
|
|
1964
|
+
pinoLog.info({ component: "subscriber", eventId: event.eventId }, "submitResult() called");
|
|
3532
1965
|
if (result.metadata?.checkpoint_yield === true) {
|
|
3533
1966
|
await this.submitCheckpointYield(event, result);
|
|
3534
1967
|
return;
|
|
3535
1968
|
}
|
|
3536
|
-
const
|
|
3537
|
-
await this.sendCompletionViaFfi(event,
|
|
1969
|
+
const serdeResult = this.buildStepExecutionResult(event, result, executionTimeMs);
|
|
1970
|
+
await this.sendCompletionViaFfi(event, serdeResult, result.success);
|
|
3538
1971
|
}
|
|
3539
1972
|
/**
|
|
3540
1973
|
* TAS-125: Submit a checkpoint yield via FFI.
|
|
@@ -3544,165 +1977,139 @@ var StepExecutionSubscriber = class {
|
|
|
3544
1977
|
*/
|
|
3545
1978
|
async submitCheckpointYield(event, result) {
|
|
3546
1979
|
pinoLog.info(
|
|
3547
|
-
{ component: "subscriber", eventId: event.
|
|
1980
|
+
{ component: "subscriber", eventId: event.eventId },
|
|
3548
1981
|
"submitCheckpointYield() called - handler yielded checkpoint"
|
|
3549
1982
|
);
|
|
3550
1983
|
const resultData = result.result ?? {};
|
|
3551
1984
|
const checkpointData = {
|
|
3552
|
-
|
|
1985
|
+
stepUuid: event.stepUuid,
|
|
3553
1986
|
cursor: resultData.cursor ?? 0,
|
|
3554
|
-
|
|
1987
|
+
itemsProcessed: resultData.items_processed ?? 0
|
|
3555
1988
|
};
|
|
3556
1989
|
const accumulatedResults = resultData.accumulated_results;
|
|
3557
1990
|
if (accumulatedResults !== void 0) {
|
|
3558
|
-
checkpointData.
|
|
1991
|
+
checkpointData.accumulatedResults = accumulatedResults;
|
|
3559
1992
|
}
|
|
3560
1993
|
try {
|
|
3561
|
-
const success = this.
|
|
1994
|
+
const success = this.module.checkpointYieldStepEvent(event.eventId, checkpointData);
|
|
3562
1995
|
if (success) {
|
|
3563
1996
|
pinoLog.info(
|
|
3564
1997
|
{
|
|
3565
1998
|
component: "subscriber",
|
|
3566
|
-
eventId: event.
|
|
1999
|
+
eventId: event.eventId,
|
|
3567
2000
|
cursor: checkpointData.cursor,
|
|
3568
|
-
itemsProcessed: checkpointData.
|
|
2001
|
+
itemsProcessed: checkpointData.itemsProcessed
|
|
3569
2002
|
},
|
|
3570
2003
|
"Checkpoint yield submitted successfully - step will be re-dispatched"
|
|
3571
2004
|
);
|
|
3572
2005
|
this.emitter.emit(StepEventNames.STEP_CHECKPOINT_YIELD_SENT, {
|
|
3573
|
-
eventId: event.
|
|
3574
|
-
stepUuid: event.
|
|
2006
|
+
eventId: event.eventId,
|
|
2007
|
+
stepUuid: event.stepUuid,
|
|
3575
2008
|
cursor: checkpointData.cursor,
|
|
3576
|
-
itemsProcessed: checkpointData.
|
|
2009
|
+
itemsProcessed: checkpointData.itemsProcessed,
|
|
3577
2010
|
timestamp: /* @__PURE__ */ new Date()
|
|
3578
2011
|
});
|
|
3579
2012
|
logInfo("Checkpoint yield submitted", {
|
|
3580
2013
|
component: "subscriber",
|
|
3581
|
-
event_id: event.
|
|
3582
|
-
step_uuid: event.
|
|
2014
|
+
event_id: event.eventId,
|
|
2015
|
+
step_uuid: event.stepUuid,
|
|
3583
2016
|
cursor: String(checkpointData.cursor),
|
|
3584
|
-
items_processed: String(checkpointData.
|
|
2017
|
+
items_processed: String(checkpointData.itemsProcessed)
|
|
3585
2018
|
});
|
|
3586
2019
|
} else {
|
|
3587
2020
|
pinoLog.error(
|
|
3588
|
-
{ component: "subscriber", eventId: event.
|
|
2021
|
+
{ component: "subscriber", eventId: event.eventId },
|
|
3589
2022
|
"Checkpoint yield rejected by Rust - event may not be in pending map"
|
|
3590
2023
|
);
|
|
3591
2024
|
logError("Checkpoint yield rejected", {
|
|
3592
2025
|
component: "subscriber",
|
|
3593
|
-
event_id: event.
|
|
3594
|
-
step_uuid: event.
|
|
2026
|
+
event_id: event.eventId,
|
|
2027
|
+
step_uuid: event.stepUuid
|
|
3595
2028
|
});
|
|
3596
2029
|
}
|
|
3597
2030
|
} catch (error) {
|
|
3598
2031
|
pinoLog.error(
|
|
3599
2032
|
{
|
|
3600
2033
|
component: "subscriber",
|
|
3601
|
-
eventId: event.
|
|
2034
|
+
eventId: event.eventId,
|
|
3602
2035
|
error: error instanceof Error ? error.message : String(error)
|
|
3603
2036
|
},
|
|
3604
2037
|
"Checkpoint yield failed with error"
|
|
3605
2038
|
);
|
|
3606
2039
|
logError("Failed to submit checkpoint yield", {
|
|
3607
2040
|
component: "subscriber",
|
|
3608
|
-
event_id: event.
|
|
2041
|
+
event_id: event.eventId,
|
|
3609
2042
|
error_message: error instanceof Error ? error.message : String(error)
|
|
3610
2043
|
});
|
|
3611
2044
|
}
|
|
3612
2045
|
}
|
|
3613
2046
|
/**
|
|
3614
|
-
*
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
event_id: event.event_id
|
|
3621
|
-
});
|
|
3622
|
-
return;
|
|
3623
|
-
}
|
|
3624
|
-
const executionTimeMs = Date.now() - startTime;
|
|
3625
|
-
const executionResult = this.buildErrorExecutionResult(event, errorMessage, executionTimeMs);
|
|
3626
|
-
const accepted = await this.sendCompletionViaFfi(event, executionResult, false);
|
|
3627
|
-
if (accepted) {
|
|
3628
|
-
this.errorCount++;
|
|
3629
|
-
}
|
|
3630
|
-
}
|
|
3631
|
-
/**
|
|
3632
|
-
* Build a StepExecutionResult from a handler result.
|
|
2047
|
+
* Build a NapiStepExecutionResult from a StepHandlerResult.
|
|
2048
|
+
*
|
|
2049
|
+
* The subscriber's only job here is to WRAP the handler result with
|
|
2050
|
+
* execution metadata (timing, worker_id, step_uuid). All handler decisions
|
|
2051
|
+
* (success, retryable, errorType, errorCode, orchestrationMetadata) are
|
|
2052
|
+
* passed through faithfully — the subscriber does not re-interpret them.
|
|
3633
2053
|
*
|
|
3634
|
-
*
|
|
2054
|
+
* This mirrors Python's _submit_result() which calls
|
|
2055
|
+
* StepExecutionResult.success_result() or .failure_result() passing
|
|
2056
|
+
* handler fields straight through.
|
|
2057
|
+
*
|
|
2058
|
+
* napi-rs #[napi(object)] maps Option<T> to `?: T`. With
|
|
2059
|
+
* exactOptionalPropertyTypes, optional props must be OMITTED (not null
|
|
2060
|
+
* or undefined) — hence the conditional spread pattern.
|
|
3635
2061
|
*/
|
|
3636
|
-
|
|
3637
|
-
const
|
|
3638
|
-
|
|
2062
|
+
buildStepExecutionResult(event, result, executionTimeMs) {
|
|
2063
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2064
|
+
const metadata = {
|
|
2065
|
+
executionTimeMs,
|
|
2066
|
+
completedAt: now,
|
|
2067
|
+
...this.workerId != null && { workerId: this.workerId },
|
|
2068
|
+
...Object.keys(result.metadata).length > 0 && { custom: result.metadata },
|
|
2069
|
+
// Pass through handler's classification — subscriber doesn't interpret these
|
|
2070
|
+
...result.retryable != null && { retryable: result.retryable },
|
|
2071
|
+
...result.errorType != null && { errorType: result.errorType },
|
|
2072
|
+
...result.errorCode != null && { errorCode: result.errorCode }
|
|
2073
|
+
};
|
|
2074
|
+
const napiResult = {
|
|
2075
|
+
stepUuid: event.stepUuid,
|
|
3639
2076
|
success: result.success,
|
|
3640
2077
|
result: result.result ?? {},
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
worker_id: this.workerId,
|
|
3644
|
-
handler_name: this.extractHandlerName(event) ?? "unknown",
|
|
3645
|
-
attempt_number: event.workflow_step?.attempts ?? 1,
|
|
3646
|
-
retryable: result.retryable ?? false,
|
|
3647
|
-
...result.metadata
|
|
3648
|
-
},
|
|
3649
|
-
status: result.success ? "completed" : "failed"
|
|
2078
|
+
status: result.success ? "completed" : "failed",
|
|
2079
|
+
metadata
|
|
3650
2080
|
};
|
|
3651
2081
|
if (!result.success) {
|
|
3652
|
-
|
|
2082
|
+
napiResult.error = {
|
|
3653
2083
|
message: result.errorMessage ?? "Unknown error",
|
|
3654
|
-
|
|
3655
|
-
retryable: result.retryable
|
|
3656
|
-
status_code: null,
|
|
3657
|
-
backtrace: null
|
|
2084
|
+
...result.errorType != null && { errorType: result.errorType },
|
|
2085
|
+
...result.retryable != null && { retryable: result.retryable }
|
|
3658
2086
|
};
|
|
3659
2087
|
}
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
*
|
|
3665
|
-
* IMPORTANT: metadata.retryable must be set for Rust's is_retryable() to work correctly.
|
|
3666
|
-
*/
|
|
3667
|
-
buildErrorExecutionResult(event, errorMessage, executionTimeMs) {
|
|
3668
|
-
return {
|
|
3669
|
-
step_uuid: event.step_uuid,
|
|
3670
|
-
success: false,
|
|
3671
|
-
result: {},
|
|
3672
|
-
metadata: {
|
|
3673
|
-
execution_time_ms: executionTimeMs,
|
|
3674
|
-
worker_id: this.workerId,
|
|
3675
|
-
retryable: true
|
|
3676
|
-
},
|
|
3677
|
-
status: "error",
|
|
3678
|
-
error: {
|
|
3679
|
-
message: errorMessage,
|
|
3680
|
-
error_type: "handler_error",
|
|
3681
|
-
retryable: true,
|
|
3682
|
-
status_code: null,
|
|
3683
|
-
backtrace: null
|
|
3684
|
-
}
|
|
3685
|
-
};
|
|
2088
|
+
if (result.orchestrationMetadata != null) {
|
|
2089
|
+
napiResult.orchestrationMetadata = result.orchestrationMetadata;
|
|
2090
|
+
}
|
|
2091
|
+
return napiResult;
|
|
3686
2092
|
}
|
|
3687
2093
|
/**
|
|
3688
2094
|
* Send a completion result to Rust via FFI and handle the response.
|
|
3689
2095
|
*
|
|
3690
2096
|
* @returns true if the completion was accepted by Rust, false otherwise
|
|
3691
2097
|
*/
|
|
3692
|
-
async sendCompletionViaFfi(event,
|
|
2098
|
+
async sendCompletionViaFfi(event, napiResult, isSuccess) {
|
|
3693
2099
|
pinoLog.info(
|
|
3694
2100
|
{
|
|
3695
2101
|
component: "subscriber",
|
|
3696
|
-
eventId: event.
|
|
3697
|
-
stepUuid: event.
|
|
3698
|
-
|
|
2102
|
+
eventId: event.eventId,
|
|
2103
|
+
stepUuid: event.stepUuid,
|
|
2104
|
+
success: napiResult.success,
|
|
2105
|
+
status: napiResult.status
|
|
3699
2106
|
},
|
|
3700
|
-
"About to call
|
|
2107
|
+
"About to call module.completeStepEvent()"
|
|
3701
2108
|
);
|
|
3702
2109
|
try {
|
|
3703
|
-
const ffiResult = this.
|
|
2110
|
+
const ffiResult = this.module.completeStepEvent(event.eventId, napiResult);
|
|
3704
2111
|
if (ffiResult) {
|
|
3705
|
-
this.handleFfiSuccess(event,
|
|
2112
|
+
this.handleFfiSuccess(event, isSuccess);
|
|
3706
2113
|
return true;
|
|
3707
2114
|
}
|
|
3708
2115
|
this.handleFfiRejection(event);
|
|
@@ -3715,23 +2122,22 @@ var StepExecutionSubscriber = class {
|
|
|
3715
2122
|
/**
|
|
3716
2123
|
* Handle successful FFI completion submission.
|
|
3717
2124
|
*/
|
|
3718
|
-
handleFfiSuccess(event,
|
|
2125
|
+
handleFfiSuccess(event, isSuccess) {
|
|
3719
2126
|
pinoLog.info(
|
|
3720
|
-
{ component: "subscriber", eventId: event.
|
|
2127
|
+
{ component: "subscriber", eventId: event.eventId, success: isSuccess },
|
|
3721
2128
|
"completeStepEvent() returned TRUE - completion accepted by Rust"
|
|
3722
2129
|
);
|
|
3723
2130
|
this.emitter.emit(StepEventNames.STEP_COMPLETION_SENT, {
|
|
3724
|
-
eventId: event.
|
|
3725
|
-
stepUuid: event.
|
|
2131
|
+
eventId: event.eventId,
|
|
2132
|
+
stepUuid: event.stepUuid,
|
|
3726
2133
|
success: isSuccess,
|
|
3727
2134
|
timestamp: /* @__PURE__ */ new Date()
|
|
3728
2135
|
});
|
|
3729
2136
|
logDebug("Step result submitted", {
|
|
3730
2137
|
component: "subscriber",
|
|
3731
|
-
event_id: event.
|
|
3732
|
-
step_uuid: event.
|
|
3733
|
-
success: String(isSuccess)
|
|
3734
|
-
execution_time_ms: String(executionResult.metadata.execution_time_ms)
|
|
2138
|
+
event_id: event.eventId,
|
|
2139
|
+
step_uuid: event.stepUuid,
|
|
2140
|
+
success: String(isSuccess)
|
|
3735
2141
|
});
|
|
3736
2142
|
}
|
|
3737
2143
|
/**
|
|
@@ -3741,15 +2147,15 @@ var StepExecutionSubscriber = class {
|
|
|
3741
2147
|
pinoLog.error(
|
|
3742
2148
|
{
|
|
3743
2149
|
component: "subscriber",
|
|
3744
|
-
eventId: event.
|
|
3745
|
-
stepUuid: event.
|
|
2150
|
+
eventId: event.eventId,
|
|
2151
|
+
stepUuid: event.stepUuid
|
|
3746
2152
|
},
|
|
3747
2153
|
"completeStepEvent() returned FALSE - completion REJECTED by Rust! Event may not be in pending map."
|
|
3748
2154
|
);
|
|
3749
2155
|
logError("FFI completion rejected", {
|
|
3750
2156
|
component: "subscriber",
|
|
3751
|
-
event_id: event.
|
|
3752
|
-
step_uuid: event.
|
|
2157
|
+
event_id: event.eventId,
|
|
2158
|
+
step_uuid: event.stepUuid
|
|
3753
2159
|
});
|
|
3754
2160
|
}
|
|
3755
2161
|
/**
|
|
@@ -3759,7 +2165,7 @@ var StepExecutionSubscriber = class {
|
|
|
3759
2165
|
pinoLog.error(
|
|
3760
2166
|
{
|
|
3761
2167
|
component: "subscriber",
|
|
3762
|
-
eventId: event.
|
|
2168
|
+
eventId: event.eventId,
|
|
3763
2169
|
error: error instanceof Error ? error.message : String(error),
|
|
3764
2170
|
stack: error instanceof Error ? error.stack : void 0
|
|
3765
2171
|
},
|
|
@@ -3767,7 +2173,7 @@ var StepExecutionSubscriber = class {
|
|
|
3767
2173
|
);
|
|
3768
2174
|
logError("Failed to submit step result", {
|
|
3769
2175
|
component: "subscriber",
|
|
3770
|
-
event_id: event.
|
|
2176
|
+
event_id: event.eventId,
|
|
3771
2177
|
error_message: error instanceof Error ? error.message : String(error)
|
|
3772
2178
|
});
|
|
3773
2179
|
}
|
|
@@ -3793,17 +2199,17 @@ var EventSystem = class {
|
|
|
3793
2199
|
/**
|
|
3794
2200
|
* Create a new EventSystem.
|
|
3795
2201
|
*
|
|
3796
|
-
* @param
|
|
2202
|
+
* @param module - The napi-rs module for polling events and submitting results
|
|
3797
2203
|
* @param registry - The handler registry for resolving step handlers
|
|
3798
2204
|
* @param config - Optional configuration for poller and subscriber
|
|
3799
2205
|
*/
|
|
3800
|
-
constructor(
|
|
2206
|
+
constructor(module, registry, config = {}) {
|
|
3801
2207
|
this.emitter = new TaskerEventEmitter();
|
|
3802
|
-
this.poller = new EventPoller(
|
|
2208
|
+
this.poller = new EventPoller(module, this.emitter, config.poller);
|
|
3803
2209
|
this.subscriber = new StepExecutionSubscriber(
|
|
3804
2210
|
this.emitter,
|
|
3805
2211
|
registry,
|
|
3806
|
-
|
|
2212
|
+
module,
|
|
3807
2213
|
config.subscriber
|
|
3808
2214
|
);
|
|
3809
2215
|
}
|
|
@@ -3833,11 +2239,11 @@ var EventSystem = class {
|
|
|
3833
2239
|
{
|
|
3834
2240
|
component: "event-system",
|
|
3835
2241
|
debugListener: true,
|
|
3836
|
-
eventId: payload.event?.
|
|
3837
|
-
stepUuid: payload.event?.
|
|
2242
|
+
eventId: payload.event?.eventId,
|
|
2243
|
+
stepUuid: payload.event?.stepUuid,
|
|
3838
2244
|
eventName: StepEventNames.STEP_EXECUTION_RECEIVED
|
|
3839
2245
|
},
|
|
3840
|
-
|
|
2246
|
+
`DEBUG LISTENER: Received ${StepEventNames.STEP_EXECUTION_RECEIVED} event!`
|
|
3841
2247
|
);
|
|
3842
2248
|
}
|
|
3843
2249
|
);
|
|
@@ -3916,407 +2322,131 @@ var EventSystem = class {
|
|
|
3916
2322
|
};
|
|
3917
2323
|
}
|
|
3918
2324
|
};
|
|
3919
|
-
|
|
3920
|
-
// src/ffi/bun-runtime.ts
|
|
3921
|
-
init_node_runtime();
|
|
3922
|
-
var BunRuntime = class extends NodeRuntime {
|
|
3923
|
-
name = "bun";
|
|
3924
|
-
};
|
|
3925
|
-
|
|
3926
|
-
// src/ffi/index.ts
|
|
3927
|
-
init_deno_runtime();
|
|
3928
|
-
|
|
3929
|
-
// src/ffi/runtime.ts
|
|
3930
|
-
var cachedRuntimeType = null;
|
|
3931
|
-
function detectRuntime() {
|
|
3932
|
-
if (cachedRuntimeType !== null) {
|
|
3933
|
-
return cachedRuntimeType;
|
|
3934
|
-
}
|
|
3935
|
-
if (typeof globalThis !== "undefined" && "Bun" in globalThis) {
|
|
3936
|
-
cachedRuntimeType = "bun";
|
|
3937
|
-
return "bun";
|
|
3938
|
-
}
|
|
3939
|
-
if (typeof globalThis !== "undefined" && "Deno" in globalThis) {
|
|
3940
|
-
cachedRuntimeType = "deno";
|
|
3941
|
-
return "deno";
|
|
3942
|
-
}
|
|
3943
|
-
if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
|
3944
|
-
cachedRuntimeType = "node";
|
|
3945
|
-
return "node";
|
|
3946
|
-
}
|
|
3947
|
-
cachedRuntimeType = "unknown";
|
|
3948
|
-
return "unknown";
|
|
3949
|
-
}
|
|
3950
|
-
function isBun() {
|
|
3951
|
-
return detectRuntime() === "bun";
|
|
3952
|
-
}
|
|
3953
|
-
function isNode() {
|
|
3954
|
-
return detectRuntime() === "node";
|
|
3955
|
-
}
|
|
3956
|
-
function isDeno() {
|
|
3957
|
-
return detectRuntime() === "deno";
|
|
3958
|
-
}
|
|
3959
|
-
function getRuntimeInfo() {
|
|
3960
|
-
const type = detectRuntime();
|
|
3961
|
-
switch (type) {
|
|
3962
|
-
case "bun": {
|
|
3963
|
-
const Bun = globalThis.Bun;
|
|
3964
|
-
return {
|
|
3965
|
-
type: "bun",
|
|
3966
|
-
version: Bun?.version ?? "unknown",
|
|
3967
|
-
platform: process?.platform ?? "unknown",
|
|
3968
|
-
arch: process?.arch ?? "unknown"
|
|
3969
|
-
};
|
|
3970
|
-
}
|
|
3971
|
-
case "deno": {
|
|
3972
|
-
const Deno2 = globalThis.Deno;
|
|
3973
|
-
return {
|
|
3974
|
-
type: "deno",
|
|
3975
|
-
version: Deno2?.version?.deno ?? "unknown",
|
|
3976
|
-
platform: Deno2?.build?.os ?? "unknown",
|
|
3977
|
-
arch: Deno2?.build?.arch ?? "unknown"
|
|
3978
|
-
};
|
|
3979
|
-
}
|
|
3980
|
-
case "node":
|
|
3981
|
-
return {
|
|
3982
|
-
type: "node",
|
|
3983
|
-
version: process.versions.node,
|
|
3984
|
-
platform: process.platform,
|
|
3985
|
-
arch: process.arch
|
|
3986
|
-
};
|
|
3987
|
-
default:
|
|
3988
|
-
return {
|
|
3989
|
-
type: "unknown",
|
|
3990
|
-
version: "unknown",
|
|
3991
|
-
platform: "unknown",
|
|
3992
|
-
arch: "unknown"
|
|
3993
|
-
};
|
|
3994
|
-
}
|
|
3995
|
-
}
|
|
3996
|
-
function getLibraryFilename() {
|
|
3997
|
-
const platform = process?.platform ?? "unknown";
|
|
3998
|
-
switch (platform) {
|
|
3999
|
-
case "darwin":
|
|
4000
|
-
return "libtasker_ts.dylib";
|
|
4001
|
-
case "linux":
|
|
4002
|
-
return "libtasker_ts.so";
|
|
4003
|
-
case "win32":
|
|
4004
|
-
return "tasker_ts.dll";
|
|
4005
|
-
default:
|
|
4006
|
-
throw new Error(`Unsupported platform: ${platform}`);
|
|
4007
|
-
}
|
|
4008
|
-
}
|
|
4009
|
-
function getLibraryPath(basePath) {
|
|
4010
|
-
const envPath = process.env.TASKER_FFI_LIBRARY_PATH;
|
|
4011
|
-
if (envPath) {
|
|
4012
|
-
return envPath;
|
|
4013
|
-
}
|
|
4014
|
-
if (basePath) {
|
|
4015
|
-
return `${basePath}/${getLibraryFilename()}`;
|
|
4016
|
-
}
|
|
4017
|
-
throw new Error(
|
|
4018
|
-
"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"
|
|
4019
|
-
);
|
|
4020
|
-
}
|
|
4021
|
-
|
|
4022
|
-
// src/ffi/ffi-layer.ts
|
|
4023
2325
|
var FfiLayer = class _FfiLayer {
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
configuredLibraryPath;
|
|
4028
|
-
/**
|
|
4029
|
-
* Create a new FfiLayer.
|
|
4030
|
-
*
|
|
4031
|
-
* @param config - Optional configuration for runtime type and library path
|
|
4032
|
-
*/
|
|
2326
|
+
module = null;
|
|
2327
|
+
modulePath = null;
|
|
2328
|
+
configuredModulePath;
|
|
4033
2329
|
constructor(config = {}) {
|
|
4034
|
-
this.
|
|
4035
|
-
this.configuredLibraryPath = config.libraryPath;
|
|
2330
|
+
this.configuredModulePath = config.modulePath;
|
|
4036
2331
|
}
|
|
4037
2332
|
/**
|
|
4038
|
-
* Load the
|
|
4039
|
-
*
|
|
4040
|
-
* Discovers and loads the native library for the current runtime.
|
|
2333
|
+
* Load the napi-rs native module.
|
|
4041
2334
|
*
|
|
4042
|
-
* @param customPath - Optional override for
|
|
4043
|
-
* @throws Error if
|
|
2335
|
+
* @param customPath - Optional override for module path
|
|
2336
|
+
* @throws Error if module not found or failed to load
|
|
4044
2337
|
*/
|
|
4045
2338
|
async load(customPath) {
|
|
4046
|
-
if (this.
|
|
2339
|
+
if (this.module) {
|
|
4047
2340
|
return;
|
|
4048
2341
|
}
|
|
4049
|
-
const
|
|
4050
|
-
if (!
|
|
2342
|
+
const path = customPath ?? this.configuredModulePath ?? this.discoverModulePath();
|
|
2343
|
+
if (!path) {
|
|
4051
2344
|
throw new Error(
|
|
4052
|
-
`
|
|
2345
|
+
`napi-rs native module not found. No bundled .node file matches this platform, and TASKER_FFI_MODULE_PATH is not set.
|
|
4053
2346
|
Current platform: ${process.platform}-${process.arch}
|
|
4054
|
-
Supported: linux-x64,
|
|
4055
|
-
Override: export
|
|
2347
|
+
Supported: linux-x64, darwin-arm64
|
|
2348
|
+
Override: export TASKER_FFI_MODULE_PATH=/path/to/tasker_ts.linux-x64-gnu.node`
|
|
4056
2349
|
);
|
|
4057
2350
|
}
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
this.
|
|
2351
|
+
const nativeModule = __require(path);
|
|
2352
|
+
this.module = nativeModule;
|
|
2353
|
+
this.modulePath = path;
|
|
4061
2354
|
}
|
|
4062
2355
|
/**
|
|
4063
|
-
* Unload the
|
|
4064
|
-
*
|
|
4065
|
-
* Safe to call even if not loaded.
|
|
2356
|
+
* Unload the native module and release resources.
|
|
4066
2357
|
*/
|
|
4067
2358
|
async unload() {
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
}
|
|
4071
|
-
this.runtime = null;
|
|
4072
|
-
this.libraryPath = null;
|
|
2359
|
+
this.module = null;
|
|
2360
|
+
this.modulePath = null;
|
|
4073
2361
|
}
|
|
4074
2362
|
/**
|
|
4075
|
-
* Check if the
|
|
2363
|
+
* Check if the native module is loaded.
|
|
4076
2364
|
*/
|
|
4077
2365
|
isLoaded() {
|
|
4078
|
-
return this.
|
|
2366
|
+
return this.module !== null;
|
|
4079
2367
|
}
|
|
4080
2368
|
/**
|
|
4081
|
-
* Get the loaded
|
|
2369
|
+
* Get the loaded napi-rs module.
|
|
4082
2370
|
*
|
|
4083
|
-
* @throws Error if
|
|
2371
|
+
* @throws Error if module is not loaded
|
|
4084
2372
|
*/
|
|
4085
|
-
|
|
4086
|
-
if (!this.
|
|
2373
|
+
getModule() {
|
|
2374
|
+
if (!this.module) {
|
|
4087
2375
|
throw new Error("FFI not loaded. Call load() first.");
|
|
4088
2376
|
}
|
|
4089
|
-
return this.
|
|
2377
|
+
return this.module;
|
|
4090
2378
|
}
|
|
4091
2379
|
/**
|
|
4092
|
-
*
|
|
2380
|
+
* Backward-compatible alias for getModule().
|
|
2381
|
+
*
|
|
2382
|
+
* @deprecated Use getModule() instead
|
|
4093
2383
|
*/
|
|
4094
|
-
|
|
4095
|
-
return this.
|
|
2384
|
+
getRuntime() {
|
|
2385
|
+
return this.getModule();
|
|
4096
2386
|
}
|
|
4097
2387
|
/**
|
|
4098
|
-
* Get the
|
|
2388
|
+
* Get the path to the loaded module.
|
|
4099
2389
|
*/
|
|
4100
|
-
|
|
4101
|
-
return this.
|
|
2390
|
+
getModulePath() {
|
|
2391
|
+
return this.modulePath;
|
|
4102
2392
|
}
|
|
4103
2393
|
/**
|
|
4104
|
-
* Find the
|
|
4105
|
-
*
|
|
4106
|
-
* Static method for finding the library path without creating an instance.
|
|
4107
|
-
* Useful for test utilities and pre-flight checks.
|
|
2394
|
+
* Find the napi-rs module path.
|
|
4108
2395
|
*
|
|
4109
2396
|
* Resolution order:
|
|
4110
|
-
* 1.
|
|
4111
|
-
* 2. Bundled
|
|
4112
|
-
*
|
|
4113
|
-
* @param _callerDir Deprecated parameter, kept for API compatibility
|
|
4114
|
-
* @returns Path to the library if found and exists, null otherwise
|
|
2397
|
+
* 1. TASKER_FFI_MODULE_PATH environment variable (explicit override, for unusual setups)
|
|
2398
|
+
* 2. Bundled .node file in package directory (standard path — `napi build --platform` places it here)
|
|
4115
2399
|
*/
|
|
4116
|
-
static
|
|
4117
|
-
const envPath = process.env.
|
|
2400
|
+
static findModulePath() {
|
|
2401
|
+
const envPath = process.env.TASKER_FFI_MODULE_PATH;
|
|
4118
2402
|
if (envPath) {
|
|
4119
2403
|
if (!existsSync(envPath)) {
|
|
4120
|
-
console.warn(`
|
|
2404
|
+
console.warn(`TASKER_FFI_MODULE_PATH is set to "${envPath}" but the file does not exist`);
|
|
4121
2405
|
return null;
|
|
4122
2406
|
}
|
|
4123
2407
|
return envPath;
|
|
4124
2408
|
}
|
|
4125
|
-
const bundledPath =
|
|
2409
|
+
const bundledPath = findBundledNodeModule();
|
|
4126
2410
|
if (bundledPath && existsSync(bundledPath)) {
|
|
4127
2411
|
return bundledPath;
|
|
4128
2412
|
}
|
|
4129
2413
|
return null;
|
|
4130
2414
|
}
|
|
4131
2415
|
/**
|
|
4132
|
-
*
|
|
2416
|
+
* Backward-compatible alias for findModulePath().
|
|
4133
2417
|
*
|
|
4134
|
-
*
|
|
2418
|
+
* @deprecated Use findModulePath() instead
|
|
4135
2419
|
*/
|
|
4136
|
-
|
|
4137
|
-
return _FfiLayer.
|
|
2420
|
+
static findLibraryPath(_callerDir) {
|
|
2421
|
+
return _FfiLayer.findModulePath();
|
|
4138
2422
|
}
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
*
|
|
4142
|
-
* NOTE: We use koffi (NodeRuntime) for both Node.js and Bun because:
|
|
4143
|
-
* - bun:ffi is experimental with known bugs (per Bun docs)
|
|
4144
|
-
* - koffi is stable and works with both Node.js and Bun via Node-API
|
|
4145
|
-
* - See: https://bun.sh/docs/runtime/node-api
|
|
4146
|
-
*/
|
|
4147
|
-
async createRuntime() {
|
|
4148
|
-
switch (this.runtimeType) {
|
|
4149
|
-
case "bun":
|
|
4150
|
-
case "node": {
|
|
4151
|
-
const { NodeRuntime: NodeRuntime2 } = await Promise.resolve().then(() => (init_node_runtime(), node_runtime_exports));
|
|
4152
|
-
return new NodeRuntime2();
|
|
4153
|
-
}
|
|
4154
|
-
case "deno": {
|
|
4155
|
-
const { DenoRuntime: DenoRuntime2 } = await Promise.resolve().then(() => (init_deno_runtime(), deno_runtime_exports));
|
|
4156
|
-
return new DenoRuntime2();
|
|
4157
|
-
}
|
|
4158
|
-
default:
|
|
4159
|
-
throw new Error(
|
|
4160
|
-
`Unsupported runtime: ${this.runtimeType}. Tasker TypeScript worker requires Bun, Node.js, or Deno.`
|
|
4161
|
-
);
|
|
4162
|
-
}
|
|
2423
|
+
discoverModulePath() {
|
|
2424
|
+
return _FfiLayer.findModulePath();
|
|
4163
2425
|
}
|
|
4164
2426
|
};
|
|
4165
|
-
var
|
|
4166
|
-
"linux-x64": "
|
|
4167
|
-
"
|
|
4168
|
-
"darwin-
|
|
2427
|
+
var BUNDLED_NODE_MODULES = {
|
|
2428
|
+
"linux-x64": "tasker_ts.linux-x64-gnu.node",
|
|
2429
|
+
"darwin-arm64": "tasker_ts.darwin-arm64.node",
|
|
2430
|
+
"darwin-x64": "tasker_ts.darwin-x64.node"
|
|
4169
2431
|
};
|
|
4170
|
-
function
|
|
2432
|
+
function findBundledNodeModule() {
|
|
4171
2433
|
const key = `${process.platform}-${process.arch}`;
|
|
4172
|
-
const
|
|
4173
|
-
if (!
|
|
2434
|
+
const filename = BUNDLED_NODE_MODULES[key];
|
|
2435
|
+
if (!filename) {
|
|
4174
2436
|
return null;
|
|
4175
2437
|
}
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
// src/types/error-type.ts
|
|
4186
|
-
var ErrorType = /* @__PURE__ */ ((ErrorType2) => {
|
|
4187
|
-
ErrorType2["PERMANENT_ERROR"] = "permanent_error";
|
|
4188
|
-
ErrorType2["RETRYABLE_ERROR"] = "retryable_error";
|
|
4189
|
-
ErrorType2["VALIDATION_ERROR"] = "validation_error";
|
|
4190
|
-
ErrorType2["TIMEOUT"] = "timeout";
|
|
4191
|
-
ErrorType2["HANDLER_ERROR"] = "handler_error";
|
|
4192
|
-
return ErrorType2;
|
|
4193
|
-
})(ErrorType || {});
|
|
4194
|
-
function isStandardErrorType(errorType) {
|
|
4195
|
-
return Object.values(ErrorType).includes(errorType);
|
|
4196
|
-
}
|
|
4197
|
-
function isTypicallyRetryable(errorType) {
|
|
4198
|
-
return ["retryable_error" /* RETRYABLE_ERROR */, "timeout" /* TIMEOUT */].includes(errorType);
|
|
4199
|
-
}
|
|
4200
|
-
|
|
4201
|
-
// src/types/step-handler-result.ts
|
|
4202
|
-
var StepHandlerResult = class _StepHandlerResult {
|
|
4203
|
-
/** Whether the handler executed successfully */
|
|
4204
|
-
success;
|
|
4205
|
-
/** Handler output data (success case) */
|
|
4206
|
-
result;
|
|
4207
|
-
/** Error message (failure case) */
|
|
4208
|
-
errorMessage;
|
|
4209
|
-
/** Error type/category for classification */
|
|
4210
|
-
errorType;
|
|
4211
|
-
/** Optional application-specific error code */
|
|
4212
|
-
errorCode;
|
|
4213
|
-
/** Whether the error is retryable */
|
|
4214
|
-
retryable;
|
|
4215
|
-
/** Additional execution metadata */
|
|
4216
|
-
metadata;
|
|
4217
|
-
constructor(params) {
|
|
4218
|
-
this.success = params.success;
|
|
4219
|
-
this.result = params.result ?? null;
|
|
4220
|
-
this.errorMessage = params.errorMessage ?? null;
|
|
4221
|
-
this.errorType = params.errorType ?? null;
|
|
4222
|
-
this.errorCode = params.errorCode ?? null;
|
|
4223
|
-
this.retryable = params.retryable ?? true;
|
|
4224
|
-
this.metadata = params.metadata ?? {};
|
|
4225
|
-
}
|
|
4226
|
-
/**
|
|
4227
|
-
* Create a successful handler result.
|
|
4228
|
-
*
|
|
4229
|
-
* This is the primary factory method for creating success results.
|
|
4230
|
-
* Aligned with Ruby and Python worker APIs.
|
|
4231
|
-
*
|
|
4232
|
-
* @param result - The handler output data
|
|
4233
|
-
* @param metadata - Optional additional metadata
|
|
4234
|
-
* @returns A StepHandlerResult indicating success
|
|
4235
|
-
*
|
|
4236
|
-
* @example
|
|
4237
|
-
* ```typescript
|
|
4238
|
-
* return StepHandlerResult.success(
|
|
4239
|
-
* { processed: 100, skipped: 5 }
|
|
4240
|
-
* );
|
|
4241
|
-
* ```
|
|
4242
|
-
*/
|
|
4243
|
-
static success(result, metadata) {
|
|
4244
|
-
return new _StepHandlerResult({
|
|
4245
|
-
success: true,
|
|
4246
|
-
result,
|
|
4247
|
-
metadata: metadata ?? {}
|
|
4248
|
-
});
|
|
4249
|
-
}
|
|
4250
|
-
/**
|
|
4251
|
-
* Create a failure handler result.
|
|
4252
|
-
*
|
|
4253
|
-
* @param message - Human-readable error message
|
|
4254
|
-
* @param errorType - Error type/category for classification. Use ErrorType enum.
|
|
4255
|
-
* @param retryable - Whether the error is retryable (default: true)
|
|
4256
|
-
* @param metadata - Optional additional metadata
|
|
4257
|
-
* @param errorCode - Optional application-specific error code
|
|
4258
|
-
* @returns A StepHandlerResult indicating failure
|
|
4259
|
-
*
|
|
4260
|
-
* @example
|
|
4261
|
-
* ```typescript
|
|
4262
|
-
* return StepHandlerResult.failure(
|
|
4263
|
-
* 'Invalid input format',
|
|
4264
|
-
* ErrorType.VALIDATION_ERROR,
|
|
4265
|
-
* false
|
|
4266
|
-
* );
|
|
4267
|
-
* ```
|
|
4268
|
-
*
|
|
4269
|
-
* @example With error code
|
|
4270
|
-
* ```typescript
|
|
4271
|
-
* return StepHandlerResult.failure(
|
|
4272
|
-
* 'Gateway timeout',
|
|
4273
|
-
* ErrorType.TIMEOUT,
|
|
4274
|
-
* true,
|
|
4275
|
-
* { duration_ms: 30000 },
|
|
4276
|
-
* 'GATEWAY_TIMEOUT'
|
|
4277
|
-
* );
|
|
4278
|
-
* ```
|
|
4279
|
-
*/
|
|
4280
|
-
static failure(message, errorType = "handler_error" /* HANDLER_ERROR */, retryable = true, metadata, errorCode) {
|
|
4281
|
-
return new _StepHandlerResult({
|
|
4282
|
-
success: false,
|
|
4283
|
-
errorMessage: message,
|
|
4284
|
-
// ErrorType enum values are already strings, so this works directly
|
|
4285
|
-
errorType,
|
|
4286
|
-
errorCode: errorCode ?? null,
|
|
4287
|
-
retryable,
|
|
4288
|
-
metadata: metadata ?? {}
|
|
4289
|
-
});
|
|
4290
|
-
}
|
|
4291
|
-
/**
|
|
4292
|
-
* Check if this result indicates success.
|
|
4293
|
-
*/
|
|
4294
|
-
isSuccess() {
|
|
4295
|
-
return this.success;
|
|
4296
|
-
}
|
|
4297
|
-
/**
|
|
4298
|
-
* Check if this result indicates failure.
|
|
4299
|
-
*/
|
|
4300
|
-
isFailure() {
|
|
4301
|
-
return !this.success;
|
|
4302
|
-
}
|
|
4303
|
-
/**
|
|
4304
|
-
* Convert to JSON for serialization.
|
|
4305
|
-
*
|
|
4306
|
-
* Uses snake_case keys to match the Rust FFI contract.
|
|
4307
|
-
*/
|
|
4308
|
-
toJSON() {
|
|
4309
|
-
return {
|
|
4310
|
-
success: this.success,
|
|
4311
|
-
result: this.result,
|
|
4312
|
-
error_message: this.errorMessage,
|
|
4313
|
-
error_type: this.errorType,
|
|
4314
|
-
error_code: this.errorCode,
|
|
4315
|
-
retryable: this.retryable,
|
|
4316
|
-
metadata: this.metadata
|
|
4317
|
-
};
|
|
2438
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
2439
|
+
for (let i = 0; i < 5; i++) {
|
|
2440
|
+
const candidate = join(dir, filename);
|
|
2441
|
+
if (existsSync(candidate)) return candidate;
|
|
2442
|
+
const nativeCandidate = join(dir, "native", filename);
|
|
2443
|
+
if (existsSync(nativeCandidate)) return nativeCandidate;
|
|
2444
|
+
const parent = dirname(dir);
|
|
2445
|
+
if (parent === dir) break;
|
|
2446
|
+
dir = parent;
|
|
4318
2447
|
}
|
|
4319
|
-
|
|
2448
|
+
return null;
|
|
2449
|
+
}
|
|
4320
2450
|
|
|
4321
2451
|
// src/handler/base.ts
|
|
4322
2452
|
var StepHandler = class {
|
|
@@ -4532,8 +2662,8 @@ var APIMixin = class {
|
|
|
4532
2662
|
/**
|
|
4533
2663
|
* Make a GET request.
|
|
4534
2664
|
*/
|
|
4535
|
-
async get(
|
|
4536
|
-
const url = this.buildUrl(
|
|
2665
|
+
async get(path, params, headers) {
|
|
2666
|
+
const url = this.buildUrl(path, params);
|
|
4537
2667
|
return this.fetch(url, {
|
|
4538
2668
|
method: "GET",
|
|
4539
2669
|
headers: this.mergeHeaders(headers)
|
|
@@ -4542,8 +2672,8 @@ var APIMixin = class {
|
|
|
4542
2672
|
/**
|
|
4543
2673
|
* Make a POST request.
|
|
4544
2674
|
*/
|
|
4545
|
-
async post(
|
|
4546
|
-
const url = this.buildUrl(
|
|
2675
|
+
async post(path, options) {
|
|
2676
|
+
const url = this.buildUrl(path);
|
|
4547
2677
|
const body = this.prepareBody(options?.body, options?.json !== false);
|
|
4548
2678
|
return this.fetch(url, {
|
|
4549
2679
|
method: "POST",
|
|
@@ -4554,8 +2684,8 @@ var APIMixin = class {
|
|
|
4554
2684
|
/**
|
|
4555
2685
|
* Make a PUT request.
|
|
4556
2686
|
*/
|
|
4557
|
-
async put(
|
|
4558
|
-
const url = this.buildUrl(
|
|
2687
|
+
async put(path, options) {
|
|
2688
|
+
const url = this.buildUrl(path);
|
|
4559
2689
|
const body = this.prepareBody(options?.body, options?.json !== false);
|
|
4560
2690
|
return this.fetch(url, {
|
|
4561
2691
|
method: "PUT",
|
|
@@ -4566,8 +2696,8 @@ var APIMixin = class {
|
|
|
4566
2696
|
/**
|
|
4567
2697
|
* Make a PATCH request.
|
|
4568
2698
|
*/
|
|
4569
|
-
async patch(
|
|
4570
|
-
const url = this.buildUrl(
|
|
2699
|
+
async patch(path, options) {
|
|
2700
|
+
const url = this.buildUrl(path);
|
|
4571
2701
|
const body = this.prepareBody(options?.body, options?.json !== false);
|
|
4572
2702
|
return this.fetch(url, {
|
|
4573
2703
|
method: "PATCH",
|
|
@@ -4578,8 +2708,8 @@ var APIMixin = class {
|
|
|
4578
2708
|
/**
|
|
4579
2709
|
* Make a DELETE request.
|
|
4580
2710
|
*/
|
|
4581
|
-
async delete(
|
|
4582
|
-
const url = this.buildUrl(
|
|
2711
|
+
async delete(path, headers) {
|
|
2712
|
+
const url = this.buildUrl(path);
|
|
4583
2713
|
return this.fetch(url, {
|
|
4584
2714
|
method: "DELETE",
|
|
4585
2715
|
headers: this.mergeHeaders(headers)
|
|
@@ -4588,8 +2718,8 @@ var APIMixin = class {
|
|
|
4588
2718
|
/**
|
|
4589
2719
|
* Make an arbitrary HTTP request.
|
|
4590
2720
|
*/
|
|
4591
|
-
async request(method,
|
|
4592
|
-
const url = this.buildUrl(
|
|
2721
|
+
async request(method, path, options) {
|
|
2722
|
+
const url = this.buildUrl(path);
|
|
4593
2723
|
return this.fetch(url, {
|
|
4594
2724
|
...options,
|
|
4595
2725
|
method,
|
|
@@ -4681,8 +2811,8 @@ var APIMixin = class {
|
|
|
4681
2811
|
clearTimeout(timeoutId);
|
|
4682
2812
|
}
|
|
4683
2813
|
}
|
|
4684
|
-
buildUrl(
|
|
4685
|
-
let url = this.baseUrl +
|
|
2814
|
+
buildUrl(path, params) {
|
|
2815
|
+
let url = this.baseUrl + path;
|
|
4686
2816
|
if (params) {
|
|
4687
2817
|
const searchParams = new URLSearchParams();
|
|
4688
2818
|
for (const [key, value] of Object.entries(params)) {
|
|
@@ -4854,23 +2984,23 @@ var ApiHandler = class extends StepHandler {
|
|
|
4854
2984
|
// =========================================================================
|
|
4855
2985
|
// HTTP Methods - Delegate to mixin
|
|
4856
2986
|
// =========================================================================
|
|
4857
|
-
get(
|
|
4858
|
-
return this.getApiMixin().get(
|
|
2987
|
+
get(path, params, headers) {
|
|
2988
|
+
return this.getApiMixin().get(path, params, headers);
|
|
4859
2989
|
}
|
|
4860
|
-
post(
|
|
4861
|
-
return this.getApiMixin().post(
|
|
2990
|
+
post(path, options) {
|
|
2991
|
+
return this.getApiMixin().post(path, options);
|
|
4862
2992
|
}
|
|
4863
|
-
put(
|
|
4864
|
-
return this.getApiMixin().put(
|
|
2993
|
+
put(path, options) {
|
|
2994
|
+
return this.getApiMixin().put(path, options);
|
|
4865
2995
|
}
|
|
4866
|
-
patch(
|
|
4867
|
-
return this.getApiMixin().patch(
|
|
2996
|
+
patch(path, options) {
|
|
2997
|
+
return this.getApiMixin().patch(path, options);
|
|
4868
2998
|
}
|
|
4869
|
-
delete(
|
|
4870
|
-
return this.getApiMixin().delete(
|
|
2999
|
+
delete(path, headers) {
|
|
3000
|
+
return this.getApiMixin().delete(path, headers);
|
|
4871
3001
|
}
|
|
4872
|
-
request(method,
|
|
4873
|
-
return this.getApiMixin().request(method,
|
|
3002
|
+
request(method, path, options) {
|
|
3003
|
+
return this.getApiMixin().request(method, path, options);
|
|
4874
3004
|
}
|
|
4875
3005
|
// =========================================================================
|
|
4876
3006
|
// Result Helpers - Delegate to mixin
|
|
@@ -6573,9 +4703,9 @@ function ffiEventToDomainEvent(ffiEvent) {
|
|
|
6573
4703
|
}
|
|
6574
4704
|
};
|
|
6575
4705
|
}
|
|
6576
|
-
function createFfiPollAdapter(
|
|
4706
|
+
function createFfiPollAdapter(module) {
|
|
6577
4707
|
return () => {
|
|
6578
|
-
const ffiEvent =
|
|
4708
|
+
const ffiEvent = module.pollInProcessEvents();
|
|
6579
4709
|
if (ffiEvent === null) {
|
|
6580
4710
|
return null;
|
|
6581
4711
|
}
|
|
@@ -7282,21 +5412,21 @@ var HandlerSystem = class {
|
|
|
7282
5412
|
* @param path - Path to directory containing handlers
|
|
7283
5413
|
* @returns Number of handlers loaded
|
|
7284
5414
|
*/
|
|
7285
|
-
async loadFromPath(
|
|
7286
|
-
if (!existsSync(
|
|
7287
|
-
log5.warn(`Handler path does not exist: ${
|
|
5415
|
+
async loadFromPath(path) {
|
|
5416
|
+
if (!existsSync(path)) {
|
|
5417
|
+
log5.warn(`Handler path does not exist: ${path}`, { operation: "load_from_path" });
|
|
7288
5418
|
return 0;
|
|
7289
5419
|
}
|
|
7290
|
-
log5.info(`Loading handlers from: ${
|
|
5420
|
+
log5.info(`Loading handlers from: ${path}`, { operation: "load_from_path" });
|
|
7291
5421
|
try {
|
|
7292
|
-
const indexResult = await this.tryImportIndexFile(
|
|
5422
|
+
const indexResult = await this.tryImportIndexFile(path);
|
|
7293
5423
|
if (indexResult.module) {
|
|
7294
5424
|
return this.registerHandlersFromModule(indexResult.module, indexResult.path);
|
|
7295
5425
|
}
|
|
7296
5426
|
log5.debug("No index file found, scanning for handler files...", {
|
|
7297
5427
|
operation: "load_from_path"
|
|
7298
5428
|
});
|
|
7299
|
-
return this.scanAndImportHandlers(
|
|
5429
|
+
return this.scanAndImportHandlers(path);
|
|
7300
5430
|
} catch (error) {
|
|
7301
5431
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
7302
5432
|
log5.error(`Failed to load handlers from path: ${errorMessage}`, {
|
|
@@ -7473,8 +5603,8 @@ var HandlerSystem = class {
|
|
|
7473
5603
|
];
|
|
7474
5604
|
for (const indexPath of indexPaths) {
|
|
7475
5605
|
if (existsSync(indexPath)) {
|
|
7476
|
-
const
|
|
7477
|
-
return { module
|
|
5606
|
+
const module = await import(`file://${indexPath}`);
|
|
5607
|
+
return { module, path: indexPath };
|
|
7478
5608
|
}
|
|
7479
5609
|
}
|
|
7480
5610
|
return { module: null, path: null };
|
|
@@ -7482,12 +5612,12 @@ var HandlerSystem = class {
|
|
|
7482
5612
|
/**
|
|
7483
5613
|
* Register handlers from a module's exports.
|
|
7484
5614
|
*/
|
|
7485
|
-
registerHandlersFromModule(
|
|
5615
|
+
registerHandlersFromModule(module, importPath) {
|
|
7486
5616
|
log5.info(`Loaded handler module from: ${importPath}`, { operation: "import_handlers" });
|
|
7487
|
-
if (Array.isArray(
|
|
7488
|
-
return this.registerFromHandlerArray(
|
|
5617
|
+
if (Array.isArray(module.ALL_EXAMPLE_HANDLERS)) {
|
|
5618
|
+
return this.registerFromHandlerArray(module.ALL_EXAMPLE_HANDLERS);
|
|
7489
5619
|
}
|
|
7490
|
-
return this.registerFromModuleExports(
|
|
5620
|
+
return this.registerFromModuleExports(module);
|
|
7491
5621
|
}
|
|
7492
5622
|
/**
|
|
7493
5623
|
* Register handlers from ALL_EXAMPLE_HANDLERS array.
|
|
@@ -7508,9 +5638,9 @@ var HandlerSystem = class {
|
|
|
7508
5638
|
/**
|
|
7509
5639
|
* Register handlers from module exports.
|
|
7510
5640
|
*/
|
|
7511
|
-
registerFromModuleExports(
|
|
5641
|
+
registerFromModuleExports(module) {
|
|
7512
5642
|
let count = 0;
|
|
7513
|
-
for (const [exportName, exported] of Object.entries(
|
|
5643
|
+
for (const [exportName, exported] of Object.entries(module)) {
|
|
7514
5644
|
if (this.isValidHandlerClass(exported)) {
|
|
7515
5645
|
this.registry.register(exported.handlerName, exported);
|
|
7516
5646
|
count++;
|
|
@@ -7577,8 +5707,8 @@ var HandlerSystem = class {
|
|
|
7577
5707
|
async importHandlerFile(fullPath) {
|
|
7578
5708
|
let count = 0;
|
|
7579
5709
|
try {
|
|
7580
|
-
const
|
|
7581
|
-
for (const [, exported] of Object.entries(
|
|
5710
|
+
const module = await import(`file://${fullPath}`);
|
|
5711
|
+
for (const [, exported] of Object.entries(module)) {
|
|
7582
5712
|
if (this.isValidHandlerClass(exported)) {
|
|
7583
5713
|
this.registry.register(exported.handlerName, exported);
|
|
7584
5714
|
count++;
|
|
@@ -7787,7 +5917,7 @@ var WorkerServer = class {
|
|
|
7787
5917
|
log7.info("WorkerServer started successfully", {
|
|
7788
5918
|
operation: "start",
|
|
7789
5919
|
worker_id: this.workerId,
|
|
7790
|
-
version: getVersion(this.ffiLayer.
|
|
5920
|
+
version: getVersion(this.ffiLayer.getModule())
|
|
7791
5921
|
});
|
|
7792
5922
|
return this;
|
|
7793
5923
|
} catch (error) {
|
|
@@ -7830,14 +5960,14 @@ var WorkerServer = class {
|
|
|
7830
5960
|
this.eventSystem = null;
|
|
7831
5961
|
log7.info(" Event system stopped", { operation: "shutdown" });
|
|
7832
5962
|
}
|
|
7833
|
-
const
|
|
7834
|
-
if (isWorkerRunning(
|
|
5963
|
+
const module = this.ffiLayer.isLoaded() ? this.ffiLayer.getModule() : void 0;
|
|
5964
|
+
if (isWorkerRunning(module)) {
|
|
7835
5965
|
log7.info(" Transitioning to graceful shutdown...", {
|
|
7836
5966
|
operation: "shutdown"
|
|
7837
5967
|
});
|
|
7838
|
-
transitionToGracefulShutdown(
|
|
5968
|
+
transitionToGracefulShutdown(module);
|
|
7839
5969
|
log7.info(" Stopping Rust worker...", { operation: "shutdown" });
|
|
7840
|
-
stopWorker(
|
|
5970
|
+
stopWorker(module);
|
|
7841
5971
|
log7.info(" Rust worker stopped", { operation: "shutdown" });
|
|
7842
5972
|
}
|
|
7843
5973
|
log7.info(" Unloading FFI...", { operation: "shutdown" });
|
|
@@ -7891,12 +6021,12 @@ var WorkerServer = class {
|
|
|
7891
6021
|
};
|
|
7892
6022
|
}
|
|
7893
6023
|
try {
|
|
7894
|
-
const
|
|
7895
|
-
const ffiHealthy = healthCheck(
|
|
6024
|
+
const module = this.ffiLayer.isLoaded() ? this.ffiLayer.getModule() : void 0;
|
|
6025
|
+
const ffiHealthy = healthCheck(module);
|
|
7896
6026
|
if (!ffiHealthy) {
|
|
7897
6027
|
return { healthy: false, error: "FFI health check failed" };
|
|
7898
6028
|
}
|
|
7899
|
-
const workerStatus = getWorkerStatus(
|
|
6029
|
+
const workerStatus = getWorkerStatus(module);
|
|
7900
6030
|
if (!workerStatus.running) {
|
|
7901
6031
|
return { healthy: false, error: "Worker not running" };
|
|
7902
6032
|
}
|
|
@@ -7939,10 +6069,10 @@ var WorkerServer = class {
|
|
|
7939
6069
|
});
|
|
7940
6070
|
log7.info("Loading FFI library...", { operation: "initialize" });
|
|
7941
6071
|
await this.ffiLayer.load(this.config?.libraryPath);
|
|
7942
|
-
log7.info(`FFI library loaded: ${this.ffiLayer.
|
|
6072
|
+
log7.info(`FFI library loaded: ${this.ffiLayer.getModulePath()}`, {
|
|
7943
6073
|
operation: "initialize"
|
|
7944
6074
|
});
|
|
7945
|
-
setLoggingRuntime(this.ffiLayer.
|
|
6075
|
+
setLoggingRuntime(this.ffiLayer.getModule());
|
|
7946
6076
|
const totalHandlers = this.handlerSystem.handlerCount();
|
|
7947
6077
|
if (totalHandlers > 0) {
|
|
7948
6078
|
log7.info(`Handler registry: ${totalHandlers} handlers registered`, {
|
|
@@ -7975,8 +6105,8 @@ var WorkerServer = class {
|
|
|
7975
6105
|
bootstrapConfig.databaseUrl = databaseUrl;
|
|
7976
6106
|
}
|
|
7977
6107
|
log7.info("Bootstrapping Rust worker...", { operation: "bootstrap" });
|
|
7978
|
-
const
|
|
7979
|
-
const result = await bootstrapWorker(bootstrapConfig,
|
|
6108
|
+
const module = this.ffiLayer.getModule();
|
|
6109
|
+
const result = await bootstrapWorker(bootstrapConfig, module);
|
|
7980
6110
|
if (!result.success) {
|
|
7981
6111
|
throw new Error(`Bootstrap failed: ${result.message}`);
|
|
7982
6112
|
}
|
|
@@ -7989,7 +6119,7 @@ var WorkerServer = class {
|
|
|
7989
6119
|
log7.info("Starting event processing system...", {
|
|
7990
6120
|
operation: "start_events"
|
|
7991
6121
|
});
|
|
7992
|
-
const
|
|
6122
|
+
const module = this.ffiLayer.getModule();
|
|
7993
6123
|
const eventConfig = {
|
|
7994
6124
|
poller: {
|
|
7995
6125
|
pollIntervalMs: this.config?.pollIntervalMs ?? 10,
|
|
@@ -8008,7 +6138,7 @@ var WorkerServer = class {
|
|
|
8008
6138
|
workerId: this.workerId
|
|
8009
6139
|
};
|
|
8010
6140
|
}
|
|
8011
|
-
this.eventSystem = new EventSystem(
|
|
6141
|
+
this.eventSystem = new EventSystem(module, this.handlerSystem.getRegistry(), eventConfig);
|
|
8012
6142
|
this.eventSystem.start();
|
|
8013
6143
|
log7.info("Event processing system started", {
|
|
8014
6144
|
operation: "start_events",
|
|
@@ -8024,8 +6154,9 @@ var WorkerServer = class {
|
|
|
8024
6154
|
await this.eventSystem.stop();
|
|
8025
6155
|
this.eventSystem = null;
|
|
8026
6156
|
}
|
|
8027
|
-
|
|
8028
|
-
|
|
6157
|
+
const module = this.ffiLayer.isLoaded() ? this.ffiLayer.getModule() : void 0;
|
|
6158
|
+
if (isWorkerRunning(module)) {
|
|
6159
|
+
stopWorker(module);
|
|
8029
6160
|
}
|
|
8030
6161
|
await this.ffiLayer.unload();
|
|
8031
6162
|
} catch {
|
|
@@ -8033,6 +6164,6 @@ var WorkerServer = class {
|
|
|
8033
6164
|
}
|
|
8034
6165
|
};
|
|
8035
6166
|
|
|
8036
|
-
export { APIMixin, ApiHandler, ApiResponse, BasePublisher, BaseSubscriber,
|
|
6167
|
+
export { APIMixin, ApiHandler, ApiResponse, BasePublisher, BaseSubscriber, BatchableMixin, ClassLookupResolver, DecisionHandler, DecisionMixin, DecisionType, DefaultPublisher, DuplicatePublisherError, ErrorType, EventNames, EventPoller, EventSystem, ExplicitMappingResolver, FfiLayer, HandlerRegistry, HandlerSystem, InProcessDomainEventPoller, MethodDispatchError, MethodDispatchWrapper, MetricsEventNames, NoResolverMatchError, PollerEventNames, PublisherNotFoundError, PublisherRegistry, PublisherValidationError, RegistryFrozenError, RegistryResolver, ResolutionError, ResolverChain, ResolverNotFoundError, ShutdownController, StepContext, StepEventNames, StepExecutionSubscriber, StepHandler, StepHandlerResult, SubscriberRegistry, TaskerClient, TaskerClientError, TaskerEventEmitter, WorkerEventNames, WorkerServer, aggregateBatchResults, applyAPI, applyBatchable, applyDecision, bootstrapWorker, createBatchWorkerContext, createBatches, createDomainEvent, createEventPoller, createFfiPollAdapter, createLogger, createStepEventContext, effectiveMethod, ffiEventToDomainEvent, fromCallable, fromDto, getRustVersion, getVersion, getWorkerStatus, hasResolverHint, healthCheck, isCreateBatches, isNoBatches, isStandardErrorType, isTypicallyRetryable, isWorkerRunning, logDebug, logError, logInfo, logTrace, logWarn, noBatches, normalizeToDefinition, stopWorker, transitionToGracefulShutdown, usesMethodDispatch };
|
|
8037
6168
|
//# sourceMappingURL=index.js.map
|
|
8038
6169
|
//# sourceMappingURL=index.js.map
|