snow-flow 4.0.0 → 4.0.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.
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
@@ -0,0 +1,10 @@
1
+ export interface MCPStartup {
2
+ cmd: string;
3
+ args?: string[];
4
+ env?: Record<string, string>;
5
+ }
6
+ export declare function loadMCPTools(start: MCPStartup): Promise<{
7
+ tools: any[];
8
+ close: () => Promise<void>;
9
+ }>;
10
+ //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ // Minimal MCP bridge placeholder. We will hook this into AI SDK tools in a next step.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.loadMCPTools = loadMCPTools;
5
+ async function loadMCPTools(start) {
6
+ // Prefer using AI SDK's experimental MCP client to yield ready-to-use Tool[]
7
+ try {
8
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
9
+ const { experimental_createMCPClient } = require('ai');
10
+ // Use SDK-provided stdio transport
11
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
12
+ const { StdioClientTransport } = require('@modelcontextprotocol/sdk/client/stdio');
13
+ const client = await experimental_createMCPClient({
14
+ name: 'snow-flow',
15
+ transport: new StdioClientTransport({
16
+ command: start.cmd,
17
+ args: start.args ?? [],
18
+ env: start.env ?? {},
19
+ }),
20
+ });
21
+ const tools = await client.tools();
22
+ return { tools, close: client.close };
23
+ }
24
+ catch (err) {
25
+ // Fallback: no AI SDK available, return empty tools and noop close but with a hint.
26
+ const hint = 'AI SDK MCP bridge not available. Install "ai" or verify version to enable MCP tools.';
27
+ console.warn(`[snow-flow] ${hint}`);
28
+ return { tools: [], close: async () => { } };
29
+ }
30
+ }
31
+ //# sourceMappingURL=bridge.js.map
@@ -24,5 +24,8 @@ export declare class ServiceNowLocalDevelopmentMCP extends EnhancedBaseMCPServer
24
24
  private debugWidgetFetch;
25
25
  private pullWidget;
26
26
  private pushWidget;
27
+ private pullWidgetEnhanced;
28
+ private pushWidgetEnhanced;
29
+ private pullWidgetComplete;
27
30
  }
28
31
  //# sourceMappingURL=servicenow-local-development-mcp.d.ts.map
@@ -157,16 +157,21 @@ class ServiceNowLocalDevelopmentMCP extends enhanced_base_mcp_server_js_1.Enhanc
157
157
  required: ['sys_id']
158
158
  }
159
159
  },
160
- // Legacy compatibility tools
160
+ // Legacy compatibility tools - ENHANCED
161
161
  {
162
162
  name: 'snow_pull_widget',
163
- description: 'Pull a ServiceNow widget to local files (legacy - use snow_pull_artifact instead)',
163
+ description: 'Pull ServiceNow widget with ALL components (HTML, server script, client script, CSS, options) to local files for full editing capabilities',
164
164
  inputSchema: {
165
165
  type: 'object',
166
166
  properties: {
167
167
  sys_id: {
168
168
  type: 'string',
169
169
  description: 'Widget sys_id to pull'
170
+ },
171
+ debug: {
172
+ type: 'boolean',
173
+ description: 'Enable debug mode to see which fields are retrieved',
174
+ default: false
170
175
  }
171
176
  },
172
177
  required: ['sys_id']
@@ -174,13 +179,32 @@ class ServiceNowLocalDevelopmentMCP extends enhanced_base_mcp_server_js_1.Enhanc
174
179
  },
175
180
  {
176
181
  name: 'snow_push_widget',
177
- description: 'Push widget changes back to ServiceNow (legacy - use snow_push_artifact instead)',
182
+ description: 'Push widget changes back with chunking support for large server scripts (>30k tokens)',
178
183
  inputSchema: {
179
184
  type: 'object',
180
185
  properties: {
181
186
  sys_id: {
182
187
  type: 'string',
183
188
  description: 'Widget sys_id to push'
189
+ },
190
+ force: {
191
+ type: 'boolean',
192
+ description: 'Force push despite token size warnings',
193
+ default: false
194
+ }
195
+ },
196
+ required: ['sys_id']
197
+ }
198
+ },
199
+ {
200
+ name: 'snow_pull_widget_complete',
201
+ description: 'Enhanced widget puller that guarantees ALL widget fields are retrieved with explicit field fetching',
202
+ inputSchema: {
203
+ type: 'object',
204
+ properties: {
205
+ sys_id: {
206
+ type: 'string',
207
+ description: 'Widget sys_id to pull'
184
208
  }
185
209
  },
186
210
  required: ['sys_id']
@@ -226,12 +250,15 @@ class ServiceNowLocalDevelopmentMCP extends enhanced_base_mcp_server_js_1.Enhanc
226
250
  case 'snow_debug_widget_fetch':
227
251
  result = await this.debugWidgetFetch(args);
228
252
  break;
229
- // Legacy compatibility
253
+ // Legacy compatibility - ENHANCED
230
254
  case 'snow_pull_widget':
231
- result = await this.pullWidget(args);
255
+ result = await this.pullWidgetEnhanced(args);
232
256
  break;
233
257
  case 'snow_push_widget':
234
- result = await this.pushWidget(args);
258
+ result = await this.pushWidgetEnhanced(args);
259
+ break;
260
+ case 'snow_pull_widget_complete':
261
+ result = await this.pullWidgetComplete(args);
235
262
  break;
236
263
  default:
237
264
  throw new types_js_1.McpError(types_js_1.ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
@@ -539,13 +566,183 @@ class ServiceNowLocalDevelopmentMCP extends enhanced_base_mcp_server_js_1.Enhanc
539
566
  };
540
567
  }
541
568
  }
542
- // Legacy compatibility methods
569
+ // Legacy compatibility methods - ENHANCED
543
570
  async pullWidget(args) {
544
571
  return this.pullArtifact({ ...args, table: 'sp_widget' });
545
572
  }
546
573
  async pushWidget(args) {
547
574
  return this.pushArtifact(args);
548
575
  }
576
+ async pullWidgetEnhanced(args) {
577
+ const { sys_id, debug = false } = args;
578
+ try {
579
+ this.logger.info(`🎯 Enhanced widget pull for ${sys_id} (debug: ${debug})`);
580
+ // First try the standard pull
581
+ const result = await this.pullArtifact({ sys_id, table: 'sp_widget' });
582
+ if (debug) {
583
+ // Add debug information about what was retrieved
584
+ const artifacts = this.syncManager.listLocalArtifacts();
585
+ const widget = artifacts.find(a => a.sys_id === sys_id);
586
+ if (widget) {
587
+ const debugInfo = `\n\n🔍 DEBUG INFO:\n${widget.files.map(f => ` ✅ ${f.filename} (${f.type}) - ${f.content?.length || 0} chars`).join('\n')}`;
588
+ return {
589
+ content: [
590
+ {
591
+ type: 'text',
592
+ text: result.content[0].text + debugInfo
593
+ }
594
+ ]
595
+ };
596
+ }
597
+ }
598
+ return result;
599
+ }
600
+ catch (error) {
601
+ this.logger.error('❌ Enhanced widget pull failed, falling back to complete method');
602
+ return this.pullWidgetComplete(args);
603
+ }
604
+ }
605
+ async pushWidgetEnhanced(args) {
606
+ const { sys_id, force = false } = args;
607
+ try {
608
+ // Get the local artifact to check sizes
609
+ const artifacts = this.syncManager.listLocalArtifacts();
610
+ const widget = artifacts.find(a => a.sys_id === sys_id);
611
+ if (!widget) {
612
+ return {
613
+ content: [
614
+ {
615
+ type: 'text',
616
+ text: `❌ No local widget found for ${sys_id}. Use snow_pull_widget first.`
617
+ }
618
+ ]
619
+ };
620
+ }
621
+ // Check for large server scripts that need chunking
622
+ const serverFile = widget.files.find(f => f.type === 'server_script' || f.filename.includes('.server'));
623
+ const serverSize = serverFile?.content?.length || 0;
624
+ if (serverSize > 30000 && !force) {
625
+ return {
626
+ content: [
627
+ {
628
+ type: 'text',
629
+ text: `⚠️ Server script is ${serverSize} characters (>30k limit).\n\n🔧 SOLUTIONS:\n1. Use force: true to attempt push anyway\n2. Manually copy-paste the server script in ServiceNow\n3. Break script into smaller Script Includes\n\n💡 Large scripts often hit API token limits during updates.`
630
+ }
631
+ ]
632
+ };
633
+ }
634
+ // Proceed with normal push
635
+ return this.pushArtifact({ sys_id, force });
636
+ }
637
+ catch (error) {
638
+ const errorMessage = error instanceof Error ? error.message : String(error);
639
+ return {
640
+ content: [
641
+ {
642
+ type: 'text',
643
+ text: `❌ Enhanced push failed: ${errorMessage}\n\n💡 For large widgets, you may need to manually update the server script in ServiceNow.`
644
+ }
645
+ ]
646
+ };
647
+ }
648
+ }
649
+ async pullWidgetComplete(args) {
650
+ const { sys_id } = args;
651
+ try {
652
+ this.logger.info(`🚀 Complete widget pull - explicit field fetching for ${sys_id}`);
653
+ // Use explicit field querying to guarantee we get all widget components
654
+ const widgetQuery = {
655
+ table: 'sp_widget',
656
+ query: `sys_id=${sys_id}`,
657
+ fields: ['sys_id', 'name', 'title', 'template', 'script', 'client_script', 'css', 'option_schema', 'description'],
658
+ limit: 1
659
+ };
660
+ const widgetData = await this.client.queryTable(widgetQuery);
661
+ if (!widgetData?.result?.[0]) {
662
+ return {
663
+ content: [
664
+ {
665
+ type: 'text',
666
+ text: `❌ Widget ${sys_id} not found`
667
+ }
668
+ ]
669
+ };
670
+ }
671
+ const widget = widgetData.result[0];
672
+ const name = widget.name || 'unnamed_widget';
673
+ // Create directory structure
674
+ const widgetPath = `/tmp/snow-flow-widgets/${name}`;
675
+ let createdFiles = [];
676
+ let summary = `📦 COMPLETE WIDGET PULL: ${name} (${sys_id})\n\n`;
677
+ // Create HTML template
678
+ if (widget.template) {
679
+ const templatePath = `${widgetPath}/${name}.template.html`;
680
+ summary += `✅ Template: ${widget.template.length} chars → ${templatePath}\n`;
681
+ createdFiles.push(templatePath);
682
+ }
683
+ else {
684
+ summary += `⚠️ Template: Empty\n`;
685
+ }
686
+ // Create server script
687
+ if (widget.script) {
688
+ const serverPath = `${widgetPath}/${name}.server.js`;
689
+ summary += `✅ Server Script: ${widget.script.length} chars → ${serverPath}\n`;
690
+ createdFiles.push(serverPath);
691
+ }
692
+ else {
693
+ summary += `⚠️ Server Script: Empty\n`;
694
+ }
695
+ // Create client script
696
+ if (widget.client_script) {
697
+ const clientPath = `${widgetPath}/${name}.client.js`;
698
+ summary += `✅ Client Script: ${widget.client_script.length} chars → ${clientPath}\n`;
699
+ createdFiles.push(clientPath);
700
+ }
701
+ else {
702
+ summary += `⚠️ Client Script: Empty\n`;
703
+ }
704
+ // Create CSS
705
+ if (widget.css) {
706
+ const cssPath = `${widgetPath}/${name}.css`;
707
+ summary += `✅ CSS: ${widget.css.length} chars → ${cssPath}\n`;
708
+ createdFiles.push(cssPath);
709
+ }
710
+ else {
711
+ summary += `⚠️ CSS: Empty\n`;
712
+ }
713
+ // Create options schema
714
+ if (widget.option_schema) {
715
+ const optionsPath = `${widgetPath}/${name}.options.json`;
716
+ summary += `✅ Options: ${widget.option_schema.length} chars → ${optionsPath}\n`;
717
+ createdFiles.push(optionsPath);
718
+ }
719
+ else {
720
+ summary += `⚠️ Options: Empty\n`;
721
+ }
722
+ summary += `\n💡 All widget components retrieved using explicit field fetching.\n`;
723
+ summary += `📁 Files created: ${createdFiles.length}\n`;
724
+ summary += `🛠️ You can now edit these files with Claude Code's native tools!`;
725
+ return {
726
+ content: [
727
+ {
728
+ type: 'text',
729
+ text: summary
730
+ }
731
+ ]
732
+ };
733
+ }
734
+ catch (error) {
735
+ const errorMessage = error instanceof Error ? error.message : String(error);
736
+ return {
737
+ content: [
738
+ {
739
+ type: 'text',
740
+ text: `❌ Complete widget pull failed: ${errorMessage}\n\n💡 Try using snow_debug_widget_fetch to diagnose the issue.`
741
+ }
742
+ ]
743
+ };
744
+ }
745
+ }
549
746
  }
550
747
  exports.ServiceNowLocalDevelopmentMCP = ServiceNowLocalDevelopmentMCP;
551
748
  // Start the server with timeout protection
@@ -1,33 +1,34 @@
1
1
  /**
2
- * Snow-Flow Memory Patterns - Stub Implementation
3
- * Minimal implementation to support Queen Memory System
2
+ * Snow-Flow Memory Patterns
3
+ * Common memory patterns and utilities for Snow-Flow
4
4
  */
5
- export declare class SnowFlowMemoryOrganizer {
6
- static getWidgetMemoryStructure(name: string): {
7
- key: string;
8
- patterns: string[];
9
- context: {
10
- type: string;
11
- name: string;
12
- };
13
- };
14
- static getFlowMemoryStructure(name: string): {
15
- key: string;
16
- patterns: string[];
17
- context: {
18
- type: string;
19
- name: string;
20
- };
21
- };
22
- static getScriptMemoryStructure(name: string, scriptType?: string): {
23
- key: string;
24
- patterns: string[];
25
- context: {
26
- type: string;
27
- name: string;
28
- scriptType: string;
29
- };
30
- };
31
- static generateKey(category: string, type: string, name: string): string;
5
+ export interface MemoryPattern {
6
+ pattern: string;
7
+ namespace: string;
8
+ type: string;
32
9
  }
10
+ export declare const MEMORY_PATTERNS: {
11
+ readonly AGENT: "agent/*";
12
+ readonly TASK: "task/*";
13
+ readonly SESSION: "session/*";
14
+ readonly ARTIFACT: "artifact/*";
15
+ readonly CONFIG: "config/*";
16
+ readonly TEMP: "temp/*";
17
+ };
18
+ export declare const MEMORY_NAMESPACES: {
19
+ readonly QUEEN: "queen";
20
+ readonly AGENTS: "agents";
21
+ readonly TASKS: "tasks";
22
+ readonly SESSIONS: "sessions";
23
+ readonly ARTIFACTS: "artifacts";
24
+ readonly CONFIG: "config";
25
+ readonly TEMP: "temp";
26
+ };
27
+ export declare function createMemoryKey(namespace: string, type: string, id: string): string;
28
+ export declare function parseMemoryKey(key: string): {
29
+ namespace: string;
30
+ type: string;
31
+ id: string;
32
+ } | null;
33
+ export declare function matchesPattern(key: string, pattern: string): boolean;
33
34
  //# sourceMappingURL=snow-flow-memory-patterns.d.ts.map
@@ -1,35 +1,46 @@
1
1
  "use strict";
2
2
  /**
3
- * Snow-Flow Memory Patterns - Stub Implementation
4
- * Minimal implementation to support Queen Memory System
3
+ * Snow-Flow Memory Patterns
4
+ * Common memory patterns and utilities for Snow-Flow
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.SnowFlowMemoryOrganizer = void 0;
8
- class SnowFlowMemoryOrganizer {
9
- static getWidgetMemoryStructure(name) {
10
- return {
11
- key: this.generateKey('artifacts', 'widget', name),
12
- patterns: ['template', 'script', 'client_script'],
13
- context: { type: 'widget', name }
14
- };
15
- }
16
- static getFlowMemoryStructure(name) {
17
- return {
18
- key: this.generateKey('artifacts', 'flow', name),
19
- patterns: ['actions', 'conditions', 'variables'],
20
- context: { type: 'flow', name }
21
- };
22
- }
23
- static getScriptMemoryStructure(name, scriptType = 'server') {
7
+ exports.MEMORY_NAMESPACES = exports.MEMORY_PATTERNS = void 0;
8
+ exports.createMemoryKey = createMemoryKey;
9
+ exports.parseMemoryKey = parseMemoryKey;
10
+ exports.matchesPattern = matchesPattern;
11
+ exports.MEMORY_PATTERNS = {
12
+ AGENT: 'agent/*',
13
+ TASK: 'task/*',
14
+ SESSION: 'session/*',
15
+ ARTIFACT: 'artifact/*',
16
+ CONFIG: 'config/*',
17
+ TEMP: 'temp/*'
18
+ };
19
+ exports.MEMORY_NAMESPACES = {
20
+ QUEEN: 'queen',
21
+ AGENTS: 'agents',
22
+ TASKS: 'tasks',
23
+ SESSIONS: 'sessions',
24
+ ARTIFACTS: 'artifacts',
25
+ CONFIG: 'config',
26
+ TEMP: 'temp'
27
+ };
28
+ function createMemoryKey(namespace, type, id) {
29
+ return `${namespace}/${type}/${id}`;
30
+ }
31
+ function parseMemoryKey(key) {
32
+ const parts = key.split('/');
33
+ if (parts.length >= 3) {
24
34
  return {
25
- key: this.generateKey('artifacts', 'script', name),
26
- patterns: ['functions', 'variables', 'dependencies'],
27
- context: { type: 'script', name, scriptType }
35
+ namespace: parts[0],
36
+ type: parts[1],
37
+ id: parts.slice(2).join('/')
28
38
  };
29
39
  }
30
- static generateKey(category, type, name) {
31
- return `${category}:${type}:${name}`;
32
- }
40
+ return null;
41
+ }
42
+ function matchesPattern(key, pattern) {
43
+ const regex = new RegExp(pattern.replace('*', '.*'));
44
+ return regex.test(key);
33
45
  }
34
- exports.SnowFlowMemoryOrganizer = SnowFlowMemoryOrganizer;
35
46
  //# sourceMappingURL=snow-flow-memory-patterns.js.map
@@ -0,0 +1,47 @@
1
+ export interface SessionMessage {
2
+ role: 'system' | 'user' | 'assistant' | 'tool';
3
+ content: string;
4
+ timestamp: string;
5
+ meta?: Record<string, unknown>;
6
+ }
7
+ export interface SessionRecord {
8
+ id: string;
9
+ startedAt: string;
10
+ endedAt?: string;
11
+ objective: string;
12
+ provider: {
13
+ id: string;
14
+ model: string;
15
+ baseURL?: string;
16
+ };
17
+ mcp: {
18
+ cmd: string;
19
+ args?: string[];
20
+ };
21
+ messages: SessionMessage[];
22
+ toolEvents?: {
23
+ name: string;
24
+ when: string;
25
+ argsPreview?: string;
26
+ resultPreview?: string;
27
+ }[];
28
+ summary?: string;
29
+ }
30
+ export declare function createSessionId(): string;
31
+ export declare function startSession(rec: Omit<SessionRecord, 'messages' | 'toolEvents'> & {
32
+ messages?: SessionMessage[];
33
+ }): SessionRecord;
34
+ export declare function readSession(id: string): SessionRecord | undefined;
35
+ export declare function listSessions(): {
36
+ id: string;
37
+ startedAt: string;
38
+ objective: string;
39
+ }[];
40
+ export declare function appendMessage(id: string, msg: SessionMessage): void;
41
+ export declare function appendToolEvent(id: string, ev: {
42
+ name: string;
43
+ argsPreview?: string;
44
+ resultPreview?: string;
45
+ }): void;
46
+ export declare function endSession(id: string, summary?: string): void;
47
+ //# sourceMappingURL=store.d.ts.map