@openenthrium/oe-runtime-sdk 1.7.5

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.
Files changed (91) hide show
  1. package/README.md +139 -0
  2. package/index.js +58 -0
  3. package/package.json +64 -0
  4. package/src/data/connectionTypes.json +18587 -0
  5. package/src/engine/index.js +183 -0
  6. package/src/engine/llm.js +71 -0
  7. package/src/engine/promptBuilder.js +38 -0
  8. package/src/index.js +156 -0
  9. package/src/middleware/auth.js +63 -0
  10. package/src/providers/embedding/index.js +69 -0
  11. package/src/providers/llm/index.js +136 -0
  12. package/src/routes/admin.js +686 -0
  13. package/src/routes/agents.js +193 -0
  14. package/src/routes/apiKeys.js +55 -0
  15. package/src/routes/audio.js +111 -0
  16. package/src/routes/auth.js +83 -0
  17. package/src/routes/chat.js +381 -0
  18. package/src/routes/connectors.js +435 -0
  19. package/src/routes/dashboard.js +244 -0
  20. package/src/routes/documents.js +443 -0
  21. package/src/routes/embed.js +103 -0
  22. package/src/routes/marketplace.js +49 -0
  23. package/src/routes/models.js +81 -0
  24. package/src/routes/oauth.js +423 -0
  25. package/src/routes/projects.js +238 -0
  26. package/src/routes/settings.js +45 -0
  27. package/src/routes/setup.js +42 -0
  28. package/src/routes/sso.js +218 -0
  29. package/src/routes/superadmin.js +51 -0
  30. package/src/routes/templates.js +75 -0
  31. package/src/routes/threads.js +53 -0
  32. package/src/routes/workspaces.js +464 -0
  33. package/src/telemetry/bootstrap.js +39 -0
  34. package/src/telemetry/registration.js +16 -0
  35. package/src/utils/activityLog.js +16 -0
  36. package/src/utils/agentChain.js +141 -0
  37. package/src/utils/buildVisualization.js +102 -0
  38. package/src/utils/dlpScanner.js +57 -0
  39. package/src/utils/ingestionQueue.js +240 -0
  40. package/src/utils/prepareConnectors.js +66 -0
  41. package/src/utils/rag/_settings.js +6 -0
  42. package/src/utils/rag/chroma.js +82 -0
  43. package/src/utils/rag/lancedb.js +103 -0
  44. package/src/utils/rag/milvus.js +116 -0
  45. package/src/utils/rag/pgvector.js +104 -0
  46. package/src/utils/rag/pinecone.js +71 -0
  47. package/src/utils/rag/qdrant.js +106 -0
  48. package/src/utils/rag/weaviate.js +137 -0
  49. package/src/utils/rag/zilliz.js +115 -0
  50. package/src/utils/scheduler.js +168 -0
  51. package/src/utils/tier.js +106 -0
  52. package/src/utils/tools/adapters/_template.js +74 -0
  53. package/src/utils/tools/adapters/box.js +71 -0
  54. package/src/utils/tools/adapters/confluence.js +80 -0
  55. package/src/utils/tools/adapters/database.js +215 -0
  56. package/src/utils/tools/adapters/dropbox.js +74 -0
  57. package/src/utils/tools/adapters/elasticsearch.js +90 -0
  58. package/src/utils/tools/adapters/filesystem.js +197 -0
  59. package/src/utils/tools/adapters/freshdesk.js +87 -0
  60. package/src/utils/tools/adapters/gdrive.js +326 -0
  61. package/src/utils/tools/adapters/github.js +169 -0
  62. package/src/utils/tools/adapters/gmail.js +157 -0
  63. package/src/utils/tools/adapters/graphql.js +73 -0
  64. package/src/utils/tools/adapters/hubspot.js +101 -0
  65. package/src/utils/tools/adapters/image-gen.js +120 -0
  66. package/src/utils/tools/adapters/jira.js +86 -0
  67. package/src/utils/tools/adapters/kafka.js +126 -0
  68. package/src/utils/tools/adapters/ldap.js +118 -0
  69. package/src/utils/tools/adapters/mcp-client.js +138 -0
  70. package/src/utils/tools/adapters/mongodb.js +119 -0
  71. package/src/utils/tools/adapters/mqtt.js +106 -0
  72. package/src/utils/tools/adapters/music-gen.js +118 -0
  73. package/src/utils/tools/adapters/notion.js +93 -0
  74. package/src/utils/tools/adapters/ocr.js +107 -0
  75. package/src/utils/tools/adapters/onedrive.js +72 -0
  76. package/src/utils/tools/adapters/redis.js +104 -0
  77. package/src/utils/tools/adapters/rest-api.js +119 -0
  78. package/src/utils/tools/adapters/s3.js +142 -0
  79. package/src/utils/tools/adapters/search.js +80 -0
  80. package/src/utils/tools/adapters/sftp.js +121 -0
  81. package/src/utils/tools/adapters/shell.js +97 -0
  82. package/src/utils/tools/adapters/slack.js +83 -0
  83. package/src/utils/tools/adapters/speech.js +160 -0
  84. package/src/utils/tools/adapters/ssh.js +113 -0
  85. package/src/utils/tools/adapters/video-gen.js +152 -0
  86. package/src/utils/tools/adapters/web3.js +111 -0
  87. package/src/utils/tools/adapters/zendesk.js +82 -0
  88. package/src/utils/tools/adapters/zoho-mail.js +246 -0
  89. package/src/utils/tools/registry.js +229 -0
  90. package/src/utils/vectorStore.js +68 -0
  91. package/src/utils/workflowEngine.js +4 -0
@@ -0,0 +1,229 @@
1
+ const path = require("path");
2
+ const fs = require("fs");
3
+
4
+ // Auto-discover adapters: community contributors only need to drop a .js file
5
+ // into adapters/ — no registry edit required. Filename (sans .js) = type key.
6
+ const _discovered = {};
7
+ try {
8
+ for (const file of fs.readdirSync(path.join(__dirname, "adapters"))) {
9
+ if (!file.endsWith(".js") || file.startsWith("_")) continue;
10
+ const key = file.slice(0, -3);
11
+ try {
12
+ _discovered[key] = require(`./adapters/${key}`);
13
+ } catch (err) {
14
+ console.warn(`[registry] Failed to load adapter "${file}": ${err.message}`);
15
+ }
16
+ }
17
+ } catch {
18
+ // Running inside a compiled binary — static ADAPTERS map below handles routing
19
+ }
20
+
21
+ const database = require("./adapters/database");
22
+ const restApi = require("./adapters/rest-api");
23
+ const mongodb = require("./adapters/mongodb");
24
+ const gmail = require("./adapters/gmail");
25
+ const slack = require("./adapters/slack");
26
+ const jira = require("./adapters/jira");
27
+ const confluence = require("./adapters/confluence");
28
+ const notion = require("./adapters/notion");
29
+ const hubspot = require("./adapters/hubspot");
30
+ const freshdesk = require("./adapters/freshdesk");
31
+ const zendesk = require("./adapters/zendesk");
32
+ const github = require("./adapters/github");
33
+ const zohoMail = require("./adapters/zoho-mail");
34
+ const gdrive = require("./adapters/gdrive");
35
+ const redis = require("./adapters/redis");
36
+ const elasticsearch = require("./adapters/elasticsearch");
37
+ const onedrive = require("./adapters/onedrive");
38
+ const dropbox = require("./adapters/dropbox");
39
+ const box = require("./adapters/box");
40
+ const ssh = require("./adapters/ssh");
41
+ const shell = require("./adapters/shell");
42
+ const sftp = require("./adapters/sftp");
43
+ const s3 = require("./adapters/s3");
44
+ const kafka = require("./adapters/kafka");
45
+ const mqttAdapter = require("./adapters/mqtt");
46
+ const ldap = require("./adapters/ldap");
47
+ const graphql = require("./adapters/graphql");
48
+ const web3 = require("./adapters/web3");
49
+ const mcpClient = require("./adapters/mcp-client");
50
+ const filesystem = require("./adapters/filesystem");
51
+
52
+ const ADAPTERS = {
53
+ // SQL databases
54
+ postgresql: database,
55
+ mysql: database,
56
+ mssql: database,
57
+ oracle: database,
58
+ cockroachdb: database,
59
+ sqlite: database,
60
+ snowflake: database,
61
+ bigquery: database,
62
+ mariadb: database,
63
+ tidb: database,
64
+ timescaledb: database,
65
+ singlestore: database,
66
+ db2: database,
67
+ teradata: database,
68
+ duckdb: database,
69
+ // MySQL-compatible
70
+ planetscale: database,
71
+ "vitess": database,
72
+ // PostgreSQL-compatible
73
+ neon: database,
74
+ supabase: database,
75
+ "cratedb": database,
76
+ "questdb": database,
77
+ "yugabyte": database,
78
+ "greenplum": database,
79
+ "redshift": database,
80
+ "alloydb": database,
81
+ // NoSQL / in-memory
82
+ mongodb: mongodb,
83
+ redis: redis,
84
+ elasticsearch: elasticsearch,
85
+ // File & object storage
86
+ "aws-s3": s3,
87
+ "gcs": s3,
88
+ "azure-blob": s3,
89
+ "minio": s3,
90
+ "cloudflare-r2": s3,
91
+ "wasabi": s3,
92
+ "backblaze-b2": s3,
93
+ // SFTP
94
+ sftp: sftp,
95
+ ftp: sftp,
96
+ // Messaging / queues
97
+ kafka: kafka,
98
+ "apache-kafka": kafka,
99
+ rabbitmq: kafka,
100
+ activemq: kafka,
101
+ "aws-sqs": kafka,
102
+ "azure-service-bus": kafka,
103
+ "google-pubsub": kafka,
104
+ // MQTT / IoT
105
+ mqtt: mqttAdapter,
106
+ "aws-iot": mqttAdapter,
107
+ "hivemq": mqttAdapter,
108
+ "mosquitto": mqttAdapter,
109
+ // LDAP / Directory
110
+ ldap: ldap,
111
+ "active-directory": ldap,
112
+ "azure-ad": ldap,
113
+ openldap: ldap,
114
+ // GraphQL
115
+ graphql: graphql,
116
+ "hasura": graphql,
117
+ "graphcms": graphql,
118
+ "fauna": graphql,
119
+ // Web3 / Blockchain
120
+ web3: web3,
121
+ ethereum: web3,
122
+ polygon: web3,
123
+ solana: web3,
124
+ "binance-smart-chain": web3,
125
+ avalanche: web3,
126
+ arbitrum: web3,
127
+ optimism: web3,
128
+ "infura": web3,
129
+ "alchemy": web3,
130
+ moralis: web3,
131
+ // Local filesystem
132
+ filesystem: filesystem,
133
+ "local-file": filesystem,
134
+ "local-fs": filesystem,
135
+ // MCP protocol
136
+ mcp: mcpClient,
137
+ "mcp-server": mcpClient,
138
+ // OAuth cloud storage
139
+ onedrive: onedrive,
140
+ dropbox: dropbox,
141
+ box: box,
142
+ gdrive: gdrive,
143
+ "google-drive": restApi,
144
+ sharepoint: onedrive,
145
+ // Messaging bots — baseUrl includes token, endpoints in agent.yaml
146
+ "telegram": restApi,
147
+ // REST / HTTP (explicit + fallback)
148
+ "rest-api": restApi,
149
+ "http": restApi,
150
+ // Specific SaaS adapters
151
+ gmail: gmail,
152
+ "gmail-rest": restApi,
153
+ slack: slack,
154
+ jira: jira,
155
+ confluence: confluence,
156
+ notion: notion,
157
+ hubspot: hubspot,
158
+ freshdesk: freshdesk,
159
+ zendesk: zendesk,
160
+ github: github,
161
+ "zoho-mail": zohoMail,
162
+ ssh: ssh,
163
+ // Local shell execution
164
+ shell: shell,
165
+ "local-exec": shell,
166
+ "local-shell": shell,
167
+ // Search — baseUrl + bearerToken in oe-config.json, endpoints in agent.yaml
168
+ "perplexity-search": restApi,
169
+ "perplexity": restApi,
170
+ "google-search": restApi,
171
+ "bing-search": restApi,
172
+ // OCR — baseUrl + apiKey/headerName in oe-config.json, endpoints in agent.yaml
173
+ "azure-vision": restApi,
174
+ "google-vision": restApi,
175
+ "aws-textract": restApi,
176
+ "tesseract-ocr": restApi,
177
+ // Image generation — baseUrl + bearerToken in oe-config.json, endpoints in agent.yaml
178
+ "openai-image": restApi,
179
+ "flux": restApi,
180
+ "stable-diffusion": restApi,
181
+ "ideogram": restApi,
182
+ // Speech & audio — baseUrl + apiKey/headerName in oe-config.json, endpoints in agent.yaml
183
+ "elevenlabs": restApi,
184
+ "openai-tts": restApi,
185
+ "azure-speech": restApi,
186
+ "google-tts": restApi,
187
+ // Video generation — baseUrl + bearerToken in oe-config.json, endpoints in agent.yaml
188
+ "runway": restApi,
189
+ "kling": restApi,
190
+ "pika": restApi,
191
+ // Music generation — baseUrl + bearerToken in oe-config.json, endpoints in agent.yaml
192
+ "suno": restApi,
193
+ "udio": restApi,
194
+ };
195
+
196
+ // Resolve a connector type → adapter.
197
+ // Priority: explicit ADAPTERS map → auto-discovered by filename → rest-api fallback.
198
+ function resolve(type) {
199
+ return ADAPTERS[type] || _discovered[type] || restApi;
200
+ }
201
+
202
+ function getToolDefinitions(connectors) {
203
+ const tools = [];
204
+ for (const c of connectors) tools.push(...resolve(c.type).getToolDefinitions(c));
205
+ return tools;
206
+ }
207
+
208
+ function getAnthropicToolDefinitions(connectors) {
209
+ const tools = [];
210
+ for (const c of connectors) tools.push(...resolve(c.type).getAnthropicToolDefinitions(c));
211
+ return tools;
212
+ }
213
+
214
+ async function executeTool(toolName, args, connectors, db) {
215
+ const match = toolName.match(/^conn_(\d+)_(.+)$/);
216
+ if (!match) return `Unknown tool: ${toolName}`;
217
+
218
+ const connectorId = parseInt(match[1]);
219
+ const action = match[2];
220
+ const connector = connectors.find(c => c.id === connectorId);
221
+ if (!connector) return "Connector not found.";
222
+
223
+ return resolve(connector.type).executeTool(action, args, connector, db);
224
+ }
225
+
226
+ // Set of connector type keys that have a native adapter file (used by the API to mark implemented)
227
+ const implementedTypes = new Set(Object.keys(_discovered));
228
+
229
+ module.exports = { getToolDefinitions, getAnthropicToolDefinitions, executeTool, ADAPTERS, implementedTypes };
@@ -0,0 +1,68 @@
1
+ const { PrismaClient } = require("@prisma/client");
2
+ const db = new PrismaClient();
3
+
4
+ const ADAPTERS = ["lancedb", "chroma", "pinecone", "qdrant", "weaviate", "pgvector", "milvus", "zilliz"];
5
+
6
+ async function resolveAdapter(workspaceSlug) {
7
+ let provider = null;
8
+ let config = {};
9
+
10
+ // Workspace-level override takes priority
11
+ if (workspaceSlug) {
12
+ const ws = await db.workspace.findUnique({
13
+ where: { slug: workspaceSlug },
14
+ select: { vectorDbProvider: true, vectorDbConfig: true },
15
+ });
16
+ if (ws?.vectorDbProvider) {
17
+ provider = ws.vectorDbProvider;
18
+ try { config = ws.vectorDbConfig ? JSON.parse(ws.vectorDbConfig) : {}; } catch { config = {}; }
19
+ }
20
+ }
21
+
22
+ // Fall back to instance-level setting
23
+ if (!provider) {
24
+ const s = await db.setting.findUnique({ where: { key: "vector_db_provider" } });
25
+ provider = s?.value || process.env.VECTOR_DB_PROVIDER || "lancedb";
26
+ }
27
+
28
+ if (!ADAPTERS.includes(provider)) {
29
+ console.warn(`[vectorStore] Unknown provider "${provider}", falling back to lancedb`);
30
+ provider = "lancedb";
31
+ }
32
+
33
+ const mod = require(`./rag/${provider}`);
34
+
35
+ // If workspace has custom config, bind it so callers don't need to pass it
36
+ if (Object.keys(config).length > 0) {
37
+ return {
38
+ upsertChunksBatched: (slug, uid, chunks, opts) => mod.upsertChunksBatched(slug, uid, chunks, opts, config),
39
+ similaritySearch: (slug, query, topK) => mod.similaritySearch(slug, query, topK, config),
40
+ deleteDocumentChunks:(slug, uid) => mod.deleteDocumentChunks(slug, uid, config),
41
+ };
42
+ }
43
+
44
+ return mod;
45
+ }
46
+
47
+ async function upsertChunks(workspaceSlug, documentUid, chunks) {
48
+ const adapter = await resolveAdapter(workspaceSlug);
49
+ const result = await adapter.upsertChunksBatched(workspaceSlug, documentUid, chunks, { batchSize: chunks.length });
50
+ return result.chunksProcessed;
51
+ }
52
+
53
+ async function upsertChunksBatched(workspaceSlug, documentUid, chunks, options = {}) {
54
+ const adapter = await resolveAdapter(workspaceSlug);
55
+ return adapter.upsertChunksBatched(workspaceSlug, documentUid, chunks, options);
56
+ }
57
+
58
+ async function similaritySearch(workspaceSlug, query, topK = 5) {
59
+ const adapter = await resolveAdapter(workspaceSlug);
60
+ return adapter.similaritySearch(workspaceSlug, query, topK);
61
+ }
62
+
63
+ async function deleteDocumentChunks(workspaceSlug, documentUid) {
64
+ const adapter = await resolveAdapter(workspaceSlug);
65
+ return adapter.deleteDocumentChunks(workspaceSlug, documentUid);
66
+ }
67
+
68
+ module.exports = { upsertChunks, upsertChunksBatched, similaritySearch, deleteDocumentChunks };
@@ -0,0 +1,4 @@
1
+ // Thin re-export — logic lives in engine/promptBuilder.js
2
+ // All Platform routes (chat, scheduler, v1, workspaces) import from here
3
+ // and continue to work without any changes.
4
+ module.exports = require("../engine/promptBuilder");