snow-flow 2.0.4 → 2.0.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.
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ /**
3
+ * Snow-Flow Memory System Test
4
+ * Demonstrates and tests the SQLite memory system functionality
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const memory_client_js_1 = require("./memory-client.js");
8
+ const logger_js_1 = require("../utils/logger.js");
9
+ const logger = new logger_js_1.Logger('MemoryTest');
10
+ async function testMemorySystem() {
11
+ logger.info('Starting memory system tests');
12
+ // Create a test session
13
+ const sessionId = `test_session_${Date.now()}`;
14
+ // Create memory clients for different agents
15
+ const widgetAgent = memory_client_js_1.MemoryClient.forAgent('widget_creator_001', 'widget-creator', sessionId);
16
+ const uiAgent = memory_client_js_1.MemoryClient.forAgent('ui_specialist_001', 'ui-specialist', sessionId);
17
+ const testAgent = memory_client_js_1.MemoryClient.forAgent('test_agent_001', 'tester', sessionId);
18
+ try {
19
+ logger.info('Test 1: Agent Registration and Coordination');
20
+ // Register agents
21
+ await widgetAgent.register(['create_incident_widget']);
22
+ await uiAgent.register(['style_widget', 'add_responsiveness']);
23
+ await testAgent.register(['test_widget_functionality']);
24
+ // Update progress
25
+ await widgetAgent.updateProgress(25, 'analyzing_requirements');
26
+ await widgetAgent.updateProgress(50, 'creating_template');
27
+ await widgetAgent.updateProgress(75, 'implementing_server_script');
28
+ logger.info('Test 2: Shared Context Storage');
29
+ // Store widget requirements in shared context
30
+ await widgetAgent.store({
31
+ key: 'widget_requirements',
32
+ value: {
33
+ name: 'incident_dashboard',
34
+ features: ['real-time updates', 'chart visualization', 'filters'],
35
+ data_sources: ['incident', 'problem'],
36
+ priority: 'high'
37
+ }
38
+ });
39
+ // UI agent retrieves requirements
40
+ const requirements = await uiAgent.retrieve({ key: 'widget_requirements' });
41
+ logger.info('UI Agent retrieved requirements', requirements);
42
+ logger.info('Test 3: Artifact Management');
43
+ // Widget agent creates artifact
44
+ await widgetAgent.storeArtifact({
45
+ sys_id: 'widget_12345',
46
+ type: 'widget',
47
+ name: 'Incident Dashboard Widget',
48
+ description: 'Real-time incident monitoring dashboard',
49
+ status: 'created',
50
+ metadata: {
51
+ template_size: '5KB',
52
+ has_client_script: true,
53
+ has_server_script: true
54
+ }
55
+ });
56
+ // Update artifact status
57
+ await widgetAgent.updateArtifactStatus('widget_12345', 'tested');
58
+ logger.info('Test 4: Agent Communication');
59
+ // Widget agent hands off to UI specialist
60
+ await widgetAgent.handoff({
61
+ to_agent: 'ui_specialist_001',
62
+ artifact_reference: 'widget_12345',
63
+ data: {
64
+ template_ready: true,
65
+ styling_requirements: {
66
+ theme: 'dark',
67
+ responsive: true,
68
+ accessibility: 'WCAG 2.1'
69
+ }
70
+ }
71
+ });
72
+ // UI agent checks for handoffs
73
+ const handoffs = await uiAgent.checkHandoffs();
74
+ logger.info('UI Agent received handoffs', handoffs);
75
+ // UI agent reports dependency ready to test agent
76
+ await uiAgent.reportDependencyReady('test_agent_001', 'widget_12345');
77
+ logger.info('Test 5: Performance Tracking');
78
+ // Track widget creation operation
79
+ const tracker = widgetAgent.trackOperation('create_widget_template');
80
+ // Simulate operation
81
+ await new Promise(resolve => setTimeout(resolve, 100));
82
+ // Complete tracking
83
+ await tracker.complete(true, undefined, { lines_of_code: 250 });
84
+ // Get performance stats
85
+ const stats = await widgetAgent.getPerformanceStats('create_widget_template');
86
+ logger.info('Performance stats', stats);
87
+ logger.info('Test 6: Deployment History');
88
+ // Record deployment events
89
+ await widgetAgent.recordDeployment('widget_12345', 'create', true);
90
+ await uiAgent.recordDeployment('widget_12345', 'update', true);
91
+ await testAgent.recordDeployment('widget_12345', 'test', true);
92
+ await widgetAgent.recordDeployment('widget_12345', 'verify', true);
93
+ // Get deployment history
94
+ const history = await widgetAgent.getDeploymentHistory('widget_12345');
95
+ logger.info('Deployment history', history);
96
+ logger.info('Test 7: Session State Management');
97
+ // Mark agents as completed
98
+ await widgetAgent.complete();
99
+ await uiAgent.complete();
100
+ await testAgent.complete();
101
+ // Get complete session state
102
+ const sessionState = await widgetAgent.getSessionState();
103
+ logger.info('Session state', {
104
+ activeAgents: sessionState.agents.length,
105
+ artifacts: sessionState.artifacts.length,
106
+ pendingMessages: sessionState.pendingMessages,
107
+ contextKeys: sessionState.activeContext.map(c => c.context_key),
108
+ performanceSummary: sessionState.performanceSummary
109
+ });
110
+ logger.info('Test 8: Memory Statistics');
111
+ const stats2 = widgetAgent.getStats();
112
+ logger.info('Memory statistics', stats2);
113
+ logger.info('Test 9: Query Performance');
114
+ // Test query performance (should be <100ms as per requirements)
115
+ const startTime = Date.now();
116
+ // Run multiple queries
117
+ await Promise.all([
118
+ widgetAgent.findSessionArtifacts(),
119
+ widgetAgent.getSessionData(),
120
+ widgetAgent.getPerformanceStats('create_widget_template'),
121
+ uiAgent.checkHandoffs(),
122
+ testAgent.checkDependencies()
123
+ ]);
124
+ const queryTime = Date.now() - startTime;
125
+ logger.info(`Query performance: ${queryTime}ms (requirement: <100ms)`);
126
+ logger.info('Test 10: Concurrent Operations');
127
+ // Test thread-safe concurrent operations
128
+ const concurrentOps = [];
129
+ for (let i = 0; i < 10; i++) {
130
+ concurrentOps.push(widgetAgent.store({
131
+ key: `concurrent_test_${i}`,
132
+ value: `value_${i}`
133
+ }));
134
+ }
135
+ await Promise.all(concurrentOps);
136
+ logger.info('Concurrent operations completed successfully');
137
+ // Cleanup
138
+ await widgetAgent.cleanup();
139
+ logger.info('All tests completed successfully!');
140
+ }
141
+ catch (error) {
142
+ logger.error('Test failed', error);
143
+ throw error;
144
+ }
145
+ finally {
146
+ // Shutdown memory system
147
+ memory_client_js_1.MemoryClient.shutdown();
148
+ }
149
+ }
150
+ // Run tests if called directly
151
+ if (require.main === module) {
152
+ testMemorySystem()
153
+ .then(() => {
154
+ logger.info('Memory system test completed');
155
+ process.exit(0);
156
+ })
157
+ .catch((error) => {
158
+ logger.error('Memory system test failed', error);
159
+ process.exit(1);
160
+ });
161
+ }
@@ -0,0 +1,119 @@
1
+ /**
2
+ * ServiceNow Artifact Indexer
3
+ * Intelligent indexing system for large ServiceNow artifacts
4
+ */
5
+ export interface ServiceNowArtifact {
6
+ sys_id: string;
7
+ name?: string;
8
+ title?: string;
9
+ table: string;
10
+ sys_class_name: string;
11
+ sys_updated_on: string;
12
+ [key: string]: any;
13
+ }
14
+ export interface FlowArtifact extends ServiceNowArtifact {
15
+ flow_definition: string;
16
+ trigger_conditions?: string;
17
+ active: boolean;
18
+ description?: string;
19
+ }
20
+ export interface WidgetArtifact extends ServiceNowArtifact {
21
+ template?: string;
22
+ css?: string;
23
+ client_script?: string;
24
+ server_script?: string;
25
+ option_schema?: string;
26
+ }
27
+ export interface IndexedArtifact {
28
+ meta: {
29
+ sys_id: string;
30
+ name: string;
31
+ type: string;
32
+ last_updated: string;
33
+ size_estimate: string;
34
+ };
35
+ structure: ArtifactStructure;
36
+ context: ArtifactContext;
37
+ relationships: ArtifactRelationships;
38
+ claudeSummary: string;
39
+ modificationPoints: ModificationPoint[];
40
+ searchTerms: string[];
41
+ editHistory: EditHistory[];
42
+ }
43
+ export interface ArtifactStructure {
44
+ type: string;
45
+ components: any;
46
+ complexity: 'low' | 'medium' | 'high';
47
+ editableFields: string[];
48
+ }
49
+ export interface ArtifactContext {
50
+ usage: string;
51
+ dependencies: string[];
52
+ impact: string;
53
+ commonModifications: string[];
54
+ }
55
+ export interface ArtifactRelationships {
56
+ relatedArtifacts: string[];
57
+ dependencies: string[];
58
+ usage: string[];
59
+ }
60
+ export interface ModificationPoint {
61
+ location: string;
62
+ type: string;
63
+ description: string;
64
+ examples: string[];
65
+ }
66
+ export interface EditHistory {
67
+ date: string;
68
+ change: string;
69
+ by: string;
70
+ }
71
+ export declare class ServiceNowArtifactIndexer {
72
+ private logger;
73
+ private memoryPath;
74
+ constructor(memoryPath?: string);
75
+ intelligentlyIndex(artifact: ServiceNowArtifact): Promise<IndexedArtifact>;
76
+ private decomposeArtifact;
77
+ private decomposeWidget;
78
+ private decomposeFlow;
79
+ private decomposeScript;
80
+ private decomposeApplication;
81
+ private decomposeGeneric;
82
+ private extractContext;
83
+ private mapRelationships;
84
+ private createClaudeSummary;
85
+ private identifyModificationPoints;
86
+ private generateSearchTerms;
87
+ private parseFlowDefinition;
88
+ private assessHTMLComplexity;
89
+ private assessCSSComplexity;
90
+ private assessJSComplexity;
91
+ private assessOverallComplexity;
92
+ private assessFlowComplexity;
93
+ private assessScriptComplexity;
94
+ private extractHTMLFeatures;
95
+ private extractJSFunctions;
96
+ private extractJSVariables;
97
+ private extractServiceNowAPIs;
98
+ private extractDependencies;
99
+ private parseOptionSchema;
100
+ private describeTrigger;
101
+ private generateStepDescription;
102
+ private identifyEditableFields;
103
+ private determineUsage;
104
+ private findDependencies;
105
+ private assessImpact;
106
+ private getCommonModifications;
107
+ private findRelatedArtifacts;
108
+ private findUsage;
109
+ private getReadableType;
110
+ private inferPurpose;
111
+ private getModificationSuggestions;
112
+ private extractKeyFunctions;
113
+ private estimateSize;
114
+ private storeInMemory;
115
+ loadFromMemory(sys_id: string): Promise<IndexedArtifact | null>;
116
+ searchMemory(query: string): Promise<IndexedArtifact[]>;
117
+ private matchesQuery;
118
+ }
119
+ //# sourceMappingURL=servicenow-artifact-indexer.d.ts.map