@redplanethq/sdk 0.1.0
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/LICENSE +44 -0
- package/README.md +203 -0
- package/dist/index.d.mts +246 -0
- package/dist/index.d.ts +246 -0
- package/dist/index.js +273 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +263 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +49 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
|
|
3
|
+
declare enum LLMModelEnum {
|
|
4
|
+
GPT35TURBO = "GPT35TURBO",
|
|
5
|
+
GPT4TURBO = "GPT4TURBO",
|
|
6
|
+
GPT4O = "GPT4O",
|
|
7
|
+
GPT41 = "GPT41",
|
|
8
|
+
GPT41MINI = "GPT41MINI",
|
|
9
|
+
GPT41NANO = "GPT41NANO",
|
|
10
|
+
LLAMA3 = "LLAMA3",
|
|
11
|
+
CLAUDEOPUS = "CLAUDEOPUS",
|
|
12
|
+
CLAUDESONNET = "CLAUDESONNET",
|
|
13
|
+
CLAUDEHAIKU = "CLAUDEHAIKU",
|
|
14
|
+
GEMINI25FLASH = "GEMINI25FLASH",
|
|
15
|
+
GEMINI25PRO = "GEMINI25PRO",
|
|
16
|
+
GEMINI20FLASH = "GEMINI20FLASH",
|
|
17
|
+
GEMINI20FLASHLITE = "GEMINI20FLASHLITE"
|
|
18
|
+
}
|
|
19
|
+
declare enum LLMMappings {
|
|
20
|
+
GPT35TURBO = "gpt-3.5-turbo",
|
|
21
|
+
GPT4TURBO = "gpt-4-turbo",
|
|
22
|
+
GPT4O = "gpt-4o",
|
|
23
|
+
GPT41 = "gpt-4.1-2025-04-14",
|
|
24
|
+
GPT41MINI = "gpt-4.1-mini-2025-04-14",
|
|
25
|
+
GPT41NANO = "gpt-4.1-nano-2025-04-14",
|
|
26
|
+
LLAMA3 = "llama3",
|
|
27
|
+
CLAUDEOPUS = "claude-3-opus-20240229",
|
|
28
|
+
CLAUDESONNET = "claude-3-7-sonnet-20250219",
|
|
29
|
+
CLAUDEHAIKU = "claude-3-5-haiku-20241022",
|
|
30
|
+
GEMINI25FLASH = "gemini-2.5-flash-preview-04-17",
|
|
31
|
+
GEMINI25PRO = "gemini-2.5-pro-preview-03-25",
|
|
32
|
+
GEMINI20FLASH = "gemini-2.0-flash",
|
|
33
|
+
GEMINI20FLASHLITE = "gemini-2.0-flash-lite"
|
|
34
|
+
}
|
|
35
|
+
declare const OpenAIModels: LLMModelEnum[];
|
|
36
|
+
declare const ClaudeModels: LLMModelEnum[];
|
|
37
|
+
declare const GeminiModels: LLMModelEnum[];
|
|
38
|
+
declare const LLMModelType: {
|
|
39
|
+
GPT35TURBO: string;
|
|
40
|
+
GPT4TURBO: string;
|
|
41
|
+
GPT4O: string;
|
|
42
|
+
GPT41: string;
|
|
43
|
+
GPT41MINI: string;
|
|
44
|
+
GPT41NANO: string;
|
|
45
|
+
LLAMA3: string;
|
|
46
|
+
CLAUDEOPUS: string;
|
|
47
|
+
CLAUDESONNET: string;
|
|
48
|
+
CLAUDEHAIKU: string;
|
|
49
|
+
GEMINI25FLASH: string;
|
|
50
|
+
GEMINI25PRO: string;
|
|
51
|
+
GEMINI20FLASH: string;
|
|
52
|
+
GEMINI20FLASHLITE: string;
|
|
53
|
+
};
|
|
54
|
+
type LLMModelType = (typeof LLMModelType)[keyof typeof LLMModelType];
|
|
55
|
+
|
|
56
|
+
declare enum EpisodeType {
|
|
57
|
+
Conversation = "CONVERSATION",
|
|
58
|
+
Text = "TEXT"
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Interface for episodic node in the reified knowledge graph
|
|
62
|
+
* Episodes are containers for statements and represent source information
|
|
63
|
+
*/
|
|
64
|
+
interface EpisodicNode {
|
|
65
|
+
uuid: string;
|
|
66
|
+
content: string;
|
|
67
|
+
originalContent: string;
|
|
68
|
+
contentEmbedding?: number[];
|
|
69
|
+
metadata: Record<string, any>;
|
|
70
|
+
source: string;
|
|
71
|
+
createdAt: Date;
|
|
72
|
+
validAt: Date;
|
|
73
|
+
labels: string[];
|
|
74
|
+
userId: string;
|
|
75
|
+
space?: string;
|
|
76
|
+
sessionId?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Interface for entity node in the reified knowledge graph
|
|
80
|
+
* Entities represent subjects, objects, or predicates in statements
|
|
81
|
+
*/
|
|
82
|
+
interface EntityNode {
|
|
83
|
+
uuid: string;
|
|
84
|
+
name: string;
|
|
85
|
+
type: string;
|
|
86
|
+
attributes: Record<string, any>;
|
|
87
|
+
nameEmbedding: number[];
|
|
88
|
+
createdAt: Date;
|
|
89
|
+
userId: string;
|
|
90
|
+
space?: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Interface for statement node in the reified knowledge graph
|
|
94
|
+
* Statements are first-class objects representing facts with temporal properties
|
|
95
|
+
*/
|
|
96
|
+
interface StatementNode {
|
|
97
|
+
uuid: string;
|
|
98
|
+
fact: string;
|
|
99
|
+
factEmbedding: number[];
|
|
100
|
+
createdAt: Date;
|
|
101
|
+
validAt: Date;
|
|
102
|
+
invalidAt: Date | null;
|
|
103
|
+
attributes: Record<string, any>;
|
|
104
|
+
userId: string;
|
|
105
|
+
space?: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Interface for a triple in the reified knowledge graph
|
|
109
|
+
* A triple connects a subject, predicate, object via a statement node
|
|
110
|
+
* and maintains provenance information
|
|
111
|
+
*/
|
|
112
|
+
interface Triple {
|
|
113
|
+
statement: StatementNode;
|
|
114
|
+
subject: EntityNode;
|
|
115
|
+
predicate: EntityNode;
|
|
116
|
+
object: EntityNode;
|
|
117
|
+
provenance: EpisodicNode;
|
|
118
|
+
}
|
|
119
|
+
type AddEpisodeParams = {
|
|
120
|
+
episodeBody: string;
|
|
121
|
+
referenceTime: Date;
|
|
122
|
+
metadata: Record<string, any>;
|
|
123
|
+
source: string;
|
|
124
|
+
userId: string;
|
|
125
|
+
spaceId?: string;
|
|
126
|
+
sessionId?: string;
|
|
127
|
+
};
|
|
128
|
+
type AddEpisodeResult = {
|
|
129
|
+
episodeUuid: string;
|
|
130
|
+
nodesCreated: number;
|
|
131
|
+
statementsCreated: number;
|
|
132
|
+
processingTimeMs: number;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
declare enum ActionStatusEnum {
|
|
136
|
+
ACCEPT = "ACCEPT",
|
|
137
|
+
DECLINE = "DECLINE",
|
|
138
|
+
QUESTION = "QUESTION",
|
|
139
|
+
TOOL_REQUEST = "TOOL_REQUEST",
|
|
140
|
+
SUCCESS = "SUCCESS",
|
|
141
|
+
FAILED = "FAILED"
|
|
142
|
+
}
|
|
143
|
+
declare const ActionStatus: {
|
|
144
|
+
ACCEPT: string;
|
|
145
|
+
DECLINE: string;
|
|
146
|
+
QUESTION: string;
|
|
147
|
+
TOOL_REQUEST: string;
|
|
148
|
+
SUCCESS: string;
|
|
149
|
+
FAILED: string;
|
|
150
|
+
};
|
|
151
|
+
type ActionStatus = (typeof ActionStatus)[keyof typeof ActionStatus];
|
|
152
|
+
|
|
153
|
+
declare class OAuth2Params {
|
|
154
|
+
authorization_url: string;
|
|
155
|
+
authorization_params?: Record<string, string>;
|
|
156
|
+
default_scopes?: string[];
|
|
157
|
+
scope_separator?: string;
|
|
158
|
+
scope_identifier?: string;
|
|
159
|
+
token_url: string;
|
|
160
|
+
token_params?: Record<string, string>;
|
|
161
|
+
redirect_uri_metadata?: string[];
|
|
162
|
+
token_response_metadata?: string[];
|
|
163
|
+
token_expiration_buffer?: number;
|
|
164
|
+
scopes?: string[];
|
|
165
|
+
}
|
|
166
|
+
type AuthType = "OAuth2" | "APIKey";
|
|
167
|
+
declare class APIKeyParams {
|
|
168
|
+
"header_name": string;
|
|
169
|
+
"format": string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
declare enum IntegrationEventType {
|
|
173
|
+
/**
|
|
174
|
+
* Processes authentication data and returns tokens/credentials to be saved
|
|
175
|
+
*/
|
|
176
|
+
SETUP = "setup",
|
|
177
|
+
/**
|
|
178
|
+
* Processing incoming data from the integration
|
|
179
|
+
*/
|
|
180
|
+
PROCESS = "process",
|
|
181
|
+
/**
|
|
182
|
+
* Identifying which account a webhook belongs to
|
|
183
|
+
*/
|
|
184
|
+
IDENTIFY = "identify",
|
|
185
|
+
/**
|
|
186
|
+
* Scheduled synchronization of data
|
|
187
|
+
*/
|
|
188
|
+
SYNC = "sync",
|
|
189
|
+
/**
|
|
190
|
+
* For returning integration metadata/config
|
|
191
|
+
*/
|
|
192
|
+
SPEC = "spec"
|
|
193
|
+
}
|
|
194
|
+
interface IntegrationEventPayload {
|
|
195
|
+
event: IntegrationEventType;
|
|
196
|
+
[x: string]: any;
|
|
197
|
+
}
|
|
198
|
+
declare class Spec {
|
|
199
|
+
name: string;
|
|
200
|
+
key: string;
|
|
201
|
+
description: string;
|
|
202
|
+
icon: string;
|
|
203
|
+
mcp?: {
|
|
204
|
+
command: string;
|
|
205
|
+
args: string[];
|
|
206
|
+
env: Record<string, string>;
|
|
207
|
+
};
|
|
208
|
+
auth?: Record<string, OAuth2Params | APIKeyParams>;
|
|
209
|
+
}
|
|
210
|
+
interface Config {
|
|
211
|
+
access_token: string;
|
|
212
|
+
[key: string]: any;
|
|
213
|
+
}
|
|
214
|
+
interface Identifier {
|
|
215
|
+
id: string;
|
|
216
|
+
type?: string;
|
|
217
|
+
}
|
|
218
|
+
type MessageType = "spec" | "activity" | "state" | "identifier";
|
|
219
|
+
interface Message {
|
|
220
|
+
type: MessageType;
|
|
221
|
+
data: any;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
declare enum UserTypeEnum {
|
|
225
|
+
Agent = "Agent",
|
|
226
|
+
User = "User",
|
|
227
|
+
System = "System"
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
declare abstract class IntegrationCLI {
|
|
231
|
+
protected program: Command;
|
|
232
|
+
protected integrationName: string;
|
|
233
|
+
protected version: string;
|
|
234
|
+
constructor(integrationName: string, version?: string);
|
|
235
|
+
private setupProgram;
|
|
236
|
+
private setupAccountCommands;
|
|
237
|
+
private setupDataCommands;
|
|
238
|
+
private setupSpecCommand;
|
|
239
|
+
private setupSyncCommand;
|
|
240
|
+
protected abstract handleEvent(eventPayload: IntegrationEventPayload): Promise<Message[]>;
|
|
241
|
+
protected abstract getSpec(): Promise<Spec>;
|
|
242
|
+
parse(): void;
|
|
243
|
+
getProgram(): Command;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export { APIKeyParams, ActionStatus, ActionStatusEnum, type AddEpisodeParams, type AddEpisodeResult, type AuthType, ClaudeModels, type Config, type EntityNode, EpisodeType, type EpisodicNode, GeminiModels, type Identifier, IntegrationCLI, type IntegrationEventPayload, IntegrationEventType, LLMMappings, LLMModelEnum, LLMModelType, type Message, type MessageType, OAuth2Params, OpenAIModels, Spec, type StatementNode, type Triple, UserTypeEnum };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var commander = require('commander');
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
|
|
8
|
+
// ../types/dist/llm/llm.entity.js
|
|
9
|
+
exports.LLMModelEnum = void 0;
|
|
10
|
+
(function(LLMModelEnum2) {
|
|
11
|
+
LLMModelEnum2["GPT35TURBO"] = "GPT35TURBO";
|
|
12
|
+
LLMModelEnum2["GPT4TURBO"] = "GPT4TURBO";
|
|
13
|
+
LLMModelEnum2["GPT4O"] = "GPT4O";
|
|
14
|
+
LLMModelEnum2["GPT41"] = "GPT41";
|
|
15
|
+
LLMModelEnum2["GPT41MINI"] = "GPT41MINI";
|
|
16
|
+
LLMModelEnum2["GPT41NANO"] = "GPT41NANO";
|
|
17
|
+
LLMModelEnum2["LLAMA3"] = "LLAMA3";
|
|
18
|
+
LLMModelEnum2["CLAUDEOPUS"] = "CLAUDEOPUS";
|
|
19
|
+
LLMModelEnum2["CLAUDESONNET"] = "CLAUDESONNET";
|
|
20
|
+
LLMModelEnum2["CLAUDEHAIKU"] = "CLAUDEHAIKU";
|
|
21
|
+
LLMModelEnum2["GEMINI25FLASH"] = "GEMINI25FLASH";
|
|
22
|
+
LLMModelEnum2["GEMINI25PRO"] = "GEMINI25PRO";
|
|
23
|
+
LLMModelEnum2["GEMINI20FLASH"] = "GEMINI20FLASH";
|
|
24
|
+
LLMModelEnum2["GEMINI20FLASHLITE"] = "GEMINI20FLASHLITE";
|
|
25
|
+
})(exports.LLMModelEnum || (exports.LLMModelEnum = {}));
|
|
26
|
+
var LLMModelType = {
|
|
27
|
+
GPT35TURBO: "GPT35TURBO",
|
|
28
|
+
GPT4TURBO: "GPT4TURBO",
|
|
29
|
+
GPT4O: "GPT4O",
|
|
30
|
+
GPT41: "GPT41",
|
|
31
|
+
GPT41MINI: "GPT41MINI",
|
|
32
|
+
GPT41NANO: "GPT41NANO",
|
|
33
|
+
LLAMA3: "LLAMA3",
|
|
34
|
+
CLAUDEOPUS: "CLAUDEOPUS",
|
|
35
|
+
CLAUDESONNET: "CLAUDESONNET",
|
|
36
|
+
CLAUDEHAIKU: "CLAUDEHAIKU",
|
|
37
|
+
GEMINI25FLASH: "GEMINI25FLASH",
|
|
38
|
+
GEMINI25PRO: "GEMINI25PRO",
|
|
39
|
+
GEMINI20FLASH: "GEMINI20FLASH",
|
|
40
|
+
GEMINI20FLASHLITE: "GEMINI20FLASHLITE"
|
|
41
|
+
};
|
|
42
|
+
exports.LLMMappings = void 0;
|
|
43
|
+
(function(LLMMappings2) {
|
|
44
|
+
LLMMappings2["GPT35TURBO"] = "gpt-3.5-turbo";
|
|
45
|
+
LLMMappings2["GPT4TURBO"] = "gpt-4-turbo";
|
|
46
|
+
LLMMappings2["GPT4O"] = "gpt-4o";
|
|
47
|
+
LLMMappings2["GPT41"] = "gpt-4.1-2025-04-14";
|
|
48
|
+
LLMMappings2["GPT41MINI"] = "gpt-4.1-mini-2025-04-14";
|
|
49
|
+
LLMMappings2["GPT41NANO"] = "gpt-4.1-nano-2025-04-14";
|
|
50
|
+
LLMMappings2["LLAMA3"] = "llama3";
|
|
51
|
+
LLMMappings2["CLAUDEOPUS"] = "claude-3-opus-20240229";
|
|
52
|
+
LLMMappings2["CLAUDESONNET"] = "claude-3-7-sonnet-20250219";
|
|
53
|
+
LLMMappings2["CLAUDEHAIKU"] = "claude-3-5-haiku-20241022";
|
|
54
|
+
LLMMappings2["GEMINI25FLASH"] = "gemini-2.5-flash-preview-04-17";
|
|
55
|
+
LLMMappings2["GEMINI25PRO"] = "gemini-2.5-pro-preview-03-25";
|
|
56
|
+
LLMMappings2["GEMINI20FLASH"] = "gemini-2.0-flash";
|
|
57
|
+
LLMMappings2["GEMINI20FLASHLITE"] = "gemini-2.0-flash-lite";
|
|
58
|
+
})(exports.LLMMappings || (exports.LLMMappings = {}));
|
|
59
|
+
var OpenAIModels = [
|
|
60
|
+
exports.LLMModelEnum.GPT35TURBO,
|
|
61
|
+
exports.LLMModelEnum.GPT4TURBO,
|
|
62
|
+
exports.LLMModelEnum.GPT4O,
|
|
63
|
+
exports.LLMModelEnum.GPT41,
|
|
64
|
+
exports.LLMModelEnum.GPT41MINI,
|
|
65
|
+
exports.LLMModelEnum.GPT41NANO
|
|
66
|
+
];
|
|
67
|
+
var ClaudeModels = [
|
|
68
|
+
exports.LLMModelEnum.CLAUDEOPUS,
|
|
69
|
+
exports.LLMModelEnum.CLAUDESONNET,
|
|
70
|
+
exports.LLMModelEnum.CLAUDEHAIKU
|
|
71
|
+
];
|
|
72
|
+
var GeminiModels = [
|
|
73
|
+
exports.LLMModelEnum.GEMINI25FLASH,
|
|
74
|
+
exports.LLMModelEnum.GEMINI25PRO,
|
|
75
|
+
exports.LLMModelEnum.GEMINI20FLASH,
|
|
76
|
+
exports.LLMModelEnum.GEMINI20FLASHLITE
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
// ../types/dist/graph/graph.entity.js
|
|
80
|
+
exports.EpisodeType = void 0;
|
|
81
|
+
(function(EpisodeType2) {
|
|
82
|
+
EpisodeType2["Conversation"] = "CONVERSATION";
|
|
83
|
+
EpisodeType2["Text"] = "TEXT";
|
|
84
|
+
})(exports.EpisodeType || (exports.EpisodeType = {}));
|
|
85
|
+
|
|
86
|
+
// ../types/dist/conversation-execution-step/conversation-execution.entity.js
|
|
87
|
+
exports.ActionStatusEnum = void 0;
|
|
88
|
+
(function(ActionStatusEnum2) {
|
|
89
|
+
ActionStatusEnum2["ACCEPT"] = "ACCEPT";
|
|
90
|
+
ActionStatusEnum2["DECLINE"] = "DECLINE";
|
|
91
|
+
ActionStatusEnum2["QUESTION"] = "QUESTION";
|
|
92
|
+
ActionStatusEnum2["TOOL_REQUEST"] = "TOOL_REQUEST";
|
|
93
|
+
ActionStatusEnum2["SUCCESS"] = "SUCCESS";
|
|
94
|
+
ActionStatusEnum2["FAILED"] = "FAILED";
|
|
95
|
+
})(exports.ActionStatusEnum || (exports.ActionStatusEnum = {}));
|
|
96
|
+
var ActionStatus = {
|
|
97
|
+
ACCEPT: "ACCEPT",
|
|
98
|
+
DECLINE: "DECLINE",
|
|
99
|
+
QUESTION: "QUESTION",
|
|
100
|
+
TOOL_REQUEST: "TOOL_REQUEST",
|
|
101
|
+
SUCCESS: "SUCCESS",
|
|
102
|
+
FAILED: "FAILED"
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// ../types/dist/oauth/params.js
|
|
106
|
+
var OAuth2Params = class {
|
|
107
|
+
static {
|
|
108
|
+
__name(this, "OAuth2Params");
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
var APIKeyParams = class {
|
|
112
|
+
static {
|
|
113
|
+
__name(this, "APIKeyParams");
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// ../types/dist/integration.js
|
|
118
|
+
exports.IntegrationEventType = void 0;
|
|
119
|
+
(function(IntegrationEventType2) {
|
|
120
|
+
IntegrationEventType2["SETUP"] = "setup";
|
|
121
|
+
IntegrationEventType2["PROCESS"] = "process";
|
|
122
|
+
IntegrationEventType2["IDENTIFY"] = "identify";
|
|
123
|
+
IntegrationEventType2["SYNC"] = "sync";
|
|
124
|
+
IntegrationEventType2["SPEC"] = "spec";
|
|
125
|
+
})(exports.IntegrationEventType || (exports.IntegrationEventType = {}));
|
|
126
|
+
var Spec = class {
|
|
127
|
+
static {
|
|
128
|
+
__name(this, "Spec");
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// ../types/dist/user/index.js
|
|
133
|
+
exports.UserTypeEnum = void 0;
|
|
134
|
+
(function(UserTypeEnum2) {
|
|
135
|
+
UserTypeEnum2["Agent"] = "Agent";
|
|
136
|
+
UserTypeEnum2["User"] = "User";
|
|
137
|
+
UserTypeEnum2["System"] = "System";
|
|
138
|
+
})(exports.UserTypeEnum || (exports.UserTypeEnum = {}));
|
|
139
|
+
var IntegrationCLI = class {
|
|
140
|
+
static {
|
|
141
|
+
__name(this, "IntegrationCLI");
|
|
142
|
+
}
|
|
143
|
+
program;
|
|
144
|
+
integrationName;
|
|
145
|
+
version;
|
|
146
|
+
constructor(integrationName, version = "1.0.0") {
|
|
147
|
+
this.integrationName = integrationName;
|
|
148
|
+
this.version = version;
|
|
149
|
+
this.program = new commander.Command();
|
|
150
|
+
this.setupProgram();
|
|
151
|
+
}
|
|
152
|
+
setupProgram() {
|
|
153
|
+
this.program.name(`${this.integrationName}-integration`).description(`${this.integrationName} integration CLI`).version(this.version);
|
|
154
|
+
this.setupSpecCommand();
|
|
155
|
+
this.setupAccountCommands();
|
|
156
|
+
this.setupDataCommands();
|
|
157
|
+
this.setupSyncCommand();
|
|
158
|
+
}
|
|
159
|
+
setupAccountCommands() {
|
|
160
|
+
this.program.command("setup").description(`Set up a new ${this.integrationName} integration account`).requiredOption("--event-body <body>", "Event body JSON (e.g. OAuth response or setup data)").requiredOption("--integration-definition <definition>", "Integration definition JSON").action(async (options) => {
|
|
161
|
+
try {
|
|
162
|
+
const eventBody = JSON.parse(options.eventBody);
|
|
163
|
+
const integrationDefinition = JSON.parse(options.integrationDefinition);
|
|
164
|
+
const messages = await this.handleEvent({
|
|
165
|
+
event: exports.IntegrationEventType.SETUP,
|
|
166
|
+
eventBody,
|
|
167
|
+
integrationDefinition
|
|
168
|
+
});
|
|
169
|
+
for (const message of messages) {
|
|
170
|
+
console.log(JSON.stringify(message, null, 2));
|
|
171
|
+
}
|
|
172
|
+
} catch (error) {
|
|
173
|
+
console.error("Error during setup:", error);
|
|
174
|
+
process.exit(1);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
setupDataCommands() {
|
|
179
|
+
this.program.command("process").description(`Process ${this.integrationName} integration data`).requiredOption("--event-data <data>", "Event data JSON").requiredOption("--config <config>", "Integration configuration JSON").action(async (options) => {
|
|
180
|
+
try {
|
|
181
|
+
const eventData = JSON.parse(options.eventData);
|
|
182
|
+
const config = JSON.parse(options.config);
|
|
183
|
+
const messages = await this.handleEvent({
|
|
184
|
+
event: exports.IntegrationEventType.PROCESS,
|
|
185
|
+
eventBody: {
|
|
186
|
+
eventData
|
|
187
|
+
},
|
|
188
|
+
config
|
|
189
|
+
});
|
|
190
|
+
for (const message of messages) {
|
|
191
|
+
console.log(JSON.stringify(message, null, 2));
|
|
192
|
+
}
|
|
193
|
+
} catch (error) {
|
|
194
|
+
console.error("Error processing data:", error);
|
|
195
|
+
process.exit(1);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
this.program.command("identify").description("Identify webhook account").requiredOption("--webhook-data <data>", "Webhook data JSON").action(async (options) => {
|
|
199
|
+
try {
|
|
200
|
+
const webhookData = JSON.parse(options.webhookData);
|
|
201
|
+
const messages = await this.handleEvent({
|
|
202
|
+
event: exports.IntegrationEventType.IDENTIFY,
|
|
203
|
+
eventBody: webhookData
|
|
204
|
+
});
|
|
205
|
+
for (const message of messages) {
|
|
206
|
+
console.log(JSON.stringify(message, null, 2));
|
|
207
|
+
}
|
|
208
|
+
} catch (error) {
|
|
209
|
+
console.error("Error identifying account:", error);
|
|
210
|
+
process.exit(1);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
setupSpecCommand() {
|
|
215
|
+
this.program.command("spec").description("Get integration specification").action(async () => {
|
|
216
|
+
try {
|
|
217
|
+
const spec = await this.getSpec();
|
|
218
|
+
const message = {
|
|
219
|
+
type: "spec",
|
|
220
|
+
data: spec
|
|
221
|
+
};
|
|
222
|
+
console.log(JSON.stringify(message, null, 2));
|
|
223
|
+
} catch (error) {
|
|
224
|
+
console.error("Error getting spec:", error);
|
|
225
|
+
process.exit(1);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
setupSyncCommand() {
|
|
230
|
+
this.program.command("sync").description("Perform scheduled sync").requiredOption("--config <config>", "Integration configuration JSON").option("--state <state>", "Integration state JSON", "{}").action(async (options) => {
|
|
231
|
+
try {
|
|
232
|
+
const config = JSON.parse(options.config);
|
|
233
|
+
const state = options.state ? JSON.parse(options.state) : {};
|
|
234
|
+
const messages = await this.handleEvent({
|
|
235
|
+
event: exports.IntegrationEventType.SYNC,
|
|
236
|
+
eventBody: {},
|
|
237
|
+
config,
|
|
238
|
+
state
|
|
239
|
+
});
|
|
240
|
+
for (const message of messages) {
|
|
241
|
+
console.log(JSON.stringify(message, null, 2));
|
|
242
|
+
}
|
|
243
|
+
} catch (error) {
|
|
244
|
+
console.error("Error during sync:", error);
|
|
245
|
+
process.exit(1);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Parse and execute the CLI commands
|
|
251
|
+
*/
|
|
252
|
+
parse() {
|
|
253
|
+
this.program.parse();
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Get the commander program instance for additional customization
|
|
257
|
+
*/
|
|
258
|
+
getProgram() {
|
|
259
|
+
return this.program;
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
exports.APIKeyParams = APIKeyParams;
|
|
264
|
+
exports.ActionStatus = ActionStatus;
|
|
265
|
+
exports.ClaudeModels = ClaudeModels;
|
|
266
|
+
exports.GeminiModels = GeminiModels;
|
|
267
|
+
exports.IntegrationCLI = IntegrationCLI;
|
|
268
|
+
exports.LLMModelType = LLMModelType;
|
|
269
|
+
exports.OAuth2Params = OAuth2Params;
|
|
270
|
+
exports.OpenAIModels = OpenAIModels;
|
|
271
|
+
exports.Spec = Spec;
|
|
272
|
+
//# sourceMappingURL=index.js.map
|
|
273
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../types/dist/llm/llm.entity.js","../../types/dist/graph/graph.entity.js","../../types/dist/conversation-execution-step/conversation-execution.entity.js","../../types/dist/oauth/params.js","../../types/dist/integration.js","../../types/dist/user/index.js","../src/integrations/integration_cli.ts"],"names":["LLMModelEnum","LLMModelType","GPT35TURBO","GPT4TURBO","GPT4O","GPT41","GPT41MINI","GPT41NANO","LLAMA3","CLAUDEOPUS","CLAUDESONNET","CLAUDEHAIKU","GEMINI25FLASH","GEMINI25PRO","GEMINI20FLASH","GEMINI20FLASHLITE","LLMMappings","OpenAIModels","ClaudeModels","GeminiModels","EpisodeType","ActionStatusEnum","ActionStatus","ACCEPT","DECLINE","QUESTION","TOOL_REQUEST","SUCCESS","FAILED","OAuth2Params","APIKeyParams","IntegrationEventType","Spec","UserTypeEnum","IntegrationCLI","program","integrationName","version","constructor","Command","setupProgram","name","description","setupSpecCommand","setupAccountCommands","setupDataCommands","setupSyncCommand","command","requiredOption","action","options","eventBody","JSON","parse","integrationDefinition","messages","handleEvent","event","SETUP","message","console","log","stringify","error","process","exit","eventData","config","PROCESS","webhookData","IDENTIFY","spec","getSpec","type","data","option","state","SYN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xC,QAAMS,MAAAA,KAAAA,GAAQ1B,QAAQ0B,KAAQxB,GAAAA,IAAAA,CAAKC,MAAMH,OAAQ0B,CAAAA,KAAK,IAAI,EAAC;AAE3D,QAAMrB,MAAAA,QAAAA,GAAsB,MAAM,IAAA,CAAKC,WAAY,CAAA;AACjDC,UAAAA,KAAAA,EAAO1B,4BAAqB8C,CAAAA,IAAAA;AAC5B1B,UAAAA,SAAAA,EAAW,EAAC;AACZgB,UAAAA,MAAAA;AACAS,UAAAA;SACF,CAAA;AAEA,QAAA,KAAA,MAAWjB,WAAWJ,QAAU,EAAA;AAC9BK,UAAAA,OAAAA,CAAQC,IAAIT,IAAKU,CAAAA,SAAAA,CAAUH,OAAS,EAAA,IAAA,EAAM,CAAA,CAAA,CAAA;AAC5C;AACF,OAAA,CAAA,OAASI,KAAO,EAAA;AACdH,QAAQG,OAAAA,CAAAA,KAAAA,CAAM,sBAAsBA,KAAAA,CAAAA;AACpCC,QAAAA,OAAAA,CAAQC,KAAK,CAAA,CAAA;AACf;KACF,CAAA;AACJ;;;;EAoBOZ,KAAc,GAAA;AACnB,IAAA,IAAA,CAAKlB,QAAQkB,KAAK,EAAA;AACpB;;;;EAKOyB,UAAsB,GAAA;AAC3B,IAAA,OAAO,IAAK3C,CAAAA,OAAAA;AACd;AACF","file":"index.js","sourcesContent":["export var LLMModelEnum;\n(function (LLMModelEnum) {\n LLMModelEnum[\"GPT35TURBO\"] = \"GPT35TURBO\";\n LLMModelEnum[\"GPT4TURBO\"] = \"GPT4TURBO\";\n LLMModelEnum[\"GPT4O\"] = \"GPT4O\";\n LLMModelEnum[\"GPT41\"] = \"GPT41\";\n LLMModelEnum[\"GPT41MINI\"] = \"GPT41MINI\";\n LLMModelEnum[\"GPT41NANO\"] = \"GPT41NANO\";\n LLMModelEnum[\"LLAMA3\"] = \"LLAMA3\";\n LLMModelEnum[\"CLAUDEOPUS\"] = \"CLAUDEOPUS\";\n LLMModelEnum[\"CLAUDESONNET\"] = \"CLAUDESONNET\";\n LLMModelEnum[\"CLAUDEHAIKU\"] = \"CLAUDEHAIKU\";\n LLMModelEnum[\"GEMINI25FLASH\"] = \"GEMINI25FLASH\";\n LLMModelEnum[\"GEMINI25PRO\"] = \"GEMINI25PRO\";\n LLMModelEnum[\"GEMINI20FLASH\"] = \"GEMINI20FLASH\";\n LLMModelEnum[\"GEMINI20FLASHLITE\"] = \"GEMINI20FLASHLITE\";\n})(LLMModelEnum || (LLMModelEnum = {}));\nexport const LLMModelType = {\n GPT35TURBO: \"GPT35TURBO\",\n GPT4TURBO: \"GPT4TURBO\",\n GPT4O: \"GPT4O\",\n GPT41: \"GPT41\",\n GPT41MINI: \"GPT41MINI\",\n GPT41NANO: \"GPT41NANO\",\n LLAMA3: \"LLAMA3\",\n CLAUDEOPUS: \"CLAUDEOPUS\",\n CLAUDESONNET: \"CLAUDESONNET\",\n CLAUDEHAIKU: \"CLAUDEHAIKU\",\n GEMINI25FLASH: \"GEMINI25FLASH\",\n GEMINI25PRO: \"GEMINI25PRO\",\n GEMINI20FLASH: \"GEMINI20FLASH\",\n GEMINI20FLASHLITE: \"GEMINI20FLASHLITE\",\n};\nexport var LLMMappings;\n(function (LLMMappings) {\n LLMMappings[\"GPT35TURBO\"] = \"gpt-3.5-turbo\";\n LLMMappings[\"GPT4TURBO\"] = \"gpt-4-turbo\";\n LLMMappings[\"GPT4O\"] = \"gpt-4o\";\n LLMMappings[\"GPT41\"] = \"gpt-4.1-2025-04-14\";\n LLMMappings[\"GPT41MINI\"] = \"gpt-4.1-mini-2025-04-14\";\n LLMMappings[\"GPT41NANO\"] = \"gpt-4.1-nano-2025-04-14\";\n LLMMappings[\"LLAMA3\"] = \"llama3\";\n LLMMappings[\"CLAUDEOPUS\"] = \"claude-3-opus-20240229\";\n LLMMappings[\"CLAUDESONNET\"] = \"claude-3-7-sonnet-20250219\";\n LLMMappings[\"CLAUDEHAIKU\"] = \"claude-3-5-haiku-20241022\";\n LLMMappings[\"GEMINI25FLASH\"] = \"gemini-2.5-flash-preview-04-17\";\n LLMMappings[\"GEMINI25PRO\"] = \"gemini-2.5-pro-preview-03-25\";\n LLMMappings[\"GEMINI20FLASH\"] = \"gemini-2.0-flash\";\n LLMMappings[\"GEMINI20FLASHLITE\"] = \"gemini-2.0-flash-lite\";\n})(LLMMappings || (LLMMappings = {}));\nexport const OpenAIModels = [\n LLMModelEnum.GPT35TURBO,\n LLMModelEnum.GPT4TURBO,\n LLMModelEnum.GPT4O,\n LLMModelEnum.GPT41,\n LLMModelEnum.GPT41MINI,\n LLMModelEnum.GPT41NANO,\n];\nexport const ClaudeModels = [\n LLMModelEnum.CLAUDEOPUS,\n LLMModelEnum.CLAUDESONNET,\n LLMModelEnum.CLAUDEHAIKU,\n];\nexport const GeminiModels = [\n LLMModelEnum.GEMINI25FLASH,\n LLMModelEnum.GEMINI25PRO,\n LLMModelEnum.GEMINI20FLASH,\n LLMModelEnum.GEMINI20FLASHLITE,\n];\n","export var EpisodeType;\n(function (EpisodeType) {\n EpisodeType[\"Conversation\"] = \"CONVERSATION\";\n EpisodeType[\"Text\"] = \"TEXT\";\n})(EpisodeType || (EpisodeType = {}));\n","export var ActionStatusEnum;\n(function (ActionStatusEnum) {\n ActionStatusEnum[\"ACCEPT\"] = \"ACCEPT\";\n ActionStatusEnum[\"DECLINE\"] = \"DECLINE\";\n ActionStatusEnum[\"QUESTION\"] = \"QUESTION\";\n ActionStatusEnum[\"TOOL_REQUEST\"] = \"TOOL_REQUEST\";\n ActionStatusEnum[\"SUCCESS\"] = \"SUCCESS\";\n ActionStatusEnum[\"FAILED\"] = \"FAILED\";\n})(ActionStatusEnum || (ActionStatusEnum = {}));\nexport const ActionStatus = {\n ACCEPT: \"ACCEPT\",\n DECLINE: \"DECLINE\",\n QUESTION: \"QUESTION\",\n TOOL_REQUEST: \"TOOL_REQUEST\",\n SUCCESS: \"SUCCESS\",\n FAILED: \"FAILED\",\n};\n","export class OAuth2Params {\n}\nexport class APIKeyParams {\n}\n","export var IntegrationEventType;\n(function (IntegrationEventType) {\n /**\n * Processes authentication data and returns tokens/credentials to be saved\n */\n IntegrationEventType[\"SETUP\"] = \"setup\";\n /**\n * Processing incoming data from the integration\n */\n IntegrationEventType[\"PROCESS\"] = \"process\";\n /**\n * Identifying which account a webhook belongs to\n */\n IntegrationEventType[\"IDENTIFY\"] = \"identify\";\n /**\n * Scheduled synchronization of data\n */\n IntegrationEventType[\"SYNC\"] = \"sync\";\n /**\n * For returning integration metadata/config\n */\n IntegrationEventType[\"SPEC\"] = \"spec\";\n})(IntegrationEventType || (IntegrationEventType = {}));\nexport class Spec {\n}\n","export var UserTypeEnum;\n(function (UserTypeEnum) {\n UserTypeEnum[\"Agent\"] = \"Agent\";\n UserTypeEnum[\"User\"] = \"User\";\n UserTypeEnum[\"System\"] = \"System\";\n})(UserTypeEnum || (UserTypeEnum = {}));\n","import { Command } from 'commander';\nimport {\n IntegrationEventPayload,\n Spec,\n Message,\n IntegrationEventType,\n} from '@core/types';\n\nexport abstract class IntegrationCLI {\n protected program: Command;\n protected integrationName: string;\n protected version: string;\n\n constructor(integrationName: string, version: string = '1.0.0') {\n this.integrationName = integrationName;\n this.version = version;\n this.program = new Command();\n this.setupProgram();\n }\n\n private setupProgram(): void {\n this.program\n .name(`${this.integrationName}-integration`)\n .description(`${this.integrationName} integration CLI`)\n .version(this.version);\n\n this.setupSpecCommand();\n this.setupAccountCommands();\n this.setupDataCommands();\n this.setupSyncCommand();\n }\n\n private setupAccountCommands(): void {\n this.program\n .command('setup')\n .description(`Set up a new ${this.integrationName} integration account`)\n .requiredOption(\n '--event-body <body>',\n 'Event body JSON (e.g. OAuth response or setup data)',\n )\n .requiredOption(\n '--integration-definition <definition>',\n 'Integration definition JSON',\n )\n .action(async (options) => {\n try {\n const eventBody = JSON.parse(options.eventBody);\n const integrationDefinition = JSON.parse(\n options.integrationDefinition,\n );\n\n const messages: Message[] = await this.handleEvent({\n event: IntegrationEventType.SETUP,\n eventBody,\n integrationDefinition,\n });\n\n for (const message of messages) {\n console.log(JSON.stringify(message, null, 2));\n }\n } catch (error) {\n console.error('Error during setup:', error);\n process.exit(1);\n }\n });\n }\n\n private setupDataCommands(): void {\n this.program\n .command('process')\n .description(`Process ${this.integrationName} integration data`)\n .requiredOption('--event-data <data>', 'Event data JSON')\n .requiredOption('--config <config>', 'Integration configuration JSON')\n .action(async (options) => {\n try {\n const eventData = JSON.parse(options.eventData);\n const config = JSON.parse(options.config);\n\n const messages: Message[] = await this.handleEvent({\n event: IntegrationEventType.PROCESS,\n eventBody: { eventData },\n config,\n });\n\n for (const message of messages) {\n console.log(JSON.stringify(message, null, 2));\n }\n } catch (error) {\n console.error('Error processing data:', error);\n process.exit(1);\n }\n });\n\n this.program\n .command('identify')\n .description('Identify webhook account')\n .requiredOption('--webhook-data <data>', 'Webhook data JSON')\n .action(async (options) => {\n try {\n const webhookData = JSON.parse(options.webhookData);\n\n const messages: Message[] = await this.handleEvent({\n event: IntegrationEventType.IDENTIFY,\n eventBody: webhookData,\n });\n\n for (const message of messages) {\n console.log(JSON.stringify(message, null, 2));\n }\n } catch (error) {\n console.error('Error identifying account:', error);\n process.exit(1);\n }\n });\n }\n\n private setupSpecCommand(): void {\n this.program\n .command('spec')\n .description('Get integration specification')\n .action(async () => {\n try {\n const spec = await this.getSpec();\n const message: Message = {\n type: 'spec',\n data: spec,\n };\n // For spec, we keep the single message output for compatibility\n console.log(JSON.stringify(message, null, 2));\n } catch (error) {\n console.error('Error getting spec:', error);\n process.exit(1);\n }\n });\n }\n\n private setupSyncCommand(): void {\n this.program\n .command('sync')\n .description('Perform scheduled sync')\n .requiredOption('--config <config>', 'Integration configuration JSON')\n .option('--state <state>', 'Integration state JSON', '{}')\n .action(async (options) => {\n try {\n const config = JSON.parse(options.config);\n const state = options.state ? JSON.parse(options.state) : {};\n\n const messages: Message[] = await this.handleEvent({\n event: IntegrationEventType.SYNC,\n eventBody: {},\n config,\n state,\n });\n\n for (const message of messages) {\n console.log(JSON.stringify(message, null, 2));\n }\n } catch (error) {\n console.error('Error during sync:', error);\n process.exit(1);\n }\n });\n }\n\n /**\n * Abstract method that must be implemented by each integration\n * This method should handle the integration-specific logic for each event type\n * and return an array of Message objects.\n */\n protected abstract handleEvent(\n eventPayload: IntegrationEventPayload,\n ): Promise<Message[]>;\n\n /**\n * Abstract method that must be implemented by each integration\n * This method should return the integration specification\n */\n protected abstract getSpec(): Promise<Spec>;\n\n /**\n * Parse and execute the CLI commands\n */\n public parse(): void {\n this.program.parse();\n }\n\n /**\n * Get the commander program instance for additional customization\n */\n public getProgram(): Command {\n return this.program;\n }\n}\n"]}
|