snow-flow 4.1.0 → 4.1.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 (44) hide show
  1. package/README.md +15 -40
  2. package/dist/cli.js +0 -81
  3. package/dist/dynamic-version.js +1 -1
  4. package/dist/index.js +3 -1
  5. package/dist/intelligence/performance-recommendations-engine.js +1 -0
  6. package/dist/mcp/advanced/servicenow-advanced-features-mcp.js +12 -12
  7. package/dist/mcp/servicenow-development-assistant-mcp.js +1 -1
  8. package/dist/mcp/servicenow-local-development-mcp.d.ts +0 -3
  9. package/dist/mcp/servicenow-local-development-mcp.js +7 -204
  10. package/dist/mcp/servicenow-machine-learning-mcp.js +2 -2
  11. package/dist/mcp/servicenow-reporting-analytics-mcp.js +1 -1
  12. package/dist/mcp/shared/response-limiter.js +1 -1
  13. package/dist/memory/snow-flow-memory-patterns.d.ts +29 -30
  14. package/dist/memory/snow-flow-memory-patterns.js +26 -37
  15. package/dist/snow-flow-system.js +1 -0
  16. package/dist/testing/integration-test-suite.js +1 -0
  17. package/dist/utils/artifact-local-sync.js +0 -17
  18. package/dist/utils/artifact-sync/artifact-registry.js +11 -11
  19. package/dist/utils/smart-field-fetcher.js +9 -11
  20. package/package.json +2 -2
  21. package/dist/agent/interactive.d.ts +0 -11
  22. package/dist/agent/interactive.js +0 -190
  23. package/dist/agent/session.d.ts +0 -12
  24. package/dist/agent/session.js +0 -106
  25. package/dist/cli/auth.d.ts +0 -3
  26. package/dist/cli/auth.js +0 -59
  27. package/dist/cli/session.d.ts +0 -3
  28. package/dist/cli/session.js +0 -46
  29. package/dist/llm/keys.d.ts +0 -5
  30. package/dist/llm/keys.js +0 -29
  31. package/dist/llm/providers.d.ts +0 -11
  32. package/dist/llm/providers.js +0 -77
  33. package/dist/mcp/bridge.d.ts +0 -10
  34. package/dist/mcp/bridge.js +0 -31
  35. package/dist/mcp/shared/mcp-types.d.ts +0 -37
  36. package/dist/mcp/shared/mcp-types.js +0 -7
  37. package/dist/memory/hierarchical-memory-system.d.ts +0 -32
  38. package/dist/memory/hierarchical-memory-system.js +0 -60
  39. package/dist/memory/memory-system.d.ts +0 -25
  40. package/dist/memory/memory-system.js +0 -36
  41. package/dist/session/store.d.ts +0 -47
  42. package/dist/session/store.js +0 -74
  43. package/dist/utils/chunking-manager.d.ts +0 -39
  44. package/dist/utils/chunking-manager.js +0 -143
@@ -1,74 +0,0 @@
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.createSessionId = createSessionId;
7
- exports.startSession = startSession;
8
- exports.readSession = readSession;
9
- exports.listSessions = listSessions;
10
- exports.appendMessage = appendMessage;
11
- exports.appendToolEvent = appendToolEvent;
12
- exports.endSession = endSession;
13
- const fs_1 = __importDefault(require("fs"));
14
- const os_1 = __importDefault(require("os"));
15
- const path_1 = __importDefault(require("path"));
16
- function ensureDir(dir) {
17
- if (!fs_1.default.existsSync(dir))
18
- fs_1.default.mkdirSync(dir, { recursive: true });
19
- }
20
- function sessionsDir() {
21
- const dir = path_1.default.join(os_1.default.homedir(), '.snow-flow', 'sessions');
22
- ensureDir(dir);
23
- return dir;
24
- }
25
- function createSessionId() {
26
- return `sess_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
27
- }
28
- function sessionPath(id) {
29
- return path_1.default.join(sessionsDir(), `${id}.json`);
30
- }
31
- function startSession(rec) {
32
- const full = { ...rec, messages: rec.messages ?? [], toolEvents: [] };
33
- fs_1.default.writeFileSync(sessionPath(rec.id), JSON.stringify(full, null, 2), 'utf8');
34
- return full;
35
- }
36
- function readSession(id) {
37
- const p = sessionPath(id);
38
- if (!fs_1.default.existsSync(p))
39
- return undefined;
40
- return JSON.parse(fs_1.default.readFileSync(p, 'utf8'));
41
- }
42
- function listSessions() {
43
- const dir = sessionsDir();
44
- const files = fs_1.default.readdirSync(dir).filter(f => f.endsWith('.json'));
45
- return files.map(f => {
46
- const rec = JSON.parse(fs_1.default.readFileSync(path_1.default.join(dir, f), 'utf8'));
47
- return { id: rec.id, startedAt: rec.startedAt, objective: rec.objective };
48
- }).sort((a, b) => (a.startedAt < b.startedAt ? 1 : -1));
49
- }
50
- function appendMessage(id, msg) {
51
- const rec = readSession(id);
52
- if (!rec)
53
- return;
54
- rec.messages.push(msg);
55
- fs_1.default.writeFileSync(sessionPath(id), JSON.stringify(rec, null, 2), 'utf8');
56
- }
57
- function appendToolEvent(id, ev) {
58
- const rec = readSession(id);
59
- if (!rec)
60
- return;
61
- const item = { name: ev.name, when: new Date().toISOString(), argsPreview: ev.argsPreview, resultPreview: ev.resultPreview };
62
- (rec.toolEvents = rec.toolEvents || []).push(item);
63
- fs_1.default.writeFileSync(sessionPath(id), JSON.stringify(rec, null, 2), 'utf8');
64
- }
65
- function endSession(id, summary) {
66
- const rec = readSession(id);
67
- if (!rec)
68
- return;
69
- rec.endedAt = new Date().toISOString();
70
- if (summary)
71
- rec.summary = summary;
72
- fs_1.default.writeFileSync(sessionPath(id), JSON.stringify(rec, null, 2), 'utf8');
73
- }
74
- //# sourceMappingURL=store.js.map
@@ -1,39 +0,0 @@
1
- /**
2
- * Chunking Manager for Large ServiceNow Artifacts
3
- * Handles scripts >30k characters that exceed API token limits
4
- */
5
- export interface ChunkingStrategy {
6
- maxChunkSize: number;
7
- overlapSize: number;
8
- chunkType: 'lines' | 'functions' | 'blocks';
9
- }
10
- export interface ScriptChunk {
11
- index: number;
12
- content: string;
13
- startLine: number;
14
- endLine: number;
15
- type: 'complete' | 'partial_start' | 'partial_middle' | 'partial_end';
16
- hasContext: boolean;
17
- }
18
- export declare class ChunkingManager {
19
- /**
20
- * Determine if script needs chunking
21
- */
22
- static needsChunking(script: string, maxSize?: number): boolean;
23
- /**
24
- * Split large script into manageable chunks
25
- */
26
- static chunkScript(script: string, strategy?: ChunkingStrategy): ScriptChunk[];
27
- /**
28
- * Generate instructions for manual large script handling
29
- */
30
- static generateManualInstructions(scriptName: string, scriptSize: number, chunks: ScriptChunk[]): string;
31
- /**
32
- * Attempt smart chunked update for large scripts
33
- */
34
- static attemptChunkedUpdate(client: any, table: string, sys_id: string, field: string, script: string): Promise<{
35
- success: boolean;
36
- message: string;
37
- }>;
38
- }
39
- //# sourceMappingURL=chunking-manager.d.ts.map
@@ -1,143 +0,0 @@
1
- "use strict";
2
- /**
3
- * Chunking Manager for Large ServiceNow Artifacts
4
- * Handles scripts >30k characters that exceed API token limits
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.ChunkingManager = void 0;
8
- class ChunkingManager {
9
- /**
10
- * Determine if script needs chunking
11
- */
12
- static needsChunking(script, maxSize = 5000000) {
13
- // 5MB = ServiceNow's actual response limit
14
- return script.length > maxSize;
15
- }
16
- /**
17
- * Split large script into manageable chunks
18
- */
19
- static chunkScript(script, strategy = {
20
- maxChunkSize: 2500000, // 2.5MB chunks
21
- overlapSize: 500,
22
- chunkType: 'functions'
23
- }) {
24
- const lines = script.split('\n');
25
- const chunks = [];
26
- if (!this.needsChunking(script)) {
27
- return [{
28
- index: 0,
29
- content: script,
30
- startLine: 1,
31
- endLine: lines.length,
32
- type: 'complete',
33
- hasContext: true
34
- }];
35
- }
36
- let currentChunk = '';
37
- let currentStartLine = 1;
38
- let chunkIndex = 0;
39
- for (let i = 0; i < lines.length; i++) {
40
- const line = lines[i];
41
- const potentialChunk = currentChunk + line + '\n';
42
- if (potentialChunk.length > strategy.maxChunkSize) {
43
- // Current chunk is full, save it
44
- if (currentChunk.trim()) {
45
- chunks.push({
46
- index: chunkIndex++,
47
- content: currentChunk.trim(),
48
- startLine: currentStartLine,
49
- endLine: i,
50
- type: chunkIndex === 0 ? 'partial_start' : 'partial_middle',
51
- hasContext: true
52
- });
53
- }
54
- // Start new chunk with overlap
55
- const overlapLines = Math.min(Math.floor(strategy.overlapSize / 50), // Assume ~50 chars per line
56
- 10 // Max 10 lines overlap
57
- );
58
- const overlapStart = Math.max(0, i - overlapLines);
59
- currentChunk = lines.slice(overlapStart, i + 1).join('\n') + '\n';
60
- currentStartLine = overlapStart + 1;
61
- }
62
- else {
63
- currentChunk += line + '\n';
64
- }
65
- }
66
- // Add final chunk
67
- if (currentChunk.trim()) {
68
- chunks.push({
69
- index: chunkIndex,
70
- content: currentChunk.trim(),
71
- startLine: currentStartLine,
72
- endLine: lines.length,
73
- type: 'partial_end',
74
- hasContext: true
75
- });
76
- }
77
- return chunks;
78
- }
79
- /**
80
- * Generate instructions for manual large script handling
81
- */
82
- static generateManualInstructions(scriptName, scriptSize, chunks) {
83
- return `
84
- 🚨 LARGE SCRIPT DETECTED: ${scriptName} (${scriptSize.toLocaleString()} characters)
85
-
86
- ⚠️ This script exceeds API token limits and cannot be updated automatically.
87
-
88
- 🔧 MANUAL UPDATE REQUIRED:
89
-
90
- 1. **Navigate to ServiceNow**:
91
- - Go to Service Portal → Widgets
92
- - Find and edit your widget
93
- - Click on "Server Script" tab
94
-
95
- 2. **Copy the updated script**:
96
- - Script has been split into ${chunks.length} chunks below
97
- - Copy ALL chunks in order and paste into ServiceNow
98
-
99
- 3. **Chunks to copy**:
100
- ${chunks.map(chunk => `
101
- **Chunk ${chunk.index + 1}/${chunks.length}** (Lines ${chunk.startLine}-${chunk.endLine}):
102
- \`\`\`javascript
103
- ${chunk.content.substring(0, 500)}${chunk.content.length > 500 ? '...\n[truncated for display]' : ''}
104
- \`\`\`
105
- `).join('')}
106
-
107
- 4. **Validation**:
108
- - Ensure no syntax errors after pasting
109
- - Test widget functionality
110
- - Consider breaking into smaller Script Includes
111
-
112
- 💡 **Prevention for future**:
113
- - Keep server scripts under 30,000 characters
114
- - Use Script Includes for reusable functions
115
- - Move complex logic to business rules where appropriate
116
- `;
117
- }
118
- /**
119
- * Attempt smart chunked update for large scripts
120
- */
121
- static async attemptChunkedUpdate(client, table, sys_id, field, script) {
122
- if (!this.needsChunking(script)) {
123
- // Not chunked, do normal update
124
- try {
125
- await client.updateRecord(table, sys_id, { [field]: script });
126
- return { success: true, message: 'Script updated successfully' };
127
- }
128
- catch (error) {
129
- return { success: false, message: `Update failed: ${error}` };
130
- }
131
- }
132
- // For large scripts, we can't actually chunk the API call
133
- // But we can provide intelligent guidance
134
- const chunks = this.chunkScript(script);
135
- const instructions = this.generateManualInstructions(field, script.length, chunks);
136
- return {
137
- success: false,
138
- message: `Script too large for automatic update. Manual steps required:\n${instructions}`
139
- };
140
- }
141
- }
142
- exports.ChunkingManager = ChunkingManager;
143
- //# sourceMappingURL=chunking-manager.js.map