@superatomai/sdk-node 0.0.27 → 0.0.28

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.mts CHANGED
@@ -587,6 +587,7 @@ type CollectionOperation = 'getMany' | 'getOne' | 'query' | 'mutation' | 'update
587
587
  type CollectionHandler<TParams = any, TResult = any> = (params: TParams) => Promise<TResult> | TResult;
588
588
  type LLMProvider = 'anthropic' | 'groq' | 'gemini' | 'openai';
589
589
 
590
+ type DatabaseType = 'postgresql' | 'mssql';
590
591
  interface SuperatomSDKConfig {
591
592
  url?: string;
592
593
  apiKey?: string;
@@ -595,6 +596,7 @@ interface SuperatomSDKConfig {
595
596
  type?: string;
596
597
  bundleDir?: string;
597
598
  promptsDir?: string;
599
+ databaseType?: DatabaseType;
598
600
  ANTHROPIC_API_KEY?: string;
599
601
  GROQ_API_KEY?: string;
600
602
  GEMINI_API_KEY?: string;
@@ -1644,6 +1646,7 @@ declare class SuperatomSDK {
1644
1646
  private geminiApiKey;
1645
1647
  private openaiApiKey;
1646
1648
  private llmProviders;
1649
+ private databaseType;
1647
1650
  private userManager;
1648
1651
  private dashboardManager;
1649
1652
  private reportManager;
@@ -1725,4 +1728,4 @@ declare class SuperatomSDK {
1725
1728
  getTools(): Tool$1[];
1726
1729
  }
1727
1730
 
1728
- export { type Action, BM25L, type BM25LOptions, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CollectionHandler, type CollectionOperation, type DBUIBlock, type HybridSearchOptions, type IncomingMessage, type KbNodesQueryFilters, type KbNodesRequestPayload, LLM, type LogLevel, type Message, type RerankedResult, SDK_VERSION, STORAGE_CONFIG, SuperatomSDK, type SuperatomSDKConfig, Thread, ThreadManager, type Tool$1 as Tool, UIBlock, UILogCollector, type User, UserManager, type UsersData, hybridRerank, logger, rerankChromaResults, rerankConversationResults };
1731
+ export { type Action, BM25L, type BM25LOptions, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CollectionHandler, type CollectionOperation, type DBUIBlock, type DatabaseType, type HybridSearchOptions, type IncomingMessage, type KbNodesQueryFilters, type KbNodesRequestPayload, LLM, type LogLevel, type Message, type RerankedResult, SDK_VERSION, STORAGE_CONFIG, SuperatomSDK, type SuperatomSDKConfig, Thread, ThreadManager, type Tool$1 as Tool, UIBlock, UILogCollector, type User, UserManager, type UsersData, hybridRerank, logger, rerankChromaResults, rerankConversationResults };
package/dist/index.d.ts CHANGED
@@ -587,6 +587,7 @@ type CollectionOperation = 'getMany' | 'getOne' | 'query' | 'mutation' | 'update
587
587
  type CollectionHandler<TParams = any, TResult = any> = (params: TParams) => Promise<TResult> | TResult;
588
588
  type LLMProvider = 'anthropic' | 'groq' | 'gemini' | 'openai';
589
589
 
590
+ type DatabaseType = 'postgresql' | 'mssql';
590
591
  interface SuperatomSDKConfig {
591
592
  url?: string;
592
593
  apiKey?: string;
@@ -595,6 +596,7 @@ interface SuperatomSDKConfig {
595
596
  type?: string;
596
597
  bundleDir?: string;
597
598
  promptsDir?: string;
599
+ databaseType?: DatabaseType;
598
600
  ANTHROPIC_API_KEY?: string;
599
601
  GROQ_API_KEY?: string;
600
602
  GEMINI_API_KEY?: string;
@@ -1644,6 +1646,7 @@ declare class SuperatomSDK {
1644
1646
  private geminiApiKey;
1645
1647
  private openaiApiKey;
1646
1648
  private llmProviders;
1649
+ private databaseType;
1647
1650
  private userManager;
1648
1651
  private dashboardManager;
1649
1652
  private reportManager;
@@ -1725,4 +1728,4 @@ declare class SuperatomSDK {
1725
1728
  getTools(): Tool$1[];
1726
1729
  }
1727
1730
 
1728
- export { type Action, BM25L, type BM25LOptions, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CollectionHandler, type CollectionOperation, type DBUIBlock, type HybridSearchOptions, type IncomingMessage, type KbNodesQueryFilters, type KbNodesRequestPayload, LLM, type LogLevel, type Message, type RerankedResult, SDK_VERSION, STORAGE_CONFIG, SuperatomSDK, type SuperatomSDKConfig, Thread, ThreadManager, type Tool$1 as Tool, UIBlock, UILogCollector, type User, UserManager, type UsersData, hybridRerank, logger, rerankChromaResults, rerankConversationResults };
1731
+ export { type Action, BM25L, type BM25LOptions, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CollectionHandler, type CollectionOperation, type DBUIBlock, type DatabaseType, type HybridSearchOptions, type IncomingMessage, type KbNodesQueryFilters, type KbNodesRequestPayload, LLM, type LogLevel, type Message, type RerankedResult, SDK_VERSION, STORAGE_CONFIG, SuperatomSDK, type SuperatomSDKConfig, Thread, ThreadManager, type Tool$1 as Tool, UIBlock, UILogCollector, type User, UserManager, type UsersData, hybridRerank, logger, rerankChromaResults, rerankConversationResults };
package/dist/index.js CHANGED
@@ -2936,7 +2936,9 @@ If adaptation is not possible or would fundamentally change the component:
2936
2936
  var PromptLoader = class {
2937
2937
  constructor(config) {
2938
2938
  this.promptCache = /* @__PURE__ */ new Map();
2939
+ this.databaseRulesCache = /* @__PURE__ */ new Map();
2939
2940
  this.isInitialized = false;
2941
+ this.databaseType = "postgresql";
2940
2942
  logger.debug("Initializing PromptLoader...");
2941
2943
  this.promptsDir = config?.promptsDir || import_path2.default.join(process.cwd(), ".prompts");
2942
2944
  logger.debug(`Prompts directory set to: ${this.promptsDir}`);
@@ -3082,6 +3084,76 @@ var PromptLoader = class {
3082
3084
  getCacheSize() {
3083
3085
  return this.promptCache.size;
3084
3086
  }
3087
+ /**
3088
+ * Set the database type for SQL rules loading
3089
+ * @param type - Database type ('postgresql' | 'mssql')
3090
+ */
3091
+ setDatabaseType(type) {
3092
+ this.databaseType = type;
3093
+ this.databaseRulesCache.clear();
3094
+ logger.debug(`Database type set to: ${type}`);
3095
+ }
3096
+ /**
3097
+ * Get current database type
3098
+ * @returns Database type string
3099
+ */
3100
+ getDatabaseType() {
3101
+ return this.databaseType;
3102
+ }
3103
+ /**
3104
+ * Load database-specific SQL rules from file system
3105
+ * Falls back to minimal default rules if file not found
3106
+ * @returns Database rules as a string
3107
+ */
3108
+ async loadDatabaseRules() {
3109
+ if (this.databaseRulesCache.has(this.databaseType)) {
3110
+ logger.debug(`\u2713 Database rules for '${this.databaseType}' loaded from cache`);
3111
+ return this.databaseRulesCache.get(this.databaseType);
3112
+ }
3113
+ const rulesPath = import_path2.default.join(this.promptsDir, "database-rules", `${this.databaseType}.md`);
3114
+ try {
3115
+ if (import_fs3.default.existsSync(rulesPath)) {
3116
+ const rules = import_fs3.default.readFileSync(rulesPath, "utf-8");
3117
+ this.databaseRulesCache.set(this.databaseType, rules);
3118
+ logger.info(`\u2713 Loaded database rules for '${this.databaseType}' from ${rulesPath}`);
3119
+ return rules;
3120
+ }
3121
+ } catch (error) {
3122
+ logger.warn(`Could not load database rules for '${this.databaseType}' from file system: ${error}`);
3123
+ }
3124
+ const defaultRules = this.getDefaultDatabaseRules();
3125
+ this.databaseRulesCache.set(this.databaseType, defaultRules);
3126
+ logger.warn(`Using default database rules for '${this.databaseType}' (file not found at ${rulesPath})`);
3127
+ return defaultRules;
3128
+ }
3129
+ /**
3130
+ * Get default database rules as fallback
3131
+ * @returns Minimal database rules
3132
+ */
3133
+ getDefaultDatabaseRules() {
3134
+ if (this.databaseType === "mssql") {
3135
+ return `**Database Type: Microsoft SQL Server**
3136
+
3137
+ **SQL Query Rules:**
3138
+ - Use \`TOP N\` for row limiting (e.g., \`SELECT TOP 32 * FROM table\`)
3139
+ - Use \`1\` for true, \`0\` for false (no native boolean)
3140
+ - Use \`+\` or \`CONCAT()\` for string concatenation
3141
+ - Use \`GETDATE()\` for current timestamp
3142
+ - Use \`CAST()\` or \`CONVERT()\` for type casting
3143
+ - Use \`OUTPUT INSERTED.*\` instead of \`RETURNING\`
3144
+ - NULL values: Use \`NULL\` keyword without quotes`;
3145
+ }
3146
+ return `**Database Type: PostgreSQL**
3147
+
3148
+ **SQL Query Rules:**
3149
+ - Use \`LIMIT N\` for row limiting (e.g., \`SELECT * FROM table LIMIT 32\`)
3150
+ - Use \`true\` / \`false\` for boolean values
3151
+ - Use \`||\` for string concatenation
3152
+ - Use \`NOW()\` for current timestamp
3153
+ - Use \`::TYPE\` or \`CAST()\` for type casting
3154
+ - Use \`RETURNING\` clause for mutations
3155
+ - NULL values: Use \`NULL\` keyword without quotes`;
3156
+ }
3085
3157
  };
3086
3158
  var defaultPromptsPath = process.env.PROMPTS_DIR || import_path2.default.join(process.cwd(), ".prompts");
3087
3159
  var promptLoader = new PromptLoader({
@@ -4240,6 +4312,7 @@ ${JSON.stringify(tool.requiredFields || [], null, 2)}`;
4240
4312
  }).join("\n\n");
4241
4313
  }
4242
4314
  const schemaDoc = schema.generateSchemaDocumentation();
4315
+ const databaseRules = await promptLoader.loadDatabaseRules();
4243
4316
  logger.file("\n=============================\nText analysis response:", analysisContent);
4244
4317
  logger.file("\n=============================\nDeferred tools:", deferredToolsText);
4245
4318
  logger.file("\n=============================\nExecuted tools:", executedToolsText);
@@ -4247,6 +4320,7 @@ ${JSON.stringify(tool.requiredFields || [], null, 2)}`;
4247
4320
  ANALYSIS_CONTENT: analysisContent,
4248
4321
  AVAILABLE_COMPONENTS: availableComponentsText,
4249
4322
  SCHEMA_DOC: schemaDoc,
4323
+ DATABASE_RULES: databaseRules,
4250
4324
  DEFERRED_TOOLS: deferredToolsText,
4251
4325
  EXECUTED_TOOLS: executedToolsText
4252
4326
  });
@@ -4507,12 +4581,14 @@ ${JSON.stringify(tool.requiredFields || [], null, 2)}`;
4507
4581
  };
4508
4582
  }
4509
4583
  const schemaDoc = schema.generateSchemaDocumentation();
4584
+ const databaseRules = await promptLoader.loadDatabaseRules();
4510
4585
  const prompts = await promptLoader.loadPrompts("adapt-ui-block-params", {
4511
4586
  ORIGINAL_USER_PROMPT: originalUserPrompt,
4512
4587
  CURRENT_USER_PROMPT: currentUserPrompt,
4513
4588
  MATCHED_UI_BLOCK_COMPONENT: JSON.stringify(component, null, 2),
4514
4589
  COMPONENT_PROPS: JSON.stringify(component.props, null, 2),
4515
- SCHEMA_DOC: schemaDoc || "No schema available"
4590
+ SCHEMA_DOC: schemaDoc || "No schema available",
4591
+ DATABASE_RULES: databaseRules
4516
4592
  });
4517
4593
  const result = await LLM.stream(
4518
4594
  {
@@ -4631,6 +4707,7 @@ ${JSON.stringify(tool.requiredFields || [], null, 2)}`;
4631
4707
  availableToolsDoc = toolsDocParts.join("\n\n---\n\n");
4632
4708
  }
4633
4709
  const schemaDoc = schema.generateSchemaDocumentation();
4710
+ const databaseRules = await promptLoader.loadDatabaseRules();
4634
4711
  const knowledgeBaseContext = await knowledge_base_default.getKnowledgeBase({
4635
4712
  prompt: userPrompt,
4636
4713
  collections,
@@ -4641,6 +4718,7 @@ ${JSON.stringify(tool.requiredFields || [], null, 2)}`;
4641
4718
  USER_PROMPT: userPrompt,
4642
4719
  CONVERSATION_HISTORY: conversationHistory || "No previous conversation",
4643
4720
  SCHEMA_DOC: schemaDoc,
4721
+ DATABASE_RULES: databaseRules,
4644
4722
  KNOWLEDGE_BASE_CONTEXT: knowledgeBaseContext || "No additional knowledge base context available.",
4645
4723
  AVAILABLE_EXTERNAL_TOOLS: availableToolsDoc
4646
4724
  });
@@ -9599,7 +9677,8 @@ var SuperatomSDK = class {
9599
9677
  this.geminiApiKey = config.GEMINI_API_KEY || process.env.GEMINI_API_KEY || "";
9600
9678
  this.openaiApiKey = config.OPENAI_API_KEY || process.env.OPENAI_API_KEY || "";
9601
9679
  this.llmProviders = config.LLM_PROVIDERS || getLLMProviders();
9602
- logger.info(`Initializing Superatom SDK v${SDK_VERSION} for project ${this.projectId}, llm providers: ${this.llmProviders.join(", ")}, config llm providers: ${config.LLM_PROVIDERS}`);
9680
+ this.databaseType = config.databaseType || "postgresql";
9681
+ logger.info(`Initializing Superatom SDK v${SDK_VERSION} for project ${this.projectId}, llm providers: ${this.llmProviders.join(", ")}, database type: ${this.databaseType}`);
9603
9682
  this.userManager = new UserManager(this.projectId, 5e3);
9604
9683
  this.dashboardManager = new DashboardManager(this.projectId);
9605
9684
  this.reportManager = new ReportManager(this.projectId);
@@ -9621,8 +9700,9 @@ var SuperatomSDK = class {
9621
9700
  if (promptsDir) {
9622
9701
  promptLoader.setPromptsDir(promptsDir);
9623
9702
  }
9703
+ promptLoader.setDatabaseType(this.databaseType);
9624
9704
  await promptLoader.initialize();
9625
- logger.info(`PromptLoader initialized with ${promptLoader.getCacheSize()} prompts from ${promptLoader.getPromptsDir()}`);
9705
+ logger.info(`PromptLoader initialized with ${promptLoader.getCacheSize()} prompts from ${promptLoader.getPromptsDir()}, database type: ${this.databaseType}`);
9626
9706
  } catch (error) {
9627
9707
  logger.error("Failed to initialize PromptLoader:", error);
9628
9708
  throw error;