snow-flow 4.2.0 → 4.2.2

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 (81) hide show
  1. package/README.md +186 -554
  2. package/cloudbuild-npm.yaml +132 -0
  3. package/cloudbuild-website.yaml +92 -0
  4. package/cloudbuild.yaml +141 -0
  5. package/dist/agent/interactive.d.ts +11 -0
  6. package/dist/agent/interactive.js +190 -0
  7. package/dist/agent/session.d.ts +12 -0
  8. package/dist/agent/session.js +106 -0
  9. package/dist/cli/auth.d.ts +3 -0
  10. package/dist/cli/auth.js +59 -0
  11. package/dist/cli/session.d.ts +3 -0
  12. package/dist/cli/session.js +46 -0
  13. package/dist/cli.js +81 -0
  14. package/dist/config/llm-config-loader.d.ts +45 -0
  15. package/dist/config/llm-config-loader.js +49 -0
  16. package/dist/index.js +1 -3
  17. package/dist/intelligence/performance-recommendations-engine.js +0 -1
  18. package/dist/llm/keys.d.ts +5 -0
  19. package/dist/llm/keys.js +29 -0
  20. package/dist/llm/providers.d.ts +11 -0
  21. package/dist/llm/providers.js +77 -0
  22. package/dist/mcp/advanced/servicenow-advanced-features-mcp.js +12 -12
  23. package/dist/mcp/bridge.d.ts +10 -0
  24. package/dist/mcp/bridge.js +31 -0
  25. package/dist/mcp/servicenow-development-assistant-mcp.js +1 -1
  26. package/dist/mcp/servicenow-machine-learning-mcp.js +2 -2
  27. package/dist/mcp/servicenow-reporting-analytics-mcp.js +1 -1
  28. package/dist/mcp/shared/mcp-types.d.ts +37 -0
  29. package/dist/mcp/shared/mcp-types.js +7 -0
  30. package/dist/mcp/shared/response-limiter.js +1 -1
  31. package/dist/memory/hierarchical-memory-system.d.ts +42 -0
  32. package/dist/memory/hierarchical-memory-system.js +60 -0
  33. package/dist/memory/memory-system.d.ts +34 -0
  34. package/dist/memory/memory-system.js +36 -0
  35. package/dist/memory/snow-flow-memory-patterns.d.ts +47 -28
  36. package/dist/memory/snow-flow-memory-patterns.js +46 -25
  37. package/dist/session/store.d.ts +47 -0
  38. package/dist/session/store.js +74 -0
  39. package/dist/snow-flow-system.js +0 -1
  40. package/dist/testing/integration-test-suite.js +0 -1
  41. package/dist/utils/artifact-local-sync.js +17 -0
  42. package/dist/utils/artifact-sync/artifact-registry.js +11 -11
  43. package/dist/utils/chunking-manager.d.ts +39 -0
  44. package/dist/utils/chunking-manager.js +143 -0
  45. package/dist/utils/smart-field-fetcher.js +11 -9
  46. package/package.json +3 -3
  47. package/website/Dockerfile +3 -2
  48. package/website/cloudbuild.yaml +4 -3
  49. package/website/complete-mcp-reference.html +1040 -0
  50. package/website/components/hero/Hero.html +9 -9
  51. package/website/components/hero/Hero.jsx +3 -3
  52. package/website/css/button-contrast-fixes.css +133 -0
  53. package/website/css/button-fixes.css +49 -0
  54. package/website/css/enterprise-section-update.css +38 -0
  55. package/website/css/font-standardization.css +54 -0
  56. package/website/css/footer-hero-styling.css +73 -0
  57. package/website/css/hero-compact-spacing.css +60 -0
  58. package/website/css/hero-contrast-fixes.css +195 -0
  59. package/website/css/hero-inspired-design.css +135 -0
  60. package/website/css/hero-size-optimization.css +146 -0
  61. package/website/css/hero-spacing-improvements.css +139 -0
  62. package/website/css/hero-stats-visibility.css +98 -0
  63. package/website/css/mobile-hero-fix.css +215 -0
  64. package/website/css/navbar-hero-styling.css +70 -0
  65. package/website/css/reference-text-contrast.css +101 -0
  66. package/website/css/scroll-overlap-nuclear-fix.css +127 -0
  67. package/website/css/section-layering-fix.css +85 -0
  68. package/website/css/style.css +37 -10
  69. package/website/css/title-layout-fix.css +58 -0
  70. package/website/css/ultimate-overlap-fix.css +101 -0
  71. package/website/css/website-hero-consistency.css +101 -0
  72. package/website/enterprise-features.html +147 -0
  73. package/website/index.html +268 -43
  74. package/website/js/animations.js +20 -23
  75. package/website/js/main.js +73 -7
  76. package/website/mcp-reference-link.html +16 -0
  77. package/website/mcp-servers.html +2 -2
  78. package/website/tools.js +125 -6
  79. package/website/what-is-snow-flow-section.html +142 -0
  80. package/assets/logo.txt +0 -8
  81. package/assets/snow-flow-logo.svg +0 -51
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ // Agent session placeholder to keep build green.
3
+ // Will be replaced with streaming + tool-calling using the AI SDK.
4
+ var __importDefault = (this && this.__importDefault) || function (mod) {
5
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.runAgent = runAgent;
9
+ const bridge_1 = require("../mcp/bridge");
10
+ const boxen_1 = __importDefault(require("boxen"));
11
+ const chalk_1 = __importDefault(require("chalk"));
12
+ const store_js_1 = require("../session/store.js");
13
+ async function runAgent(opts) {
14
+ const { mcp, system, user, maxSteps = 40, provider, model, baseURL, apiKeyEnv, showReasoning = true, saveOutputPath } = opts;
15
+ // Resolve model via provider registry
16
+ let llm;
17
+ try {
18
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
19
+ const prov = require('../llm/providers.js');
20
+ llm = prov.getModel({ provider, model, baseURL, apiKeyEnv });
21
+ }
22
+ catch (e) {
23
+ console.error('❌ LLM provider init error:', e instanceof Error ? e.message : String(e));
24
+ throw e;
25
+ }
26
+ // Load MCP tools (if AI SDK MCP client is available)
27
+ const { tools, close } = await (0, bridge_1.loadMCPTools)(mcp);
28
+ // Stream using AI SDK
29
+ try {
30
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
31
+ const { streamText } = require('ai');
32
+ const sessionId = (0, store_js_1.createSessionId)();
33
+ (0, store_js_1.startSession)({
34
+ id: sessionId,
35
+ startedAt: new Date().toISOString(),
36
+ objective: user,
37
+ provider: { id: String(provider), model: String(model), baseURL },
38
+ mcp: { cmd: mcp.cmd, args: mcp.args },
39
+ });
40
+ (0, store_js_1.appendMessage)(sessionId, { role: 'user', content: user, timestamp: new Date().toISOString() });
41
+ const result = await streamText({
42
+ model: llm,
43
+ system: system ?? 'You are Snow-Flow, a ServiceNow engineering agent. Be precise. Use tools when helpful.',
44
+ messages: [{ role: 'user', content: user }],
45
+ tools,
46
+ maxSteps,
47
+ });
48
+ let buffer = '';
49
+ let inReasoning = false;
50
+ const writeChunk = (s) => {
51
+ buffer += s;
52
+ const colored = inReasoning && showReasoning ? chalk_1.default.yellow.dim(s) : s;
53
+ process.stdout.write(colored);
54
+ };
55
+ // Optional: stream tool call events if provided by SDK
56
+ if (result.toolCallStream && typeof result.toolCallStream[Symbol.asyncIterator] === 'function') {
57
+ (async () => {
58
+ for await (const ev of result.toolCallStream) {
59
+ const name = ev?.toolName || ev?.name || 'tool';
60
+ const args = ev?.args ? JSON.stringify(ev.args).slice(0, 200) : '';
61
+ process.stdout.write('\n' + chalk_1.default.cyan(`🔧 Tool → ${name} ${args}`) + '\n');
62
+ (0, store_js_1.appendToolEvent)(sessionId, { name, argsPreview: args });
63
+ }
64
+ })().catch(() => { });
65
+ }
66
+ if (result.toolResultStream && typeof result.toolResultStream[Symbol.asyncIterator] === 'function') {
67
+ (async () => {
68
+ for await (const ev of result.toolResultStream) {
69
+ const name = ev?.toolName || ev?.name || 'tool';
70
+ const out = ev?.result ? JSON.stringify(ev.result).slice(0, 200) : '';
71
+ process.stdout.write(chalk_1.default.magenta(`📦 Result ← ${name} ${out}`) + '\n');
72
+ (0, store_js_1.appendToolEvent)(sessionId, { name, resultPreview: out });
73
+ }
74
+ })().catch(() => { });
75
+ }
76
+ for await (const chunk of result.textStream) {
77
+ const str = String(chunk);
78
+ // Heuristic: detect reasoning blocks (```reasoning, <thinking>, [reasoning])
79
+ if (showReasoning) {
80
+ if (str.includes('```reasoning') || str.toLowerCase().includes('<thinking>') || /\[\s*reasoning\s*\]/i.test(str))
81
+ inReasoning = true;
82
+ if (str.includes('```') || str.toLowerCase().includes('</thinking>'))
83
+ inReasoning = false;
84
+ }
85
+ writeChunk(str);
86
+ }
87
+ // Render a boxed summary if output is long
88
+ if (buffer.length > 4000) {
89
+ const preview = buffer.slice(0, 1200) + '…';
90
+ const box = (0, boxen_1.default)(preview, { padding: 1, borderColor: 'green', title: 'Preview (truncated)', titleAlignment: 'center' });
91
+ process.stdout.write('\n' + box + '\n');
92
+ process.stdout.write(chalk_1.default.gray(`Full length: ${buffer.length} chars`) + '\n');
93
+ }
94
+ if (saveOutputPath) {
95
+ const fs = require('fs');
96
+ fs.writeFileSync(saveOutputPath, buffer, 'utf8');
97
+ process.stdout.write(chalk_1.default.gray(`Saved full output to ${saveOutputPath}`) + '\n');
98
+ }
99
+ (0, store_js_1.appendMessage)(sessionId, { role: 'assistant', content: buffer, timestamp: new Date().toISOString() });
100
+ (0, store_js_1.endSession)(sessionId);
101
+ }
102
+ finally {
103
+ await close();
104
+ }
105
+ }
106
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerAuthCommands(program: Command): void;
3
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.registerAuthCommands = registerAuthCommands;
7
+ const inquirer_1 = __importDefault(require("inquirer"));
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const keys_js_1 = require("../llm/keys.js");
10
+ function registerAuthCommands(program) {
11
+ const auth = program.command('auth').description('Manage provider API credentials for Snow-Flow');
12
+ auth
13
+ .command('login')
14
+ .description('Interactive login to store API keys for a provider')
15
+ .option('--provider <provider>', 'Provider id (openai|google|openrouter|openai-compatible|ollama)')
16
+ .action(async (opts) => {
17
+ const p = opts.provider || (await inquirer_1.default.prompt([{ name: 'provider', message: 'Provider', type: 'list', choices: ['openai', 'google', 'openrouter', 'openai-compatible', 'ollama'] }])).provider;
18
+ const existing = (0, keys_js_1.getApiKey)(p);
19
+ const { apiKey } = await inquirer_1.default.prompt([{ name: 'apiKey', message: `API key for ${p}${existing ? ' (leave blank to keep existing)' : ''}`, type: 'password', mask: '*' }]);
20
+ if (!apiKey && existing) {
21
+ console.log(chalk_1.default.yellow('Keeping existing key.'));
22
+ return;
23
+ }
24
+ if (!apiKey) {
25
+ console.error(chalk_1.default.red('No key entered. Aborting.'));
26
+ process.exit(1);
27
+ }
28
+ (0, keys_js_1.setApiKey)(p, apiKey);
29
+ console.log(chalk_1.default.green(`Saved API key for ${p}.`));
30
+ });
31
+ auth
32
+ .command('set-key')
33
+ .description('Set API key non-interactively')
34
+ .requiredOption('--provider <provider>', 'Provider id')
35
+ .requiredOption('--api-key <key>', 'API key value')
36
+ .action((opts) => {
37
+ (0, keys_js_1.setApiKey)(opts.provider, opts.apiKey);
38
+ console.log(chalk_1.default.green(`Saved API key for ${opts.provider}.`));
39
+ });
40
+ auth
41
+ .command('show')
42
+ .description('Show configured providers (keys partially masked)')
43
+ .action(() => {
44
+ const entries = (0, keys_js_1.listKeys)();
45
+ for (const [p, v] of Object.entries(entries)) {
46
+ const mask = v ? `${v.substring(0, 4)}…${v.substring(v.length - 4)}` : '—';
47
+ console.log(`${p.padEnd(18)} ${mask}`);
48
+ }
49
+ });
50
+ auth
51
+ .command('clear')
52
+ .description('Clear a stored API key')
53
+ .requiredOption('--provider <provider>', 'Provider id')
54
+ .action((opts) => {
55
+ (0, keys_js_1.clearApiKey)(opts.provider);
56
+ console.log(chalk_1.default.yellow(`Cleared API key for ${opts.provider}.`));
57
+ });
58
+ }
59
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerSessionCommands(program: Command): void;
3
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.registerSessionCommands = registerSessionCommands;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const store_js_1 = require("../session/store.js");
9
+ function registerSessionCommands(program) {
10
+ const sess = program.command('session').description('Manage and inspect Snow-Flow sessions');
11
+ sess
12
+ .command('list')
13
+ .description('List recent sessions')
14
+ .action(() => {
15
+ const rows = (0, store_js_1.listSessions)().slice(0, 30);
16
+ if (!rows.length)
17
+ return console.log('No sessions yet.');
18
+ for (const r of rows) {
19
+ console.log(`${chalk_1.default.gray(r.startedAt)} ${chalk_1.default.cyan(r.id)} ${r.objective}`);
20
+ }
21
+ });
22
+ sess
23
+ .command('show <id>')
24
+ .description('Show session details')
25
+ .action((id) => {
26
+ const rec = (0, store_js_1.readSession)(id);
27
+ if (!rec)
28
+ return console.error(chalk_1.default.red('Session not found.'));
29
+ console.log(chalk_1.default.cyan(`Session ${rec.id}`));
30
+ console.log(`${chalk_1.default.gray(rec.startedAt)} → ${chalk_1.default.gray(rec.endedAt ?? '…')}`);
31
+ console.log('Objective:', rec.objective);
32
+ console.log('Provider:', `${rec.provider.id} ${rec.provider.model}`);
33
+ console.log('MCP:', `${rec.mcp.cmd} ${(rec.mcp.args || []).join(' ')}`);
34
+ console.log('\nMessages:');
35
+ for (const m of rec.messages) {
36
+ console.log(`- ${chalk_1.default.yellow(m.role)} ${chalk_1.default.gray(m.timestamp)}\n ${m.content.slice(0, 400)}${m.content.length > 400 ? '…' : ''}`);
37
+ }
38
+ if (rec.toolEvents?.length) {
39
+ console.log('\nTool events:');
40
+ for (const ev of rec.toolEvents) {
41
+ console.log(` 🔧 ${ev.name} ${chalk_1.default.gray(ev.when)} ${ev.argsPreview ? ('args:' + ev.argsPreview) : ''} ${ev.resultPreview ? ('res:' + ev.resultPreview) : ''}`);
42
+ }
43
+ }
44
+ });
45
+ }
46
+ //# sourceMappingURL=session.js.map
package/dist/cli.js CHANGED
@@ -53,6 +53,11 @@ const agent_detector_js_1 = require("./utils/agent-detector.js");
53
53
  const version_js_1 = require("./version.js");
54
54
  const logger_js_1 = require("./utils/logger.js");
55
55
  const chalk_1 = __importDefault(require("chalk"));
56
+ // New provider-agnostic engine imports (compile-safe placeholders)
57
+ const llm_config_loader_js_1 = require("./config/llm-config-loader.js");
58
+ const interactive_js_1 = require("./agent/interactive.js");
59
+ const auth_js_1 = require("./cli/auth.js");
60
+ const session_js_1 = require("./cli/session.js");
56
61
  // Load environment variables
57
62
  dotenv_1.default.config();
58
63
  // Create CLI logger instance
@@ -62,6 +67,10 @@ program
62
67
  .name('snow-flow')
63
68
  .description('ServiceNow Multi-Agent Development Framework')
64
69
  .version(version_js_1.VERSION);
70
+ // Register auth commands (API key management)
71
+ (0, auth_js_1.registerAuthCommands)(program);
72
+ // Register session inspection commands
73
+ (0, session_js_1.registerSessionCommands)(program);
65
74
  // Flow deprecation handler - check for flow-related commands
66
75
  function checkFlowDeprecation(command, objective) {
67
76
  const flowKeywords = ['flow', 'create-flow', 'xml-flow', 'flow-designer'];
@@ -90,6 +99,18 @@ function checkFlowDeprecation(command, objective) {
90
99
  program
91
100
  .command('swarm <objective>')
92
101
  .description('Execute multi-agent orchestration for a ServiceNow task - één command voor alles!')
102
+ // New engine selector: defaults to auto (uses config-driven agent when available)
103
+ .option('--engine <engine>', 'Execution engine (auto|agent|claude)', 'auto')
104
+ .option('--config <path>', 'Path to snowflow.config file')
105
+ .option('--show-reasoning', 'Show LLM reasoning in a different color (default)', true)
106
+ .option('--no-show-reasoning', 'Hide LLM reasoning blocks')
107
+ .option('--save-output <path>', 'Save full assistant output to a file')
108
+ .option('--resume <sessionId>', 'Resume an existing interactive session')
109
+ // Provider overrides (optional, config-driven by default)
110
+ .option('--provider <provider>', 'LLM provider override')
111
+ .option('--model <model>', 'Model override')
112
+ .option('--base-url <url>', 'Base URL override for openai-compatible or gateways')
113
+ .option('--api-key-env <name>', 'Use specific API key env var')
93
114
  .option('--strategy <strategy>', 'Execution strategy (development, _analysis, research)', 'development')
94
115
  .option('--mode <mode>', 'Coordination mode (hierarchical, mesh, distributed)', 'hierarchical')
95
116
  .option('--max-agents <number>', 'Maximum number of agents', '5')
@@ -266,6 +287,66 @@ program
266
287
  cliLogger.info(`🤖 Autonomous Systems: ❌ All Disabled`);
267
288
  }
268
289
  }
290
+ // Detect agent engine via config (provider-agnostic) when requested or available
291
+ const shouldUseAgent = (() => {
292
+ if (options.engine === 'agent')
293
+ return true;
294
+ if (options.engine === 'claude')
295
+ return false;
296
+ // auto: use agent when config file is present and valid
297
+ const cfg = (0, llm_config_loader_js_1.loadSnowFlowConfig)({
298
+ configPath: options.config,
299
+ overrides: {
300
+ llm: {
301
+ provider: options.provider || undefined,
302
+ model: options.model || undefined,
303
+ baseURL: options.baseUrl || options.baseURL || undefined,
304
+ apiKeyEnv: options.apiKeyEnv || undefined,
305
+ },
306
+ },
307
+ });
308
+ return Boolean(cfg && cfg.llm && cfg.llm.provider && cfg.llm.model);
309
+ })();
310
+ if (shouldUseAgent) {
311
+ const cfg = (0, llm_config_loader_js_1.loadSnowFlowConfig)({
312
+ configPath: options.config,
313
+ overrides: {
314
+ llm: {
315
+ provider: options.provider || undefined,
316
+ model: options.model || undefined,
317
+ baseURL: options.baseUrl || options.baseURL || undefined,
318
+ apiKeyEnv: options.apiKeyEnv || undefined,
319
+ },
320
+ },
321
+ });
322
+ if (!cfg) {
323
+ cliLogger.error('❌ Geen snowflow.config.(json|js|cjs) gevonden. Voeg config toe of gebruik --engine claude.');
324
+ process.exit(1);
325
+ }
326
+ // Basic validation for MVP
327
+ if (!cfg.llm?.provider || !cfg.llm?.model) {
328
+ cliLogger.error('❌ Config mist llm.provider of llm.model');
329
+ process.exit(1);
330
+ }
331
+ cliLogger.info('\n🤖 Using provider-agnostic Snow-Flow agent (interactive)');
332
+ try {
333
+ await (0, interactive_js_1.runInteractive)({
334
+ provider: cfg.llm.provider,
335
+ model: String(cfg.llm.model),
336
+ baseURL: cfg.llm.baseURL,
337
+ apiKeyEnv: cfg.llm.apiKeyEnv,
338
+ mcp: cfg.mcp,
339
+ system: cfg.agent?.system,
340
+ maxSteps: cfg.agent?.maxSteps ?? 40,
341
+ showReasoning: options.showReasoning !== false,
342
+ resumeId: options.resume || undefined,
343
+ });
344
+ }
345
+ catch (e) {
346
+ cliLogger.error('❌ Interactive agent error:', e instanceof Error ? e.message : String(e));
347
+ }
348
+ return; // end here; skip legacy Claude path
349
+ }
269
350
  // Analyze the objective using intelligent agent detection
270
351
  const taskAnalysis = analyzeObjective(objective, parseInt(options.maxAgents));
271
352
  // Debug logging to understand task type detection
@@ -0,0 +1,45 @@
1
+ /**
2
+ * LLM Config Loader
3
+ * Loads Snow-Flow configuration with LLM provider settings
4
+ */
5
+ export interface SnowFlowConfig {
6
+ instance?: string;
7
+ username?: string;
8
+ password?: string;
9
+ client_id?: string;
10
+ client_secret?: string;
11
+ refresh_token?: string;
12
+ debug?: boolean;
13
+ llm?: {
14
+ provider?: string;
15
+ model?: string;
16
+ apiKey?: string;
17
+ baseURL?: string;
18
+ apiKeyEnv?: string;
19
+ };
20
+ mcp?: {
21
+ enabled?: boolean;
22
+ servers?: string[];
23
+ };
24
+ agent?: {
25
+ maxWorkers?: number;
26
+ timeout?: number;
27
+ system?: any;
28
+ maxSteps?: number;
29
+ };
30
+ }
31
+ /**
32
+ * Load Snow-Flow configuration with optional LLM settings
33
+ */
34
+ export declare function loadSnowFlowConfig(): SnowFlowConfig;
35
+ /**
36
+ * Get LLM configuration specifically
37
+ */
38
+ export declare function getLLMConfig(): {
39
+ provider?: string;
40
+ model?: string;
41
+ apiKey?: string;
42
+ baseURL?: string;
43
+ apiKeyEnv?: string;
44
+ };
45
+ //# sourceMappingURL=llm-config-loader.d.ts.map
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ /**
3
+ * LLM Config Loader
4
+ * Loads Snow-Flow configuration with LLM provider settings
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.loadSnowFlowConfig = loadSnowFlowConfig;
8
+ exports.getLLMConfig = getLLMConfig;
9
+ const snow_flow_config_js_1 = require("./snow-flow-config.js");
10
+ /**
11
+ * Load Snow-Flow configuration with optional LLM settings
12
+ */
13
+ function loadSnowFlowConfig() {
14
+ try {
15
+ // Load base config from snow-flow-config
16
+ const baseConfig = snow_flow_config_js_1.snowFlowConfig || {};
17
+ // Add LLM configuration if available
18
+ const config = {
19
+ ...baseConfig,
20
+ llm: {
21
+ provider: process.env.LLM_PROVIDER || 'claude',
22
+ model: process.env.LLM_MODEL || 'claude-3-sonnet',
23
+ apiKey: process.env.ANTHROPIC_API_KEY || process.env.OPENAI_API_KEY
24
+ }
25
+ };
26
+ return config;
27
+ }
28
+ catch (error) {
29
+ // Fallback to basic config
30
+ return {
31
+ debug: false,
32
+ llm: {
33
+ provider: 'claude',
34
+ model: 'claude-3-sonnet'
35
+ }
36
+ };
37
+ }
38
+ }
39
+ /**
40
+ * Get LLM configuration specifically
41
+ */
42
+ function getLLMConfig() {
43
+ const config = loadSnowFlowConfig();
44
+ return config.llm || {
45
+ provider: 'claude',
46
+ model: 'claude-3-sonnet'
47
+ };
48
+ }
49
+ //# sourceMappingURL=llm-config-loader.js.map
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
18
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.SystemHealth = exports.PerformanceTracker = exports.FALLBACK_STRATEGIES = exports.ErrorRecovery = exports.MemorySystem = exports.snowFlowConfig = exports.SnowFlowConfig = exports.snowFlowSystem = exports.SnowFlowSystem = exports.ServiceNowLocalDevelopmentMCP = exports.ServiceNowMCPServer = exports.SmartFieldFetcher = exports.ArtifactLocalSync = exports.Logger = exports.ServiceNowClient = exports.ServiceNowOAuth = void 0;
21
+ exports.SystemHealth = exports.PerformanceTracker = exports.FALLBACK_STRATEGIES = exports.ErrorRecovery = exports.snowFlowConfig = exports.SnowFlowConfig = exports.snowFlowSystem = exports.SnowFlowSystem = exports.ServiceNowLocalDevelopmentMCP = exports.ServiceNowMCPServer = exports.SmartFieldFetcher = exports.ArtifactLocalSync = exports.Logger = exports.ServiceNowClient = exports.ServiceNowOAuth = void 0;
22
22
  // Export main types
23
23
  __exportStar(require("./types/index.js"), exports);
24
24
  // Export utilities
@@ -46,8 +46,6 @@ Object.defineProperty(exports, "snowFlowSystem", { enumerable: true, get: functi
46
46
  var snow_flow_config_js_1 = require("./config/snow-flow-config.js");
47
47
  Object.defineProperty(exports, "SnowFlowConfig", { enumerable: true, get: function () { return snow_flow_config_js_1.SnowFlowConfig; } });
48
48
  Object.defineProperty(exports, "snowFlowConfig", { enumerable: true, get: function () { return snow_flow_config_js_1.snowFlowConfig; } });
49
- var memory_system_js_1 = require("./memory/memory-system.js");
50
- Object.defineProperty(exports, "MemorySystem", { enumerable: true, get: function () { return memory_system_js_1.MemorySystem; } });
51
49
  var error_recovery_js_1 = require("./utils/error-recovery.js");
52
50
  Object.defineProperty(exports, "ErrorRecovery", { enumerable: true, get: function () { return error_recovery_js_1.ErrorRecovery; } });
53
51
  Object.defineProperty(exports, "FALLBACK_STRATEGIES", { enumerable: true, get: function () { return error_recovery_js_1.FALLBACK_STRATEGIES; } });
@@ -14,7 +14,6 @@
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.PerformanceRecommendationsEngine = void 0;
16
16
  const logger_js_1 = require("../utils/logger.js");
17
- const memory_system_js_1 = require("../memory/memory-system.js");
18
17
  class PerformanceRecommendationsEngine {
19
18
  constructor(memory) {
20
19
  this.performancePatterns = new Map();
@@ -0,0 +1,5 @@
1
+ export declare function setApiKey(provider: string, value: string): void;
2
+ export declare function getApiKey(provider: string): string | undefined;
3
+ export declare function clearApiKey(provider: string): void;
4
+ export declare function listKeys(): Record<string, string | undefined>;
5
+ //# sourceMappingURL=keys.d.ts.map
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.setApiKey = setApiKey;
7
+ exports.getApiKey = getApiKey;
8
+ exports.clearApiKey = clearApiKey;
9
+ exports.listKeys = listKeys;
10
+ const conf_1 = __importDefault(require("conf"));
11
+ // Avoid generic type for broader compatibility with shimmed types
12
+ const store = new conf_1.default({ projectName: 'snow-flow' });
13
+ function setApiKey(provider, value) {
14
+ store.set(`keys.${provider}`, value);
15
+ }
16
+ function getApiKey(provider) {
17
+ return store.get(`keys.${provider}`);
18
+ }
19
+ function clearApiKey(provider) {
20
+ store.delete(`keys.${provider}`);
21
+ }
22
+ function listKeys() {
23
+ const providers = ['openai', 'google', 'openrouter', 'openai-compatible', 'ollama'];
24
+ const out = {};
25
+ for (const p of providers)
26
+ out[p] = getApiKey(p);
27
+ return out;
28
+ }
29
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1,11 @@
1
+ import type { SnowFlowConfig } from '../config/llm-config-loader';
2
+ export type ProviderId = SnowFlowConfig['llm']['provider'];
3
+ export interface ProviderOptions {
4
+ provider: ProviderId;
5
+ model: string;
6
+ baseURL?: string;
7
+ apiKeyEnv?: string;
8
+ extraBody?: Record<string, unknown>;
9
+ }
10
+ export declare function getModel(opts: ProviderOptions): unknown;
11
+ //# sourceMappingURL=providers.d.ts.map
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ // Compile-safe placeholder registry. Real providers will be wired via AI SDK in a follow-up step.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getModel = getModel;
5
+ const keys_js_1 = require("./keys.js");
6
+ function getModel(opts) {
7
+ const { provider, model, baseURL, apiKeyEnv, extraBody } = opts;
8
+ const requireOrThrow = (name) => {
9
+ try {
10
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
11
+ return require(name);
12
+ }
13
+ catch (err) {
14
+ const hint = `Missing dependency ${name}. Run: npm i ai @ai-sdk/openai @ai-sdk/google @openrouter/ai-sdk-provider`;
15
+ throw new Error(hint);
16
+ }
17
+ };
18
+ switch (provider) {
19
+ case 'anthropic': {
20
+ // Prefer AI SDK anthropic provider if installed; otherwise instruct
21
+ try {
22
+ // Dynamic require to avoid hard dep
23
+ const anthropic = require('@ai-sdk/anthropic');
24
+ const key = process.env[apiKeyEnv || 'ANTHROPIC_API_KEY'] || (0, keys_js_1.getApiKey)('anthropic');
25
+ if (!key)
26
+ throw new Error('Missing ANTHROPIC_API_KEY');
27
+ return anthropic.anthropic({ apiKey: key, baseURL }).languageModel(model);
28
+ }
29
+ catch (e) {
30
+ throw new Error('Anthropic provider not available. Install @ai-sdk/anthropic or use OpenRouter with an Anthropic model.');
31
+ }
32
+ }
33
+ case 'openai': {
34
+ const { openai } = requireOrThrow('@ai-sdk/openai');
35
+ const apiKey = process.env[apiKeyEnv || 'OPENAI_API_KEY'] || (0, keys_js_1.getApiKey)('openai');
36
+ if (!apiKey)
37
+ throw new Error('Missing OPENAI_API_KEY');
38
+ return openai({ apiKey, baseURL }).languageModel(model);
39
+ }
40
+ case 'google': {
41
+ const { google } = requireOrThrow('@ai-sdk/google');
42
+ const apiKey = process.env[apiKeyEnv || 'GOOGLE_API_KEY']
43
+ || process.env['GOOGLE_GENERATIVE_AI_API_KEY']
44
+ || (0, keys_js_1.getApiKey)('google');
45
+ if (!apiKey)
46
+ throw new Error('Missing GOOGLE_API_KEY or GOOGLE_GENERATIVE_AI_API_KEY');
47
+ return google({ apiKey, baseURL }).languageModel(model);
48
+ }
49
+ case 'openrouter': {
50
+ const { createOpenRouter } = requireOrThrow('@openrouter/ai-sdk-provider');
51
+ const apiKey = process.env[apiKeyEnv || 'OPENROUTER_API_KEY'] || (0, keys_js_1.getApiKey)('openrouter');
52
+ if (!apiKey)
53
+ throw new Error('Missing OPENROUTER_API_KEY');
54
+ const or = createOpenRouter({ apiKey, baseURL, extraBody });
55
+ return or(model);
56
+ }
57
+ case 'openai-compatible': {
58
+ const { openai } = requireOrThrow('@ai-sdk/openai');
59
+ const keyName = apiKeyEnv || 'OPENAI_COMPAT_API_KEY';
60
+ const apiKey = process.env[keyName] || (0, keys_js_1.getApiKey)('openai-compatible');
61
+ if (!baseURL)
62
+ throw new Error('openai-compatible requires baseURL');
63
+ if (!apiKey)
64
+ throw new Error(`Missing ${keyName}`);
65
+ return openai({ apiKey, baseURL }).languageModel(model);
66
+ }
67
+ case 'ollama': {
68
+ const { openai } = requireOrThrow('@ai-sdk/openai');
69
+ const keyName = apiKeyEnv || 'OLLAMA_API_KEY';
70
+ const apiKey = process.env[keyName] || (0, keys_js_1.getApiKey)('ollama');
71
+ if (!baseURL)
72
+ throw new Error('ollama requires baseURL (e.g., http://localhost:11434/v1)');
73
+ return openai({ apiKey, baseURL }).languageModel(model);
74
+ }
75
+ }
76
+ }
77
+ //# sourceMappingURL=providers.js.map