-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoop.engine.ts
More file actions
34 lines (29 loc) · 987 Bytes
/
noop.engine.ts
File metadata and controls
34 lines (29 loc) · 987 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import type { BaseEngine, EngineResult, TaskContext } from 'kernel-script';
export class NoopEngine implements BaseEngine {
keycard: string = 'NoopEngine';
async execute(ctx: TaskContext): Promise<EngineResult> {
const { task } = ctx;
try {
// For testing logic, use sleep instead of actual generate
console.log(`Starting mock execution for task: ${task.id}`);
for (let i = 0; i < 5; i++) {
await ctx.sleep(1000); // Sleep 1s with context
console.log(`Task ${task.id} progress: ${(i + 1) * 20}%`);
}
return {
success: true,
output: 'Mock output (test mode)',
};
} catch (e) {
if (e instanceof Error && e.message === 'CANCELLED') {
return { success: false, error: 'CANCELLED' };
}
return {
success: false,
error: e instanceof Error ? e.message : String(e),
};
}
}
cancel(_taskId: string): void {}
}
export const noopEngine = new NoopEngine();