@deepbounty/sdk 1.0.6 → 1.0.8

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/index.d.ts CHANGED
@@ -1,26 +1,65 @@
1
- import { ModuleSetting, TaskContent, TaskResult } from "./types";
1
+ import { ModuleSetting, TaskContent, Tool } from "./types";
2
2
  export interface Logger {
3
3
  info: (...args: any[]) => void;
4
4
  warn: (...args: any[]) => void;
5
5
  error: (...args: any[]) => void;
6
6
  }
7
7
  export interface ConfigAPI {
8
+ /** Get a configuration value by key
9
+ * @param key The configuration key
10
+ * @param defaultValue The default value to return if the key does not exist
11
+ * @returns The configuration value
12
+ */
8
13
  get<T = any>(key: string, defaultValue?: T): Promise<T>;
14
+ /** Set a configuration value by key
15
+ * @param key The configuration key
16
+ * @param value The configuration value
17
+ * @returns A promise that resolves when the value is set
18
+ */
9
19
  set<T = any>(key: string, value: T): Promise<void>;
20
+ /** Remove a configuration value by key
21
+ * @param key The configuration key
22
+ * @returns A promise that resolves when the value is removed
23
+ */
10
24
  remove(key: string): Promise<void>;
11
25
  getAll(): Promise<Record<string, any>>;
26
+ /** Get a specific module setting by name
27
+ * @param name The setting name
28
+ * @returns The module setting
29
+ */
12
30
  getSetting(name: string): Promise<ModuleSetting>;
31
+ /** Set a specific module setting by name
32
+ * @param name The setting name
33
+ * @param value The setting value
34
+ * @returns A promise that resolves when the value is set
35
+ */
13
36
  setSetting(name: string, value: any): Promise<void>;
37
+ /** Get all module settings
38
+ * @returns An array of all module settings
39
+ */
14
40
  getAllSettings(): Promise<ModuleSetting[]>;
15
41
  }
16
- export interface TasksAPI {
17
- submit(taskContent: TaskContent): Promise<TaskResult>;
18
- }
19
42
  export interface ServerAPI {
20
43
  version: string;
21
44
  logger: Logger;
22
45
  config: ConfigAPI;
23
- tasks: TasksAPI;
46
+ /**
47
+ * Register a scheduled task that runs at a specific interval
48
+ * @param taskContent The task content including commands and required tools
49
+ * @param interval Interval in seconds between task executions
50
+ * @returns The ID of the registered scheduled task
51
+ */
52
+ registerScheduledTask(taskContent: TaskContent, interval: number): number;
53
+ /**
54
+ * Unregister a scheduled task
55
+ * @param taskId The ID of the scheduled task to unregister
56
+ * @returns true if the task was unregistered, false if it didn't exist
57
+ */
58
+ unregisterScheduledTask(taskId: number): boolean;
59
+ /** Register a tool
60
+ * @param tool The tool to register
61
+ */
62
+ registerTool(tool: Tool): void;
24
63
  }
25
64
  export interface PluginLifecycle {
26
65
  run?(api: ServerAPI): Promise<void> | void;
@@ -1,4 +1,3 @@
1
- import { Tool } from "./tools";
2
1
  export interface Module {
3
2
  id: string;
4
3
  name: string;
@@ -6,7 +5,6 @@ export interface Module {
6
5
  entry: string;
7
6
  description?: string;
8
7
  settings?: ModuleSetting[];
9
- tools?: Tool[];
10
8
  }
11
9
  export interface ModuleSetting {
12
10
  name: string;
@@ -18,5 +16,4 @@ export interface ModuleSetting {
18
16
  }
19
17
  export interface LoadedModule extends Module {
20
18
  run: () => Promise<any>;
21
- tools?: Tool[];
22
19
  }
@@ -1,19 +1,27 @@
1
1
  import { Tool } from "./tools";
2
2
  export interface TaskContent {
3
3
  commands: string[];
4
- requiredTools?: (Tool | string)[];
4
+ requiredTools?: Tool[];
5
5
  }
6
- export interface Task extends TaskContent {
6
+ export interface ScheduledTask {
7
7
  id: number;
8
+ content: TaskContent;
9
+ interval: number;
10
+ moduleId: string;
11
+ lastExecutedAt?: Date;
12
+ nextExecutionAt: Date;
8
13
  }
9
- export interface ServerTask extends Task {
14
+ export interface TaskExecution {
15
+ executionId: number;
16
+ scheduledTaskId: number;
10
17
  workerId?: number;
11
18
  status: "pending" | "running" | "completed" | "failed";
12
19
  createdAt: Date;
13
- requiredTools?: Tool[];
20
+ content: TaskContent;
14
21
  }
15
22
  export interface TaskResult {
16
- taskId: number;
23
+ executionId: number;
24
+ scheduledTaskId: number;
17
25
  success: boolean;
18
26
  output?: any;
19
27
  error?: string;
@@ -1,8 +1,8 @@
1
- import { ServerTask } from "./tasks";
1
+ import { TaskExecution } from "./tasks";
2
2
  import { Tool } from "./tools";
3
3
  export interface Worker {
4
4
  id: number;
5
- currentTasks: ServerTask[];
5
+ currentTasks: TaskExecution[];
6
6
  availableTools: Tool[];
7
7
  loadFactor: number;
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepbounty/sdk",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "DeepBounty SDK for module development",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",