@ironflow/node 0.1.0-test.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.js ADDED
@@ -0,0 +1,404 @@
1
+ /**
2
+ * Ironflow Worker Client
3
+ *
4
+ * Pull mode worker that polls the Ironflow server for jobs.
5
+ */
6
+ import { IronflowError, JobAssignmentSchema, createLogger, createNoopLogger, DEFAULT_SERVER_URL, DEFAULT_WORKER, } from "@ironflow/core";
7
+ import { ExecutionContext } from "./internal/context.js";
8
+ import { createStepClient } from "./step.js";
9
+ import { isYieldSignal } from "./internal/errors.js";
10
+ /**
11
+ * Create a worker for Pull mode execution
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { createWorker } from "@ironflow/node/worker";
16
+ *
17
+ * const worker = createWorker({
18
+ * serverUrl: "http://localhost:9123",
19
+ * functions: [myFunction],
20
+ * maxConcurrentJobs: 4,
21
+ * });
22
+ *
23
+ * await worker.start();
24
+ * ```
25
+ */
26
+ export function createWorker(config) {
27
+ return new IronflowWorker(config);
28
+ }
29
+ /**
30
+ * Worker implementation using REST HTTP polling
31
+ */
32
+ class IronflowWorker {
33
+ config;
34
+ functionMap;
35
+ workerId;
36
+ maxConcurrentJobs;
37
+ heartbeatInterval;
38
+ reconnectDelay;
39
+ logger;
40
+ state = "idle";
41
+ activeJobs = new Map();
42
+ heartbeatTimer;
43
+ abortController;
44
+ constructor(config) {
45
+ this.config = {
46
+ ...config,
47
+ serverUrl: config.serverUrl || DEFAULT_SERVER_URL,
48
+ };
49
+ this.workerId = generateWorkerId();
50
+ this.maxConcurrentJobs =
51
+ config.maxConcurrentJobs ?? DEFAULT_WORKER.MAX_CONCURRENT_JOBS;
52
+ this.heartbeatInterval =
53
+ config.heartbeatInterval ?? DEFAULT_WORKER.HEARTBEAT_INTERVAL_MS;
54
+ this.reconnectDelay =
55
+ config.reconnectDelay ?? DEFAULT_WORKER.RECONNECT_DELAY_MS;
56
+ // Initialize logger
57
+ if (config.logger === false) {
58
+ this.logger = createNoopLogger();
59
+ }
60
+ else if (config.logger) {
61
+ this.logger = config.logger;
62
+ }
63
+ else {
64
+ this.logger = createLogger({ prefix: "[ironflow-worker]" });
65
+ }
66
+ // Build function map
67
+ this.functionMap = new Map();
68
+ for (const fn of config.functions) {
69
+ this.functionMap.set(fn.config.id, fn);
70
+ }
71
+ }
72
+ /**
73
+ * Start the worker (blocks until stopped)
74
+ */
75
+ async start() {
76
+ if (this.state !== "idle") {
77
+ throw new IronflowError("Worker is already running", {
78
+ code: "WORKER_ALREADY_RUNNING",
79
+ });
80
+ }
81
+ this.state = "connecting";
82
+ this.abortController = new AbortController();
83
+ this.logger.info(`Starting worker ${this.workerId} with ${this.functionMap.size} functions`);
84
+ // Connect loop with auto-reconnect
85
+ // Use explicit type annotation to allow state changes from other methods
86
+ while (this.state !== "stopped") {
87
+ try {
88
+ await this.connect();
89
+ }
90
+ catch (error) {
91
+ if (this.state === "stopped") {
92
+ break;
93
+ }
94
+ this.logger.error("Connection error", { error: String(error) });
95
+ this.logger.info(`Reconnecting in ${this.reconnectDelay}ms...`);
96
+ await this.sleep(this.reconnectDelay);
97
+ }
98
+ }
99
+ this.logger.info("Worker stopped");
100
+ }
101
+ /**
102
+ * Gracefully drain and stop
103
+ */
104
+ async drain() {
105
+ if (this.state === "stopped" || this.state === "idle") {
106
+ return;
107
+ }
108
+ this.logger.info("Draining worker...");
109
+ this.state = "draining";
110
+ // Wait for active jobs to complete
111
+ while (this.activeJobs.size > 0) {
112
+ this.logger.info(`Waiting for ${this.activeJobs.size} jobs to complete...`);
113
+ await this.sleep(1000);
114
+ }
115
+ this.stop();
116
+ }
117
+ /**
118
+ * Force stop immediately
119
+ */
120
+ stop() {
121
+ this.state = "stopped";
122
+ this.abortController?.abort();
123
+ if (this.heartbeatTimer) {
124
+ clearInterval(this.heartbeatTimer);
125
+ this.heartbeatTimer = undefined;
126
+ }
127
+ // Cancel all active jobs
128
+ for (const job of this.activeJobs.values()) {
129
+ job.abortController.abort();
130
+ }
131
+ this.activeJobs.clear();
132
+ }
133
+ /**
134
+ * Establish connection to the Ironflow server
135
+ */
136
+ async connect() {
137
+ this.state = "connecting";
138
+ const baseUrl = this.config.serverUrl.replace(/\/$/, "");
139
+ // Register worker
140
+ await this.registerWorker(baseUrl);
141
+ this.state = "connected";
142
+ this.logger.info("Connected to server");
143
+ // Start heartbeat
144
+ this.startHeartbeat(baseUrl);
145
+ // Poll for jobs
146
+ await this.pollForJobs(baseUrl);
147
+ }
148
+ /**
149
+ * Register the worker with the Ironflow server
150
+ */
151
+ async registerWorker(baseUrl) {
152
+ const functionIds = Array.from(this.functionMap.keys());
153
+ const response = await fetch(`${baseUrl}/api/v1/workers/${this.workerId}/register`, {
154
+ method: "POST",
155
+ headers: { "Content-Type": "application/json" },
156
+ body: JSON.stringify({
157
+ worker_id: this.workerId,
158
+ hostname: getHostname(),
159
+ function_ids: functionIds,
160
+ max_concurrent_jobs: this.maxConcurrentJobs,
161
+ labels: this.config.labels ?? {},
162
+ version: {
163
+ sdk: "0.1.0",
164
+ runtime: `node-${process.version}`,
165
+ },
166
+ }),
167
+ signal: this.abortController?.signal,
168
+ });
169
+ if (!response.ok) {
170
+ throw new IronflowError("Failed to register worker", {
171
+ code: "REGISTRATION_FAILED",
172
+ });
173
+ }
174
+ }
175
+ /**
176
+ * Start the heartbeat interval
177
+ */
178
+ startHeartbeat(baseUrl) {
179
+ this.heartbeatTimer = setInterval(async () => {
180
+ if (this.state !== "connected") {
181
+ return;
182
+ }
183
+ try {
184
+ await fetch(`${baseUrl}/api/v1/workers/${this.workerId}/heartbeat`, {
185
+ method: "POST",
186
+ headers: { "Content-Type": "application/json" },
187
+ body: JSON.stringify({
188
+ worker_id: this.workerId,
189
+ active_jobs: this.activeJobs.size,
190
+ jobs: Array.from(this.activeJobs.values()).map((job) => ({
191
+ job_id: job.jobId,
192
+ started_at: job.startedAt.toISOString(),
193
+ })),
194
+ }),
195
+ signal: this.abortController?.signal,
196
+ });
197
+ }
198
+ catch (error) {
199
+ this.logger.warn("Heartbeat failed", { error: String(error) });
200
+ }
201
+ }, this.heartbeatInterval);
202
+ }
203
+ /**
204
+ * Continuously poll the server for available jobs
205
+ */
206
+ async pollForJobs(baseUrl) {
207
+ while (this.state === "connected") {
208
+ // Check capacity
209
+ if (this.activeJobs.size >= this.maxConcurrentJobs) {
210
+ await this.sleep(1000);
211
+ continue;
212
+ }
213
+ try {
214
+ // Request a job
215
+ const response = await fetch(`${baseUrl}/api/v1/workers/${this.workerId}/jobs`, {
216
+ method: "GET",
217
+ headers: { "Content-Type": "application/json" },
218
+ signal: this.abortController?.signal,
219
+ });
220
+ if (response.status === 204) {
221
+ // No jobs available
222
+ await this.sleep(1000);
223
+ continue;
224
+ }
225
+ if (!response.ok) {
226
+ throw new Error(`Failed to get job: ${response.status}`);
227
+ }
228
+ // Parse and validate job assignment
229
+ const rawJob = await response.json();
230
+ const result = JobAssignmentSchema.safeParse(rawJob);
231
+ if (!result.success) {
232
+ const issues = result.error.issues
233
+ .map((i) => `${i.path.join(".")}: ${i.message}`)
234
+ .join(", ");
235
+ this.logger.error(`Invalid job assignment: ${issues}`);
236
+ await this.sleep(1000);
237
+ continue;
238
+ }
239
+ // Process the validated job
240
+ this.processJob(baseUrl, result.data);
241
+ }
242
+ catch (error) {
243
+ if (this.state !== "connected") {
244
+ break;
245
+ }
246
+ this.logger.warn("Job polling error", { error: String(error) });
247
+ await this.sleep(5000);
248
+ }
249
+ }
250
+ }
251
+ /**
252
+ * Start processing a job asynchronously
253
+ */
254
+ processJob(baseUrl, job) {
255
+ const abortController = new AbortController();
256
+ const activeJob = {
257
+ jobId: job.job_id,
258
+ runId: job.run_id,
259
+ functionId: job.function_id,
260
+ startedAt: new Date(),
261
+ abortController,
262
+ };
263
+ this.activeJobs.set(job.job_id, activeJob);
264
+ // Execute in background
265
+ this.executeJob(baseUrl, job, abortController.signal)
266
+ .catch((error) => {
267
+ this.logger.error(`Job ${job.job_id} failed`, { error: String(error) });
268
+ })
269
+ .finally(() => {
270
+ this.activeJobs.delete(job.job_id);
271
+ });
272
+ }
273
+ /**
274
+ * Execute a job and report results
275
+ */
276
+ async executeJob(baseUrl, job, signal) {
277
+ const fn = this.functionMap.get(job.function_id);
278
+ if (!fn) {
279
+ await this.sendJobFailed(baseUrl, job.job_id, {
280
+ message: `Function not found: ${job.function_id}`,
281
+ code: "FUNCTION_NOT_FOUND",
282
+ retryable: false,
283
+ });
284
+ return;
285
+ }
286
+ this.logger.info(`Processing job ${job.job_id} for ${job.function_id}`);
287
+ // Build execution context from job assignment
288
+ const ctx = new ExecutionContext({
289
+ run_id: job.run_id,
290
+ function_id: job.function_id,
291
+ attempt: job.attempt,
292
+ event: job.event,
293
+ steps: job.completed_steps.map((s) => ({
294
+ id: s.step_id,
295
+ name: s.name,
296
+ status: "completed",
297
+ output: s.output,
298
+ })),
299
+ resume: undefined,
300
+ });
301
+ const step = createStepClient(ctx);
302
+ const functionContext = {
303
+ event: ctx.event,
304
+ step,
305
+ run: ctx.runInfo,
306
+ logger: ctx.logger,
307
+ };
308
+ try {
309
+ // Check for abort
310
+ if (signal.aborted) {
311
+ return;
312
+ }
313
+ const result = await fn.handler(functionContext);
314
+ // Send completion with executed steps
315
+ await this.sendJobCompleted(baseUrl, job.job_id, result, ctx.getExecutedSteps());
316
+ }
317
+ catch (error) {
318
+ if (signal.aborted) {
319
+ return;
320
+ }
321
+ if (isYieldSignal(error)) {
322
+ // Send yield
323
+ await this.sendStepYielded(baseUrl, job.job_id, error.yieldInfo);
324
+ return;
325
+ }
326
+ // Send failure
327
+ await this.sendJobFailed(baseUrl, job.job_id, {
328
+ message: error instanceof Error ? error.message : String(error),
329
+ code: error instanceof IronflowError ? error.code : "ERROR",
330
+ retryable: error instanceof IronflowError ? error.retryable : true,
331
+ });
332
+ }
333
+ }
334
+ /**
335
+ * Report successful job completion
336
+ */
337
+ async sendJobCompleted(baseUrl, jobId, output, steps) {
338
+ await fetch(`${baseUrl}/api/v1/workers/${this.workerId}/jobs/${jobId}`, {
339
+ method: "PUT",
340
+ headers: { "Content-Type": "application/json" },
341
+ body: JSON.stringify({
342
+ status: "completed",
343
+ output,
344
+ steps,
345
+ }),
346
+ });
347
+ }
348
+ /**
349
+ * Report job failure
350
+ */
351
+ async sendJobFailed(baseUrl, jobId, error) {
352
+ await fetch(`${baseUrl}/api/v1/workers/${this.workerId}/jobs/${jobId}`, {
353
+ method: "PUT",
354
+ headers: { "Content-Type": "application/json" },
355
+ body: JSON.stringify({
356
+ status: "failed",
357
+ error,
358
+ }),
359
+ });
360
+ }
361
+ /**
362
+ * Report step yield
363
+ */
364
+ async sendStepYielded(baseUrl, jobId, yieldInfo) {
365
+ await fetch(`${baseUrl}/api/v1/workers/${this.workerId}/jobs/${jobId}`, {
366
+ method: "PUT",
367
+ headers: { "Content-Type": "application/json" },
368
+ body: JSON.stringify({
369
+ status: "yielded",
370
+ yield: yieldInfo,
371
+ }),
372
+ });
373
+ }
374
+ /**
375
+ * Async sleep helper
376
+ */
377
+ sleep(ms) {
378
+ return new Promise((resolve) => setTimeout(resolve, ms));
379
+ }
380
+ }
381
+ /**
382
+ * Generate a unique worker ID
383
+ */
384
+ function generateWorkerId() {
385
+ const timestamp = Date.now().toString(36);
386
+ const random = Math.random().toString(36).substring(2, 8);
387
+ return `worker-${timestamp}-${random}`;
388
+ }
389
+ /**
390
+ * Get the hostname from environment
391
+ */
392
+ function getHostname() {
393
+ if (typeof process !== "undefined" && process.env["HOSTNAME"]) {
394
+ return process.env["HOSTNAME"];
395
+ }
396
+ return "unknown";
397
+ }
398
+ // Re-export the streaming worker
399
+ export { createStreamingWorker } from "./worker-streaming.js";
400
+ /**
401
+ * Default export
402
+ */
403
+ export default createWorker;
404
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,EACL,aAAa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CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF;AAED;;GAEG;AACH,SAAS,gBAAgB;IACvB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1D,OAAO,UAAU,SAAS,IAAI,MAAM,EAAE,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,SAAS,WAAW;IAClB,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9D,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,iCAAiC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;GAEG;AACH,eAAe,YAAY,CAAC"}
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@ironflow/node",
3
+ "version": "0.1.0-test.2",
4
+ "description": "Node.js SDK for Ironflow workflow engine - workers, serve handlers, and step execution",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./serve": {
14
+ "types": "./dist/serve.d.ts",
15
+ "import": "./dist/serve.js"
16
+ },
17
+ "./worker": {
18
+ "types": "./dist/worker.d.ts",
19
+ "import": "./dist/worker.js"
20
+ }
21
+ },
22
+ "sideEffects": false,
23
+ "files": [
24
+ "dist",
25
+ "README.md"
26
+ ],
27
+ "dependencies": {
28
+ "@bufbuild/protobuf": "^2.5.1",
29
+ "@connectrpc/connect": "^2.1.1",
30
+ "@connectrpc/connect-node": "^2.1.1",
31
+ "zod": "^4.3.5",
32
+ "@ironflow/core": "0.1.0-test.2"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^22.14.0",
36
+ "typescript": "^5.9.3",
37
+ "vitest": "^2.1.9"
38
+ },
39
+ "peerDependencies": {
40
+ "typescript": ">=5.0.0"
41
+ },
42
+ "peerDependenciesMeta": {
43
+ "typescript": {
44
+ "optional": true
45
+ }
46
+ },
47
+ "engines": {
48
+ "node": ">=20.0.0"
49
+ },
50
+ "keywords": [
51
+ "ironflow",
52
+ "workflow",
53
+ "serverless",
54
+ "worker",
55
+ "step-functions"
56
+ ],
57
+ "author": "Ironflow",
58
+ "license": "MIT",
59
+ "repository": {
60
+ "type": "git",
61
+ "url": "https://github.com/ironflowapp/ironflow.git",
62
+ "directory": "sdk/js/node"
63
+ },
64
+ "publishConfig": {
65
+ "access": "restricted"
66
+ },
67
+ "scripts": {
68
+ "build": "tsc",
69
+ "dev": "tsc --watch",
70
+ "test": "vitest run",
71
+ "test:watch": "vitest",
72
+ "lint": "eslint src/",
73
+ "clean": "rm -rf dist",
74
+ "typecheck": "tsc --noEmit"
75
+ }
76
+ }