@smythos/sre 1.6.14 → 1.7.1
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/CHANGELOG +15 -0
- package/dist/index.js +52 -46
- package/dist/index.js.map +1 -1
- package/dist/types/Components/APIEndpoint.class.d.ts +2 -8
- package/dist/types/Components/Component.class.d.ts +9 -0
- package/dist/types/Components/Triggers/Gmail.trigger.d.ts +0 -17
- package/dist/types/Components/Triggers/JobScheduler.trigger.d.ts +10 -0
- package/dist/types/Components/Triggers/Trigger.class.d.ts +11 -0
- package/dist/types/Components/index.d.ts +6 -0
- package/dist/types/Core/Connector.class.d.ts +1 -0
- package/dist/types/Core/ConnectorsService.d.ts +2 -0
- package/dist/types/Core/HookService.d.ts +1 -1
- package/dist/types/helpers/Conversation.helper.d.ts +2 -0
- package/dist/types/helpers/Crypto.helper.d.ts +8 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/subsystems/AgentManager/Agent.class.d.ts +4 -2
- package/dist/types/subsystems/AgentManager/AgentData.service/AgentDataConnector.d.ts +13 -0
- package/dist/types/subsystems/AgentManager/AgentData.service/connectors/NullAgentData.class.d.ts +1 -4
- package/dist/types/subsystems/AgentManager/Scheduler.service/Job.class.d.ts +29 -6
- package/dist/types/subsystems/AgentManager/Scheduler.service/SchedulerConnector.d.ts +11 -3
- package/dist/types/subsystems/AgentManager/Scheduler.service/connectors/LocalScheduler.class.d.ts +31 -7
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/Perplexity.class.d.ts +2 -5
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/openai/OpenAIConnector.class.d.ts +3 -6
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.d.ts +7 -0
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/xAI.class.d.ts +2 -5
- package/dist/types/types/Agent.types.d.ts +1 -0
- package/dist/types/types/LLM.types.d.ts +2 -5
- package/dist/types/types/SRE.types.d.ts +4 -1
- package/package.json +6 -2
- package/src/Components/APICall/OAuth.helper.ts +30 -35
- package/src/Components/APIEndpoint.class.ts +25 -6
- package/src/Components/Component.class.ts +11 -0
- package/src/Components/Triggers/Gmail.trigger.ts +282 -0
- package/src/Components/Triggers/JobScheduler.trigger.ts +45 -0
- package/src/Components/Triggers/README.md +3 -0
- package/src/Components/Triggers/Trigger.class.ts +101 -0
- package/src/Components/Triggers/WhatsApp.trigger.ts +219 -0
- package/src/Components/index.ts +8 -0
- package/src/Core/AgentProcess.helper.ts +4 -6
- package/src/Core/Connector.class.ts +11 -3
- package/src/Core/ConnectorsService.ts +5 -0
- package/src/Core/ExternalEventsReceiver.ts +317 -0
- package/src/Core/HookService.ts +20 -6
- package/src/Core/SmythRuntime.class.ts +7 -0
- package/src/Core/SystemEvents.ts +17 -0
- package/src/Core/boot.ts +2 -0
- package/src/helpers/Conversation.helper.ts +35 -11
- package/src/helpers/Crypto.helper.ts +28 -0
- package/src/index.ts +208 -195
- package/src/index.ts.bak +208 -195
- package/src/subsystems/AGENTS.md +594 -0
- package/src/subsystems/AgentManager/Agent.class.ts +71 -21
- package/src/subsystems/AgentManager/AgentData.service/AgentDataConnector.ts +24 -1
- package/src/subsystems/AgentManager/AgentData.service/connectors/NullAgentData.class.ts +2 -2
- package/src/subsystems/AgentManager/AgentRuntime.class.ts +34 -5
- package/src/subsystems/AgentManager/Scheduler.service/Job.class.ts +414 -0
- package/src/subsystems/AgentManager/Scheduler.service/Schedule.class.ts +200 -0
- package/src/subsystems/AgentManager/Scheduler.service/SchedulerConnector.ts +200 -0
- package/src/subsystems/AgentManager/Scheduler.service/connectors/LocalScheduler.class.ts +767 -0
- package/src/subsystems/AgentManager/Scheduler.service/index.ts +11 -0
- package/src/subsystems/IO/VectorDB.service/connectors/MilvusVectorDB.class.ts +1 -1
- package/src/subsystems/LLMManager/LLM.service/LLMCredentials.helper.ts +61 -2
- package/src/subsystems/LLMManager/LLM.service/connectors/Anthropic.class.ts +3 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/Bedrock.class.ts +3 -1
- package/src/subsystems/LLMManager/LLM.service/connectors/Echo.class.ts +5 -1
- package/src/subsystems/LLMManager/LLM.service/connectors/GoogleAI.class.ts +247 -56
- package/src/subsystems/LLMManager/LLM.service/connectors/Groq.class.ts +3 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/Ollama.class.ts +28 -21
- package/src/subsystems/LLMManager/LLM.service/connectors/Perplexity.class.ts +3 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/VertexAI.class.ts +121 -33
- package/src/subsystems/LLMManager/LLM.service/connectors/openai/OpenAIConnector.class.ts +38 -27
- package/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts +115 -18
- package/src/subsystems/LLMManager/LLM.service/connectors/xAI.class.ts +3 -0
- package/src/subsystems/LLMManager/ModelsProvider.service/ModelsProviderConnector.ts +1 -6
- package/src/subsystems/MemoryManager/LLMContext.ts +3 -8
- package/src/subsystems/MemoryManager/RuntimeContext.ts +10 -9
- package/src/subsystems/Security/Credentials/Credentials.class.ts +1 -0
- package/src/subsystems/Security/Credentials/ManagedOAuth2Credentials.class.ts +106 -0
- package/src/types/Agent.types.ts +1 -0
- package/src/types/LLM.types.ts +2 -2
- package/src/types/SRE.types.ts +3 -0
|
@@ -5,12 +5,6 @@ export declare class APIEndpoint extends Component {
|
|
|
5
5
|
protected configSchema: Joi.ObjectSchema<any>;
|
|
6
6
|
constructor();
|
|
7
7
|
init(): void;
|
|
8
|
-
process(input: any, config: any, agent: Agent): Promise<
|
|
9
|
-
|
|
10
|
-
body: any;
|
|
11
|
-
query: any;
|
|
12
|
-
params: any;
|
|
13
|
-
_authInfo: any;
|
|
14
|
-
_debug: string;
|
|
15
|
-
}>;
|
|
8
|
+
process(input: any, config: any, agent: Agent): Promise<any>;
|
|
9
|
+
postProcess(output: any, config: any, agent: Agent): Promise<any>;
|
|
16
10
|
}
|
|
@@ -50,4 +50,13 @@ export declare class Component {
|
|
|
50
50
|
disable(config: any, agent: Agent): Promise<any>;
|
|
51
51
|
readOutput(id: any, config: any, agent: Agent): any;
|
|
52
52
|
hasOutput(id: any, config: any, agent: Agent): any;
|
|
53
|
+
/**
|
|
54
|
+
* A generic registration function that can be overridden by child classes to register the trigger with providers
|
|
55
|
+
* this function is usually called outside of a workflow in order to register the trigger with providers
|
|
56
|
+
* @param componentId the id of the component to register (in SRE a single trigger instance handles all the triggers of the same type)
|
|
57
|
+
* @param agent the agent instance
|
|
58
|
+
* @param payload any additional payload to pass to the trigger
|
|
59
|
+
*/
|
|
60
|
+
register(componentId: string, componentSettings: any, payload?: any): Promise<void>;
|
|
61
|
+
unregister(componentId: string, componentSettings: any, payload?: any): Promise<void>;
|
|
53
62
|
}
|
|
@@ -56,20 +56,3 @@ export declare class GmailTrigger extends Trigger {
|
|
|
56
56
|
};
|
|
57
57
|
}[]>;
|
|
58
58
|
}
|
|
59
|
-
/**
|
|
60
|
-
* Create or update a Dkron job
|
|
61
|
-
* @param {string} id - Unique job ID
|
|
62
|
-
* @param {object} metadata - Arbitrary metadata object
|
|
63
|
-
* @param {string} url - URL to call
|
|
64
|
-
* @param {object|string} body - Request body (object will be JSON stringified)
|
|
65
|
-
* @param {object} headers - HTTP headers
|
|
66
|
-
* @param {string} schedule - Cron or frequency expression (e.g. "@every 1m" or "0 * * * * *")
|
|
67
|
-
*/
|
|
68
|
-
export declare function createDkronJob(id: any, metadata: any, url: any, body: any, headers: any, schedule: any): Promise<any>;
|
|
69
|
-
/**
|
|
70
|
-
* Delete a Dkron job by ID
|
|
71
|
-
* @param {string} id - Job ID
|
|
72
|
-
*/
|
|
73
|
-
export declare function deleteDkronJob(id: any): Promise<{
|
|
74
|
-
success: boolean;
|
|
75
|
-
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IAgent as Agent, IAgent } from '@sre/types/Agent.types';
|
|
2
|
+
import { Trigger } from './Trigger.class';
|
|
3
|
+
export declare class JobSchedulerTrigger extends Trigger {
|
|
4
|
+
collectPayload(input: any, settings: any, agent: Agent): Promise<any[]>;
|
|
5
|
+
register(componentId: string, componentSettings: any, payload?: {
|
|
6
|
+
agentData: IAgent;
|
|
7
|
+
triggerUrl: string;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
unregister(componentId: string, agent: Agent, payload?: any): Promise<void>;
|
|
10
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Agent } from '@sre/AgentManager/Agent.class';
|
|
2
2
|
import { Component } from '../Component.class';
|
|
3
3
|
import { LogHelper } from '@sre/helpers/Log.helper';
|
|
4
|
+
import { IAgent } from '@sre/types/Agent.types';
|
|
4
5
|
export declare class Trigger extends Component {
|
|
5
6
|
protected logger: LogHelper;
|
|
6
7
|
process(input: any, settings: any, agent: Agent): Promise<any>;
|
|
@@ -15,7 +16,17 @@ export declare class Trigger extends Component {
|
|
|
15
16
|
_debug: string;
|
|
16
17
|
}>;
|
|
17
18
|
postProcess(output: any, settings: any, agent: Agent): Promise<any>;
|
|
19
|
+
/**
|
|
20
|
+
* This function is used to register a trigger,
|
|
21
|
+
* It can be called by a visual builder when saving a trigger component.
|
|
22
|
+
* it performs the necessary actions to register the trigger with the external service or with the internal scheduler.
|
|
23
|
+
* @param componentId - The id of the component to register
|
|
24
|
+
* @param componentSettings - The settings of the component to register
|
|
25
|
+
* @param payload - The payload to register the trigger with
|
|
26
|
+
* @returns A promise that resolves to the result of the registration
|
|
27
|
+
*/
|
|
18
28
|
register(componentId: string, componentSettings: any, payload: {
|
|
29
|
+
agentData: IAgent;
|
|
19
30
|
triggerUrl: string;
|
|
20
31
|
}): Promise<void>;
|
|
21
32
|
}
|
|
@@ -42,6 +42,9 @@ import { MemoryWriteKeyVal } from './MemoryWriteKeyVal.class';
|
|
|
42
42
|
import { MemoryReadKeyVal } from './MemoryReadKeyVal.class';
|
|
43
43
|
import { MemoryDeleteKeyVal } from './MemoryDeleteKeyVal.class';
|
|
44
44
|
import { MemoryWriteObject } from './MemoryWriteObject.class';
|
|
45
|
+
import { GmailTrigger } from './Triggers/Gmail.trigger';
|
|
46
|
+
import { WhatsAppTrigger } from './Triggers/WhatsApp.trigger';
|
|
47
|
+
import { JobSchedulerTrigger } from './Triggers/JobScheduler.trigger';
|
|
45
48
|
export declare const ComponentInstances: {
|
|
46
49
|
Component: Component;
|
|
47
50
|
Note: Component;
|
|
@@ -91,4 +94,7 @@ export declare const ComponentInstances: {
|
|
|
91
94
|
MemoryReadKeyVal: MemoryReadKeyVal;
|
|
92
95
|
MemoryDeleteKeyVal: MemoryDeleteKeyVal;
|
|
93
96
|
MemoryWriteObject: MemoryWriteObject;
|
|
97
|
+
GmailTrigger: GmailTrigger;
|
|
98
|
+
WhatsAppTrigger: WhatsAppTrigger;
|
|
99
|
+
JobSchedulerTrigger: JobSchedulerTrigger;
|
|
94
100
|
};
|
|
@@ -15,6 +15,7 @@ import { LogConnector } from '@sre/IO/Log.service/LogConnector';
|
|
|
15
15
|
import { ComponentConnector } from '@sre/AgentManager/Component.service/ComponentConnector';
|
|
16
16
|
import { ModelsProviderConnector } from '@sre/LLMManager/ModelsProvider.service/ModelsProviderConnector';
|
|
17
17
|
import { CodeConnector } from '@sre/ComputeManager/Code.service/CodeConnector';
|
|
18
|
+
import { SchedulerConnector } from '@sre/AgentManager/Scheduler.service/SchedulerConnector';
|
|
18
19
|
export declare class ConnectorService {
|
|
19
20
|
static Connectors: {};
|
|
20
21
|
static ConnectorInstances: any;
|
|
@@ -58,6 +59,7 @@ export declare class ConnectorService {
|
|
|
58
59
|
static hasInstance(connectorType: TConnectorService, connectorName?: string): any;
|
|
59
60
|
static getRouterConnector(name?: string): RouterConnector;
|
|
60
61
|
static getCodeConnector(name?: string): CodeConnector;
|
|
62
|
+
static getSchedulerConnector(name?: string): SchedulerConnector;
|
|
61
63
|
}
|
|
62
64
|
export declare abstract class ConnectorServiceProvider {
|
|
63
65
|
abstract register(): any;
|
|
@@ -35,7 +35,7 @@ export declare function hook(hookName: string): (target: any, propertyKey: strin
|
|
|
35
35
|
* Decorator function that executes registered hooks asynchronously before and after the decorated method
|
|
36
36
|
* @param hookName The name of the hook to trigger
|
|
37
37
|
*/
|
|
38
|
-
export declare function hookAsync(hookName: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
38
|
+
export declare function hookAsync(hookName: string, customContext?: Record<string, any> | ((instance: any) => Record<string, any>)): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
39
39
|
/**
|
|
40
40
|
* Decorator function that executes registered hooks asynchronously before the decorated method
|
|
41
41
|
* @param hookName The name of the hook to trigger
|
|
@@ -59,6 +59,8 @@ export declare class Conversation extends EventEmitter {
|
|
|
59
59
|
handler: (args: Record<string, any>) => Promise<any>;
|
|
60
60
|
inputs?: any[];
|
|
61
61
|
}): Promise<void>;
|
|
62
|
+
removeTool(toolName: string): Promise<void>;
|
|
63
|
+
get toolNames(): string[];
|
|
62
64
|
/**
|
|
63
65
|
* updates LLM model, if spec is available, it will update the tools config
|
|
64
66
|
* @param model
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate a service-specific authentication key
|
|
3
|
+
*/
|
|
4
|
+
export declare function generateServiceKey(serviceName: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Validate a service key
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateServiceKey(serviceName: string, providedKey: string): boolean;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -48,12 +48,14 @@ export * from './Core/boot';
|
|
|
48
48
|
export * from './Core/Connector.class';
|
|
49
49
|
export * from './Core/ConnectorsService';
|
|
50
50
|
export * from './Core/DummyConnector';
|
|
51
|
+
export * from './Core/ExternalEventsReceiver';
|
|
51
52
|
export * from './Core/HookService';
|
|
52
53
|
export * from './Core/SmythRuntime.class';
|
|
53
54
|
export * from './Core/SystemEvents';
|
|
54
55
|
export * from './helpers/AWSLambdaCode.helper';
|
|
55
56
|
export * from './helpers/BinaryInput.helper';
|
|
56
57
|
export * from './helpers/Conversation.helper';
|
|
58
|
+
export * from './helpers/Crypto.helper';
|
|
57
59
|
export * from './helpers/ECMASandbox.helper';
|
|
58
60
|
export * from './helpers/JsonContent.helper';
|
|
59
61
|
export * from './helpers/LocalCache.helper';
|
|
@@ -86,6 +88,10 @@ export * from './Components/APICall/parseHeaders';
|
|
|
86
88
|
export * from './Components/APICall/parseProxy';
|
|
87
89
|
export * from './Components/APICall/parseUrl';
|
|
88
90
|
export * from './Components/Image/imageSettings.config';
|
|
91
|
+
export * from './Components/Triggers/Gmail.trigger';
|
|
92
|
+
export * from './Components/Triggers/JobScheduler.trigger';
|
|
93
|
+
export * from './Components/Triggers/Trigger.class';
|
|
94
|
+
export * from './Components/Triggers/WhatsApp.trigger';
|
|
89
95
|
export * from './subsystems/AgentManager/Agent.class';
|
|
90
96
|
export * from './subsystems/AgentManager/Agent.helper';
|
|
91
97
|
export * from './subsystems/AgentManager/AgentLogger.class';
|
|
@@ -110,6 +116,10 @@ export * from './subsystems/AgentManager/AgentData.service/AgentDataConnector';
|
|
|
110
116
|
export * from './subsystems/AgentManager/AgentData.service/index';
|
|
111
117
|
export * from './subsystems/AgentManager/Component.service/ComponentConnector';
|
|
112
118
|
export * from './subsystems/AgentManager/Component.service/index';
|
|
119
|
+
export * from './subsystems/AgentManager/Scheduler.service/index';
|
|
120
|
+
export * from './subsystems/AgentManager/Scheduler.service/Job.class';
|
|
121
|
+
export * from './subsystems/AgentManager/Scheduler.service/Schedule.class';
|
|
122
|
+
export * from './subsystems/AgentManager/Scheduler.service/SchedulerConnector';
|
|
113
123
|
export * from './subsystems/ComputeManager/Code.service/CodeConnector';
|
|
114
124
|
export * from './subsystems/ComputeManager/Code.service/index';
|
|
115
125
|
export * from './subsystems/IO/CLI.service/CLIConnector';
|
|
@@ -138,6 +148,8 @@ export * from './subsystems/Security/AccessControl/AccessRequest.class';
|
|
|
138
148
|
export * from './subsystems/Security/AccessControl/ACL.class';
|
|
139
149
|
export * from './subsystems/Security/Account.service/AccountConnector';
|
|
140
150
|
export * from './subsystems/Security/Account.service/index';
|
|
151
|
+
export * from './subsystems/Security/Credentials/Credentials.class';
|
|
152
|
+
export * from './subsystems/Security/Credentials/ManagedOAuth2Credentials.class';
|
|
141
153
|
export * from './subsystems/Security/ManagedVault.service/index';
|
|
142
154
|
export * from './subsystems/Security/ManagedVault.service/ManagedVaultConnector';
|
|
143
155
|
export * from './subsystems/Security/Vault.service/index';
|
|
@@ -147,6 +159,7 @@ export * from './subsystems/AgentManager/AgentData.service/connectors/CLIAgentDa
|
|
|
147
159
|
export * from './subsystems/AgentManager/AgentData.service/connectors/LocalAgentDataConnector.class';
|
|
148
160
|
export * from './subsystems/AgentManager/AgentData.service/connectors/NullAgentData.class';
|
|
149
161
|
export * from './subsystems/AgentManager/Component.service/connectors/LocalComponentConnector.class';
|
|
162
|
+
export * from './subsystems/AgentManager/Scheduler.service/connectors/LocalScheduler.class';
|
|
150
163
|
export * from './subsystems/ComputeManager/Code.service/connectors/AWSLambdaCode.class';
|
|
151
164
|
export * from './subsystems/IO/Log.service/connectors/ConsoleLog.class';
|
|
152
165
|
export * from './subsystems/IO/NKV.service/connectors/NKVLocalStorage.class';
|
|
@@ -13,10 +13,12 @@ export declare class Agent implements IAgent {
|
|
|
13
13
|
components: any;
|
|
14
14
|
connections: any;
|
|
15
15
|
endpoints: any;
|
|
16
|
+
triggers: any;
|
|
16
17
|
sessionId: any;
|
|
17
18
|
sessionTag: string;
|
|
18
19
|
callerSessionId: any;
|
|
19
20
|
apiBasePath: string;
|
|
21
|
+
triggerBasePath: string;
|
|
20
22
|
agentRuntime: AgentRuntime | any;
|
|
21
23
|
usingTestDomain: boolean;
|
|
22
24
|
domain: string;
|
|
@@ -24,7 +26,7 @@ export declare class Agent implements IAgent {
|
|
|
24
26
|
circularLimit: number;
|
|
25
27
|
version: string;
|
|
26
28
|
agentVariables: any;
|
|
27
|
-
private
|
|
29
|
+
private _killReason;
|
|
28
30
|
async: boolean;
|
|
29
31
|
jobID: string;
|
|
30
32
|
planInfo: any;
|
|
@@ -44,7 +46,7 @@ export declare class Agent implements IAgent {
|
|
|
44
46
|
addSSE(sseSource: Response | AgentSSE, monitorId?: string): void;
|
|
45
47
|
setRequest(agentRequest: AgentRequest | any): void;
|
|
46
48
|
setCallback(callback: (data: any) => void): void;
|
|
47
|
-
kill(): void;
|
|
49
|
+
kill(reason?: string): void;
|
|
48
50
|
isKilled(): boolean;
|
|
49
51
|
private parseVariables;
|
|
50
52
|
process(endpointPath: any, input: any): Promise<any>;
|
|
@@ -9,6 +9,7 @@ export interface IAgentDataConnector {
|
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
export declare abstract class AgentDataConnector extends Connector implements IAgentDataConnector {
|
|
12
|
+
static ephemeralAgentData: Map<string, any>;
|
|
12
13
|
name: string;
|
|
13
14
|
abstract getAgentData(agentId: string, version?: string): Promise<any>;
|
|
14
15
|
abstract getAgentIdByDomain(domain: string): Promise<string>;
|
|
@@ -30,4 +31,16 @@ export declare abstract class AgentDataConnector extends Connector implements IA
|
|
|
30
31
|
* @returns
|
|
31
32
|
*/
|
|
32
33
|
getOpenAPIJSON(source: string | Record<string, any>, server_url: any, version: any, aiOnly?: boolean): Promise<any>;
|
|
34
|
+
/**
|
|
35
|
+
* Sets ephemeral agent data for the given agent ID
|
|
36
|
+
* @param agentId
|
|
37
|
+
* @param data
|
|
38
|
+
*/
|
|
39
|
+
setEphemeralAgentData(agentId: string, data: any): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Gets ephemeral agent data for the given agent ID
|
|
42
|
+
* @param agentId
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
getEphemeralAgentData(agentId: string): Promise<any>;
|
|
33
46
|
}
|
package/dist/types/subsystems/AgentManager/AgentData.service/connectors/NullAgentData.class.d.ts
CHANGED
|
@@ -6,10 +6,7 @@ export declare class NullAgentData extends AgentDataConnector {
|
|
|
6
6
|
name: string;
|
|
7
7
|
constructor(settings: TArgs);
|
|
8
8
|
getAgentConfig(agentId: string): Partial<TArgs>;
|
|
9
|
-
getAgentData(agentId: string, version?: string): Promise<
|
|
10
|
-
data: {};
|
|
11
|
-
version: string;
|
|
12
|
-
}>;
|
|
9
|
+
getAgentData(agentId: string, version?: string): Promise<any>;
|
|
13
10
|
getAgentIdByDomain(domain: string): Promise<string>;
|
|
14
11
|
getAgentSettings(agentId: string, version?: string): Promise<{}>;
|
|
15
12
|
getAgentEmbodiments(agentId: string): Promise<any>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Job - Wrapper for agent-based scheduled tasks
|
|
3
3
|
*
|
|
4
|
-
* Jobs can execute in
|
|
4
|
+
* Jobs can execute in three ways:
|
|
5
5
|
* 1. **Skill Execution**: Call a specific agent skill with arguments
|
|
6
|
-
* 2. **
|
|
6
|
+
* 2. **Trigger Execution**: Invoke an agent trigger (no arguments)
|
|
7
|
+
* 3. **Prompt Execution**: Send a prompt to an agent for processing
|
|
7
8
|
*
|
|
8
9
|
* All job data is fully serializable, allowing jobs to persist and resume after restart.
|
|
9
10
|
*
|
|
@@ -23,6 +24,17 @@
|
|
|
23
24
|
* }
|
|
24
25
|
* });
|
|
25
26
|
*
|
|
27
|
+
* // Trigger execution job
|
|
28
|
+
* const triggerJob = new Job({
|
|
29
|
+
* type: 'trigger',
|
|
30
|
+
* agentId: 'my-agent',
|
|
31
|
+
* triggerName: 'daily_sync',
|
|
32
|
+
* metadata: {
|
|
33
|
+
* name: 'Daily Sync',
|
|
34
|
+
* description: 'Sync data every day at midnight'
|
|
35
|
+
* }
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
26
38
|
* // Prompt execution job
|
|
27
39
|
* const promptJob = new Job({
|
|
28
40
|
* type: 'prompt',
|
|
@@ -36,7 +48,7 @@
|
|
|
36
48
|
* ```
|
|
37
49
|
*/
|
|
38
50
|
export interface IJobMetadata {
|
|
39
|
-
name
|
|
51
|
+
name?: string;
|
|
40
52
|
description?: string;
|
|
41
53
|
tags?: string[];
|
|
42
54
|
retryOnFailure?: boolean;
|
|
@@ -52,7 +64,13 @@ export interface ISkillJobConfig {
|
|
|
52
64
|
agentId: string;
|
|
53
65
|
skillName: string;
|
|
54
66
|
args?: Record<string, any> | any[];
|
|
55
|
-
metadata
|
|
67
|
+
metadata?: IJobMetadata;
|
|
68
|
+
}
|
|
69
|
+
export interface ITriggerJobConfig {
|
|
70
|
+
type: 'trigger';
|
|
71
|
+
agentId: string;
|
|
72
|
+
triggerName: string;
|
|
73
|
+
metadata?: IJobMetadata;
|
|
56
74
|
}
|
|
57
75
|
/**
|
|
58
76
|
* Configuration for a prompt-based job
|
|
@@ -61,11 +79,12 @@ export interface IPromptJobConfig {
|
|
|
61
79
|
type: 'prompt';
|
|
62
80
|
agentId: string;
|
|
63
81
|
prompt: string;
|
|
64
|
-
metadata
|
|
82
|
+
metadata?: IJobMetadata;
|
|
65
83
|
}
|
|
66
|
-
export type IJobConfig = ISkillJobConfig | IPromptJobConfig;
|
|
84
|
+
export type IJobConfig = ISkillJobConfig | IPromptJobConfig | ITriggerJobConfig;
|
|
67
85
|
export declare class Job {
|
|
68
86
|
private config;
|
|
87
|
+
get agentId(): string;
|
|
69
88
|
constructor(config: IJobConfig);
|
|
70
89
|
/**
|
|
71
90
|
* Get the job metadata
|
|
@@ -93,6 +112,10 @@ export declare class Job {
|
|
|
93
112
|
* Execute a skill-based job
|
|
94
113
|
*/
|
|
95
114
|
private executeSkill;
|
|
115
|
+
/**
|
|
116
|
+
* Execute a trigger-based job
|
|
117
|
+
*/
|
|
118
|
+
private executeTrigger;
|
|
96
119
|
/**
|
|
97
120
|
* Execute a prompt-based job
|
|
98
121
|
*/
|
|
@@ -5,6 +5,7 @@ import { SecureConnector } from '@sre/Security/SecureConnector.class';
|
|
|
5
5
|
import { IAccessCandidate, IACL, TAccessRole } from '@sre/types/ACL.types';
|
|
6
6
|
import { Schedule, IScheduleData } from './Schedule.class';
|
|
7
7
|
import { Job, IJobConfig } from './Job.class';
|
|
8
|
+
import EventEmitter from 'events';
|
|
8
9
|
/**
|
|
9
10
|
* Scheduled job data structure
|
|
10
11
|
*/
|
|
@@ -13,7 +14,7 @@ export interface IScheduledJob {
|
|
|
13
14
|
schedule: IScheduleData;
|
|
14
15
|
jobConfig: IJobConfig;
|
|
15
16
|
acl: IACL;
|
|
16
|
-
status: 'active' | 'paused'
|
|
17
|
+
status: 'active' | 'paused';
|
|
17
18
|
lastRun?: string;
|
|
18
19
|
nextRun?: string;
|
|
19
20
|
createdBy: {
|
|
@@ -37,11 +38,13 @@ export interface IJobExecution {
|
|
|
37
38
|
*/
|
|
38
39
|
export interface ISchedulerRequest {
|
|
39
40
|
list(): Promise<IScheduledJob[]>;
|
|
40
|
-
add(jobId: string,
|
|
41
|
+
add(jobId: string, job: Job, schedule: Schedule): Promise<void>;
|
|
41
42
|
delete(jobId: string): Promise<void>;
|
|
42
43
|
get(jobId: string): Promise<IScheduledJob | undefined>;
|
|
43
44
|
pause(jobId: string): Promise<void>;
|
|
44
45
|
resume(jobId: string): Promise<void>;
|
|
46
|
+
on(event: string, listener: (...args: any[]) => void): any;
|
|
47
|
+
off(event: string, listener: (...args: any[]) => void): any;
|
|
45
48
|
}
|
|
46
49
|
/**
|
|
47
50
|
* Abstract base class for scheduler connectors
|
|
@@ -70,6 +73,8 @@ export interface ISchedulerRequest {
|
|
|
70
73
|
export declare abstract class SchedulerConnector extends SecureConnector<ISchedulerRequest> {
|
|
71
74
|
abstract id: string;
|
|
72
75
|
abstract name: string;
|
|
76
|
+
protected _eventEmitter: EventEmitter;
|
|
77
|
+
constructor(settings?: any);
|
|
73
78
|
/**
|
|
74
79
|
* Get ACL for a specific job resource
|
|
75
80
|
* @param resourceId - Job ID
|
|
@@ -93,7 +98,7 @@ export declare abstract class SchedulerConnector extends SecureConnector<ISchedu
|
|
|
93
98
|
* @param schedule - Schedule definition
|
|
94
99
|
* @param job - Job to execute
|
|
95
100
|
*/
|
|
96
|
-
protected abstract add(acRequest: AccessRequest, jobId: string,
|
|
101
|
+
protected abstract add(acRequest: AccessRequest, jobId: string, job: Job, schedule: Schedule): Promise<void>;
|
|
97
102
|
/**
|
|
98
103
|
* Delete a scheduled job
|
|
99
104
|
* @param acRequest - Access request
|
|
@@ -124,4 +129,7 @@ export declare abstract class SchedulerConnector extends SecureConnector<ISchedu
|
|
|
124
129
|
* @param jobId - Job ID
|
|
125
130
|
*/
|
|
126
131
|
protected constructJobKey(candidate: IAccessCandidate, jobId: string): string;
|
|
132
|
+
protected emit(event: string, ...args: any[]): boolean;
|
|
133
|
+
on(event: string, listener: (...args: any[]) => void): this;
|
|
134
|
+
off(event: string, listener: (...args: any[]) => void): this;
|
|
127
135
|
}
|
package/dist/types/subsystems/AgentManager/Scheduler.service/connectors/LocalScheduler.class.d.ts
CHANGED
|
@@ -11,10 +11,12 @@ export type LocalSchedulerConfig = {
|
|
|
11
11
|
*/
|
|
12
12
|
folder?: string;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Enable job execution
|
|
15
|
+
* If true: loads jobs at start and executes them on schedule
|
|
16
|
+
* If false: allows job management but skips all execution (for multi-instance setups)
|
|
15
17
|
* Defaults to true
|
|
16
18
|
*/
|
|
17
|
-
|
|
19
|
+
runJobs?: boolean;
|
|
18
20
|
/**
|
|
19
21
|
* Keep execution history
|
|
20
22
|
* Defaults to true
|
|
@@ -33,9 +35,22 @@ export type LocalSchedulerConfig = {
|
|
|
33
35
|
* Loads and schedules jobs on initialization.
|
|
34
36
|
* Provides full ACL-based access control and candidate isolation.
|
|
35
37
|
*
|
|
38
|
+
* **Multi-Instance Safety**: Uses static storage to prevent race conditions when
|
|
39
|
+
* multiple scheduler instances are running. Job timers are shared across all instances,
|
|
40
|
+
* ensuring each job runs only once even if scheduled by multiple instances.
|
|
41
|
+
*
|
|
42
|
+
* **Multi-Instance Setup**: Use the `runJobs` config to control execution:
|
|
43
|
+
* - Set `runJobs: true` on ONE instance to execute jobs
|
|
44
|
+
* - Set `runJobs: false` on other instances to only manage jobs (add/delete/pause/resume)
|
|
45
|
+
*
|
|
36
46
|
* @example
|
|
37
47
|
* ```typescript
|
|
38
|
-
*
|
|
48
|
+
* // Execution instance (runs jobs)
|
|
49
|
+
* const scheduler = new LocalScheduler({ folder: '~/.smyth/scheduler', runJobs: true });
|
|
50
|
+
*
|
|
51
|
+
* // Management-only instance (no execution)
|
|
52
|
+
* const managerScheduler = new LocalScheduler({ folder: '~/.smyth/scheduler', runJobs: false });
|
|
53
|
+
*
|
|
39
54
|
* const candidate = new AccessCandidate(TAccessRole.User, 'user123');
|
|
40
55
|
* const requester = scheduler.requester(candidate);
|
|
41
56
|
*
|
|
@@ -51,10 +66,11 @@ export declare class LocalScheduler extends SchedulerConnector {
|
|
|
51
66
|
protected _settings?: LocalSchedulerConfig;
|
|
52
67
|
name: string;
|
|
53
68
|
id: string;
|
|
69
|
+
private static jobs;
|
|
70
|
+
private static timers;
|
|
54
71
|
private folder;
|
|
55
72
|
private jobsPrefix;
|
|
56
73
|
private runtimePrefix;
|
|
57
|
-
private jobs;
|
|
58
74
|
private isInitialized;
|
|
59
75
|
private config;
|
|
60
76
|
constructor(_settings?: LocalSchedulerConfig);
|
|
@@ -73,12 +89,12 @@ export declare class LocalScheduler extends SchedulerConnector {
|
|
|
73
89
|
private getCandidateFolderName;
|
|
74
90
|
/**
|
|
75
91
|
* Get the job configuration file path
|
|
76
|
-
* Format: scheduler/jobs/<username>.user/<
|
|
92
|
+
* Format: scheduler/jobs/<username>.user/<role_id_jobId>.json
|
|
77
93
|
*/
|
|
78
94
|
private getJobFilePath;
|
|
79
95
|
/**
|
|
80
96
|
* Get the runtime data file path
|
|
81
|
-
* Format: scheduler/.jobs.runtime/<username>.user/<
|
|
97
|
+
* Format: scheduler/.jobs.runtime/<username>.user/<role_id_jobId>.json
|
|
82
98
|
*/
|
|
83
99
|
private getRuntimeFilePath;
|
|
84
100
|
/**
|
|
@@ -104,10 +120,15 @@ export declare class LocalScheduler extends SchedulerConnector {
|
|
|
104
120
|
/**
|
|
105
121
|
* Schedule a job for execution
|
|
106
122
|
* Jobs are fully serializable and can be executed after restart
|
|
123
|
+
*
|
|
124
|
+
* **Multi-Instance Safety**: Before scheduling, checks if a timer already exists
|
|
125
|
+
* for this job (from another scheduler instance) and clears it. This ensures
|
|
126
|
+
* each job has exactly one active timer across all instances.
|
|
107
127
|
*/
|
|
108
128
|
private scheduleJob;
|
|
109
129
|
/**
|
|
110
130
|
* Unschedule a job
|
|
131
|
+
* Uses the job key (not just jobId) to access the static timer storage
|
|
111
132
|
*/
|
|
112
133
|
private unscheduleJob;
|
|
113
134
|
/**
|
|
@@ -119,13 +140,16 @@ export declare class LocalScheduler extends SchedulerConnector {
|
|
|
119
140
|
*/
|
|
120
141
|
getResourceACL(resourceId: string, candidate: IAccessCandidate): Promise<ACL>;
|
|
121
142
|
protected list(acRequest: AccessRequest): Promise<IScheduledJob[]>;
|
|
122
|
-
protected add(acRequest: AccessRequest, jobId: string,
|
|
143
|
+
protected add(acRequest: AccessRequest, jobId: string, job: Job, schedule: Schedule): Promise<void>;
|
|
123
144
|
protected delete(acRequest: AccessRequest, jobId: string): Promise<void>;
|
|
124
145
|
protected get(acRequest: AccessRequest, jobId: string): Promise<IScheduledJob | undefined>;
|
|
125
146
|
protected pause(acRequest: AccessRequest, jobId: string): Promise<void>;
|
|
126
147
|
protected resume(acRequest: AccessRequest, jobId: string): Promise<void>;
|
|
127
148
|
/**
|
|
128
149
|
* Cleanup - stop all scheduled jobs
|
|
150
|
+
*
|
|
151
|
+
* Note: This clears ALL timers in the static storage, affecting all instances.
|
|
152
|
+
* Use with caution in multi-instance environments.
|
|
129
153
|
*/
|
|
130
154
|
shutdown(): Promise<void>;
|
|
131
155
|
}
|
|
@@ -69,14 +69,11 @@ export declare class PerplexityConnector extends LLMConnector {
|
|
|
69
69
|
text?: string;
|
|
70
70
|
functionCall?: {
|
|
71
71
|
name: string;
|
|
72
|
-
args: string
|
|
72
|
+
args: string | Record<string, any>;
|
|
73
73
|
};
|
|
74
74
|
functionResponse?: {
|
|
75
75
|
name: string;
|
|
76
|
-
response:
|
|
77
|
-
name: string;
|
|
78
|
-
content: string;
|
|
79
|
-
};
|
|
76
|
+
response: any;
|
|
80
77
|
};
|
|
81
78
|
}[];
|
|
82
79
|
tool_calls?: ToolData[];
|
package/dist/types/subsystems/LLMManager/LLM.service/connectors/openai/OpenAIConnector.class.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare class OpenAIConnector extends LLMConnector {
|
|
|
14
14
|
* Determine the appropriate interface type based on context and capabilities
|
|
15
15
|
*/
|
|
16
16
|
private getInterfaceType;
|
|
17
|
-
protected getClient(
|
|
17
|
+
protected getClient(context: ILLMRequestContext): Promise<OpenAI>;
|
|
18
18
|
protected request({ acRequest, body, context }: ILLMRequestFuncParams): Promise<TLLMChatResponse>;
|
|
19
19
|
protected streamRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
|
|
20
20
|
protected imageGenRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<OpenAI.ImagesResponse>;
|
|
@@ -44,14 +44,11 @@ export declare class OpenAIConnector extends LLMConnector {
|
|
|
44
44
|
text?: string;
|
|
45
45
|
functionCall?: {
|
|
46
46
|
name: string;
|
|
47
|
-
args: string
|
|
47
|
+
args: string | Record<string, any>;
|
|
48
48
|
};
|
|
49
49
|
functionResponse?: {
|
|
50
50
|
name: string;
|
|
51
|
-
response:
|
|
52
|
-
name: string;
|
|
53
|
-
content: string;
|
|
54
|
-
};
|
|
51
|
+
response: any;
|
|
55
52
|
};
|
|
56
53
|
}[];
|
|
57
54
|
tool_calls?: ToolData[];
|
|
@@ -108,12 +108,19 @@ export declare class ResponsesApiInterface extends OpenAIApiInterface {
|
|
|
108
108
|
* Upload files to storage
|
|
109
109
|
*/
|
|
110
110
|
private uploadFiles;
|
|
111
|
+
/**
|
|
112
|
+
* Upload file to OpenAI Files API
|
|
113
|
+
* Similar to GoogleAI's uploadFile implementation
|
|
114
|
+
*/
|
|
115
|
+
private uploadFile;
|
|
111
116
|
/**
|
|
112
117
|
* Process image files with Responses API specific formatting
|
|
118
|
+
* Uses OpenAI Files API for uploading images
|
|
113
119
|
*/
|
|
114
120
|
private processImageData;
|
|
115
121
|
/**
|
|
116
122
|
* Process document files with Responses API specific formatting
|
|
123
|
+
* Uses OpenAI Files API for uploading documents
|
|
117
124
|
*/
|
|
118
125
|
private processDocumentData;
|
|
119
126
|
/**
|
|
@@ -104,14 +104,11 @@ export declare class xAIConnector extends LLMConnector {
|
|
|
104
104
|
text?: string;
|
|
105
105
|
functionCall?: {
|
|
106
106
|
name: string;
|
|
107
|
-
args: string
|
|
107
|
+
args: string | Record<string, any>;
|
|
108
108
|
};
|
|
109
109
|
functionResponse?: {
|
|
110
110
|
name: string;
|
|
111
|
-
response:
|
|
112
|
-
name: string;
|
|
113
|
-
content: string;
|
|
114
|
-
};
|
|
111
|
+
response: any;
|
|
115
112
|
};
|
|
116
113
|
}[];
|
|
117
114
|
tool_calls?: ToolData[];
|
|
@@ -341,14 +341,11 @@ export type TLLMMessageBlock = {
|
|
|
341
341
|
text?: string;
|
|
342
342
|
functionCall?: {
|
|
343
343
|
name: string;
|
|
344
|
-
args: string
|
|
344
|
+
args: string | Record<string, any>;
|
|
345
345
|
};
|
|
346
346
|
functionResponse?: {
|
|
347
347
|
name: string;
|
|
348
|
-
response:
|
|
349
|
-
name: string;
|
|
350
|
-
content: string;
|
|
351
|
-
};
|
|
348
|
+
response: any;
|
|
352
349
|
};
|
|
353
350
|
}[];
|
|
354
351
|
tool_calls?: ToolData[];
|