@donkeylabs/server 1.1.8 → 1.1.9
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/package.json +1 -1
- package/src/core/workflows.ts +14 -0
- package/src/server.ts +3 -0
package/package.json
CHANGED
package/src/core/workflows.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { Events } from "./events";
|
|
|
11
11
|
import type { Jobs } from "./jobs";
|
|
12
12
|
import type { SSE } from "./sse";
|
|
13
13
|
import type { z } from "zod";
|
|
14
|
+
import type { CoreServices } from "../core";
|
|
14
15
|
|
|
15
16
|
// Type helper for Zod schema inference
|
|
16
17
|
type ZodSchema = z.ZodTypeAny;
|
|
@@ -192,6 +193,8 @@ export interface WorkflowContext {
|
|
|
192
193
|
instance: WorkflowInstance;
|
|
193
194
|
/** Get a step result with type safety */
|
|
194
195
|
getStepResult<T = any>(stepName: string): T | undefined;
|
|
196
|
+
/** Core services (logger, events, cache, etc.) */
|
|
197
|
+
core: CoreServices;
|
|
195
198
|
}
|
|
196
199
|
|
|
197
200
|
// ============================================
|
|
@@ -501,6 +504,8 @@ export interface WorkflowsConfig {
|
|
|
501
504
|
sse?: SSE;
|
|
502
505
|
/** Poll interval for checking job completion (ms) */
|
|
503
506
|
pollInterval?: number;
|
|
507
|
+
/** Core services to pass to step handlers */
|
|
508
|
+
core?: CoreServices;
|
|
504
509
|
}
|
|
505
510
|
|
|
506
511
|
export interface Workflows {
|
|
@@ -518,6 +523,8 @@ export interface Workflows {
|
|
|
518
523
|
resume(): Promise<void>;
|
|
519
524
|
/** Stop the workflow service */
|
|
520
525
|
stop(): Promise<void>;
|
|
526
|
+
/** Set core services (called after initialization to resolve circular dependency) */
|
|
527
|
+
setCore(core: CoreServices): void;
|
|
521
528
|
}
|
|
522
529
|
|
|
523
530
|
// ============================================
|
|
@@ -529,6 +536,7 @@ class WorkflowsImpl implements Workflows {
|
|
|
529
536
|
private events?: Events;
|
|
530
537
|
private jobs?: Jobs;
|
|
531
538
|
private sse?: SSE;
|
|
539
|
+
private core?: CoreServices;
|
|
532
540
|
private definitions = new Map<string, WorkflowDefinition>();
|
|
533
541
|
private running = new Map<string, { timeout?: ReturnType<typeof setTimeout> }>();
|
|
534
542
|
private pollInterval: number;
|
|
@@ -538,9 +546,14 @@ class WorkflowsImpl implements Workflows {
|
|
|
538
546
|
this.events = config.events;
|
|
539
547
|
this.jobs = config.jobs;
|
|
540
548
|
this.sse = config.sse;
|
|
549
|
+
this.core = config.core;
|
|
541
550
|
this.pollInterval = config.pollInterval ?? 1000;
|
|
542
551
|
}
|
|
543
552
|
|
|
553
|
+
setCore(core: CoreServices): void {
|
|
554
|
+
this.core = core;
|
|
555
|
+
}
|
|
556
|
+
|
|
544
557
|
register(definition: WorkflowDefinition): void {
|
|
545
558
|
if (this.definitions.has(definition.name)) {
|
|
546
559
|
throw new Error(`Workflow "${definition.name}" is already registered`);
|
|
@@ -1099,6 +1112,7 @@ class WorkflowsImpl implements Workflows {
|
|
|
1099
1112
|
getStepResult: <T = any>(stepName: string): T | undefined => {
|
|
1100
1113
|
return steps[stepName] as T | undefined;
|
|
1101
1114
|
},
|
|
1115
|
+
core: this.core!,
|
|
1102
1116
|
};
|
|
1103
1117
|
}
|
|
1104
1118
|
|
package/src/server.ts
CHANGED
|
@@ -166,6 +166,9 @@ export class AppServer {
|
|
|
166
166
|
websocket,
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
+
// Resolve circular dependency: workflows needs core for step handlers
|
|
170
|
+
workflows.setCore(this.coreServices);
|
|
171
|
+
|
|
169
172
|
this.manager = new PluginManager(this.coreServices);
|
|
170
173
|
this.typeGenConfig = options.generateTypes;
|
|
171
174
|
}
|