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.
- package/README.md +186 -554
- package/cloudbuild-npm.yaml +132 -0
- package/cloudbuild-website.yaml +92 -0
- package/cloudbuild.yaml +141 -0
- package/dist/agent/interactive.d.ts +11 -0
- package/dist/agent/interactive.js +190 -0
- package/dist/agent/session.d.ts +12 -0
- package/dist/agent/session.js +106 -0
- package/dist/cli/auth.d.ts +3 -0
- package/dist/cli/auth.js +59 -0
- package/dist/cli/session.d.ts +3 -0
- package/dist/cli/session.js +46 -0
- package/dist/cli.js +81 -0
- package/dist/config/llm-config-loader.d.ts +45 -0
- package/dist/config/llm-config-loader.js +49 -0
- package/dist/index.js +1 -3
- package/dist/intelligence/performance-recommendations-engine.js +0 -1
- package/dist/llm/keys.d.ts +5 -0
- package/dist/llm/keys.js +29 -0
- package/dist/llm/providers.d.ts +11 -0
- package/dist/llm/providers.js +77 -0
- package/dist/mcp/advanced/servicenow-advanced-features-mcp.js +12 -12
- package/dist/mcp/bridge.d.ts +10 -0
- package/dist/mcp/bridge.js +31 -0
- package/dist/mcp/servicenow-development-assistant-mcp.js +1 -1
- package/dist/mcp/servicenow-machine-learning-mcp.js +2 -2
- package/dist/mcp/servicenow-reporting-analytics-mcp.js +1 -1
- package/dist/mcp/shared/mcp-types.d.ts +37 -0
- package/dist/mcp/shared/mcp-types.js +7 -0
- package/dist/mcp/shared/response-limiter.js +1 -1
- package/dist/memory/hierarchical-memory-system.d.ts +42 -0
- package/dist/memory/hierarchical-memory-system.js +60 -0
- package/dist/memory/memory-system.d.ts +34 -0
- package/dist/memory/memory-system.js +36 -0
- package/dist/memory/snow-flow-memory-patterns.d.ts +47 -28
- package/dist/memory/snow-flow-memory-patterns.js +46 -25
- package/dist/session/store.d.ts +47 -0
- package/dist/session/store.js +74 -0
- package/dist/snow-flow-system.js +0 -1
- package/dist/testing/integration-test-suite.js +0 -1
- package/dist/utils/artifact-local-sync.js +17 -0
- package/dist/utils/artifact-sync/artifact-registry.js +11 -11
- package/dist/utils/chunking-manager.d.ts +39 -0
- package/dist/utils/chunking-manager.js +143 -0
- package/dist/utils/smart-field-fetcher.js +11 -9
- package/package.json +3 -3
- package/website/Dockerfile +3 -2
- package/website/cloudbuild.yaml +4 -3
- package/website/complete-mcp-reference.html +1040 -0
- package/website/components/hero/Hero.html +9 -9
- package/website/components/hero/Hero.jsx +3 -3
- package/website/css/button-contrast-fixes.css +133 -0
- package/website/css/button-fixes.css +49 -0
- package/website/css/enterprise-section-update.css +38 -0
- package/website/css/font-standardization.css +54 -0
- package/website/css/footer-hero-styling.css +73 -0
- package/website/css/hero-compact-spacing.css +60 -0
- package/website/css/hero-contrast-fixes.css +195 -0
- package/website/css/hero-inspired-design.css +135 -0
- package/website/css/hero-size-optimization.css +146 -0
- package/website/css/hero-spacing-improvements.css +139 -0
- package/website/css/hero-stats-visibility.css +98 -0
- package/website/css/mobile-hero-fix.css +215 -0
- package/website/css/navbar-hero-styling.css +70 -0
- package/website/css/reference-text-contrast.css +101 -0
- package/website/css/scroll-overlap-nuclear-fix.css +127 -0
- package/website/css/section-layering-fix.css +85 -0
- package/website/css/style.css +37 -10
- package/website/css/title-layout-fix.css +58 -0
- package/website/css/ultimate-overlap-fix.css +101 -0
- package/website/css/website-hero-consistency.css +101 -0
- package/website/enterprise-features.html +147 -0
- package/website/index.html +268 -43
- package/website/js/animations.js +20 -23
- package/website/js/main.js +73 -7
- package/website/mcp-reference-link.html +16 -0
- package/website/mcp-servers.html +2 -2
- package/website/tools.js +125 -6
- package/website/what-is-snow-flow-section.html +142 -0
- package/assets/logo.txt +0 -8
- package/assets/snow-flow-logo.svg +0 -51
|
@@ -0,0 +1,74 @@
|
|
|
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
|
package/dist/snow-flow-system.js
CHANGED
|
@@ -11,7 +11,6 @@ exports.snowFlowSystem = exports.SnowFlowSystem = void 0;
|
|
|
11
11
|
const events_1 = require("events");
|
|
12
12
|
const snow_flow_config_1 = require("./config/snow-flow-config");
|
|
13
13
|
const servicenow_queen_1 = require("./queen/servicenow-queen");
|
|
14
|
-
const memory_system_1 = require("./memory/memory-system");
|
|
15
14
|
const mcp_server_manager_1 = require("./utils/mcp-server-manager");
|
|
16
15
|
const performance_tracker_1 = require("./monitoring/performance-tracker");
|
|
17
16
|
const system_health_1 = require("./health/system-health");
|
|
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.IntegrationTestSuite = void 0;
|
|
11
11
|
const logger_js_1 = require("../utils/logger.js");
|
|
12
12
|
const servicenow_client_js_1 = require("../utils/servicenow-client.js");
|
|
13
|
-
const memory_system_js_1 = require("../memory/memory-system.js");
|
|
14
13
|
class IntegrationTestSuite {
|
|
15
14
|
constructor() {
|
|
16
15
|
// Flow-related systems removed in v1.4.0
|
|
@@ -47,6 +47,7 @@ const fs = __importStar(require("fs"));
|
|
|
47
47
|
const path = __importStar(require("path"));
|
|
48
48
|
const smart_field_fetcher_js_1 = require("./smart-field-fetcher.js");
|
|
49
49
|
const mcp_timeout_config_js_1 = require("./mcp-timeout-config.js");
|
|
50
|
+
const chunking_manager_js_1 = require("./chunking-manager.js");
|
|
50
51
|
const artifact_registry_1 = require("./artifact-sync/artifact-registry");
|
|
51
52
|
class ArtifactLocalSync {
|
|
52
53
|
constructor(client, customBaseDir) {
|
|
@@ -285,6 +286,22 @@ class ArtifactLocalSync {
|
|
|
285
286
|
}
|
|
286
287
|
// Map back to ServiceNow field
|
|
287
288
|
if (file.field && file.field !== 'documentation' && file.field !== 'metadata') {
|
|
289
|
+
// Check if field needs chunking (large server scripts)
|
|
290
|
+
if (chunking_manager_js_1.ChunkingManager.needsChunking(processedContent)) {
|
|
291
|
+
console.log(` ⚠️ Large field detected: ${file.field} (${processedContent.length} chars)`);
|
|
292
|
+
// Attempt chunked update
|
|
293
|
+
const chunkResult = await chunking_manager_js_1.ChunkingManager.attemptChunkedUpdate(this.client, config.tableName, sys_id, file.field, processedContent);
|
|
294
|
+
if (!chunkResult.success) {
|
|
295
|
+
// Add to validation results as a manual instruction
|
|
296
|
+
validationResults.push({
|
|
297
|
+
valid: false,
|
|
298
|
+
errors: [],
|
|
299
|
+
warnings: [`Large ${file.field} requires manual update`],
|
|
300
|
+
hints: [chunkResult.message]
|
|
301
|
+
});
|
|
302
|
+
continue; // Skip adding to updates
|
|
303
|
+
}
|
|
304
|
+
}
|
|
288
305
|
updates[file.field] = processedContent;
|
|
289
306
|
console.log(` 📝 Changed: ${file.filename} (${file.field})`);
|
|
290
307
|
// Validate ES5 if required
|
|
@@ -33,7 +33,7 @@ exports.ARTIFACT_REGISTRY = {
|
|
|
33
33
|
fileExtension: 'html',
|
|
34
34
|
description: 'HTML template with Angular bindings',
|
|
35
35
|
wrapperHeader: '<!-- ServiceNow Widget Template: {name} -->\n<!-- Angular bindings: {{data.x}}, ng-click="method()" -->\n\n',
|
|
36
|
-
maxTokens:
|
|
36
|
+
maxTokens: 200000, // Claude's context window is 200k tokens
|
|
37
37
|
isRequired: true
|
|
38
38
|
},
|
|
39
39
|
{
|
|
@@ -43,7 +43,7 @@ exports.ARTIFACT_REGISTRY = {
|
|
|
43
43
|
description: 'Server-side script (ES5 ONLY)',
|
|
44
44
|
wrapperHeader: '/**\n * Server Script for Widget: {name}\n * ES5 ONLY - No arrow functions, const/let, template literals\n * Available: data, input, options, gs, $sp\n */\n\n(function() {\n',
|
|
45
45
|
wrapperFooter: '\n})();',
|
|
46
|
-
maxTokens:
|
|
46
|
+
maxTokens: 200000, // Claude's context window is 200k tokens
|
|
47
47
|
isRequired: false,
|
|
48
48
|
validateES5: true
|
|
49
49
|
},
|
|
@@ -54,7 +54,7 @@ exports.ARTIFACT_REGISTRY = {
|
|
|
54
54
|
description: 'Client-side AngularJS controller',
|
|
55
55
|
wrapperHeader: '/**\n * Client Controller for Widget: {name}\n * AngularJS 1.x\n * Available: c (this), c.data, c.server, $scope\n */\n\nfunction(',
|
|
56
56
|
wrapperFooter: ')',
|
|
57
|
-
maxTokens:
|
|
57
|
+
maxTokens: 200000, // Claude's context window is 200k tokens
|
|
58
58
|
isRequired: false
|
|
59
59
|
},
|
|
60
60
|
{
|
|
@@ -63,7 +63,7 @@ exports.ARTIFACT_REGISTRY = {
|
|
|
63
63
|
fileExtension: 'css',
|
|
64
64
|
description: 'Widget-specific CSS styles',
|
|
65
65
|
wrapperHeader: '/* Styles for Widget: {name} */\n/* Prefix classes to avoid conflicts */\n\n',
|
|
66
|
-
maxTokens:
|
|
66
|
+
maxTokens: 200000, // Claude's context window is 200k tokens
|
|
67
67
|
isRequired: false
|
|
68
68
|
},
|
|
69
69
|
{
|
|
@@ -153,7 +153,7 @@ exports.ARTIFACT_REGISTRY = {
|
|
|
153
153
|
localFileName: '{name}.flow',
|
|
154
154
|
fileExtension: 'json',
|
|
155
155
|
description: 'Complete flow definition with all steps and actions',
|
|
156
|
-
maxTokens:
|
|
156
|
+
maxTokens: 200000, // Claude's context window is 200k tokens // Flows can be huge
|
|
157
157
|
isRequired: true,
|
|
158
158
|
preprocessor: (content) => {
|
|
159
159
|
try {
|
|
@@ -243,7 +243,7 @@ exports.ARTIFACT_REGISTRY = {
|
|
|
243
243
|
description: 'Business rule script',
|
|
244
244
|
wrapperHeader: '/**\n * Business Rule: {name}\n * Table: {collection}\n * When: {when}\n * Order: {order}\n * Available: current, previous, gs, g_scratchpad\n */\n\n(function executeRule(current, previous /*null when async*/) {\n',
|
|
245
245
|
wrapperFooter: '\n})(current, previous);',
|
|
246
|
-
maxTokens:
|
|
246
|
+
maxTokens: 200000, // Claude's context window is 200k tokens
|
|
247
247
|
isRequired: true,
|
|
248
248
|
validateES5: true
|
|
249
249
|
},
|
|
@@ -281,7 +281,7 @@ exports.ARTIFACT_REGISTRY = {
|
|
|
281
281
|
localFileName: '{name}.client',
|
|
282
282
|
fileExtension: 'js',
|
|
283
283
|
description: 'Client-side JavaScript',
|
|
284
|
-
maxTokens:
|
|
284
|
+
maxTokens: 200000, // Claude's context window is 200k tokens
|
|
285
285
|
isRequired: false
|
|
286
286
|
},
|
|
287
287
|
{
|
|
@@ -289,7 +289,7 @@ exports.ARTIFACT_REGISTRY = {
|
|
|
289
289
|
localFileName: '{name}.server',
|
|
290
290
|
fileExtension: 'js',
|
|
291
291
|
description: 'Server-side processing script (ES5)',
|
|
292
|
-
maxTokens:
|
|
292
|
+
maxTokens: 200000, // Claude's context window is 200k tokens
|
|
293
293
|
isRequired: false,
|
|
294
294
|
validateES5: true
|
|
295
295
|
}
|
|
@@ -310,7 +310,7 @@ exports.ARTIFACT_REGISTRY = {
|
|
|
310
310
|
fileExtension: 'js',
|
|
311
311
|
description: 'Client-side form script',
|
|
312
312
|
wrapperHeader: '/**\n * Client Script: {name}\n * Table: {table}\n * Type: {type}\n * Available: g_form, g_user, g_list\n */\n\n',
|
|
313
|
-
maxTokens:
|
|
313
|
+
maxTokens: 200000, // Claude's context window is 200k tokens
|
|
314
314
|
isRequired: true
|
|
315
315
|
}
|
|
316
316
|
]
|
|
@@ -375,7 +375,7 @@ exports.ARTIFACT_REGISTRY = {
|
|
|
375
375
|
localFileName: '{name}',
|
|
376
376
|
fileExtension: 'js',
|
|
377
377
|
description: 'Transform map script',
|
|
378
|
-
maxTokens:
|
|
378
|
+
maxTokens: 200000, // Claude's context window is 200k tokens
|
|
379
379
|
isRequired: false,
|
|
380
380
|
validateES5: true
|
|
381
381
|
}
|
|
@@ -396,7 +396,7 @@ exports.ARTIFACT_REGISTRY = {
|
|
|
396
396
|
fileExtension: 'js',
|
|
397
397
|
description: 'Scheduled job script (ES5)',
|
|
398
398
|
wrapperHeader: '/**\n * Scheduled Job: {name}\n * Run as: {run_as}\n * Time zone: {time_zone}\n */\n\n',
|
|
399
|
-
maxTokens:
|
|
399
|
+
maxTokens: 200000, // Claude's context window is 200k tokens
|
|
400
400
|
isRequired: true,
|
|
401
401
|
validateES5: true
|
|
402
402
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
|
@@ -0,0 +1,143 @@
|
|
|
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
|
|
@@ -22,25 +22,25 @@ const WIDGET_FIELD_GROUPS = [
|
|
|
22
22
|
groupName: 'template',
|
|
23
23
|
fields: ['template'],
|
|
24
24
|
description: 'HTML template - defines UI structure and Angular bindings (ng-click, {{data.x}})',
|
|
25
|
-
maxTokens:
|
|
25
|
+
maxTokens: 200000 // Claude's full context window
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
groupName: 'server_script',
|
|
29
29
|
fields: ['script'], // Note: 'script' is the actual field name, not 'server_script'
|
|
30
30
|
description: 'Server-side script (ES5 only) - initializes data object and handles input.action requests',
|
|
31
|
-
maxTokens:
|
|
31
|
+
maxTokens: 200000 // Claude's full context window
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
groupName: 'client_script',
|
|
35
35
|
fields: ['client_script'],
|
|
36
36
|
description: 'Client-side AngularJS controller - implements methods called by template ng-click and calls c.server.get()',
|
|
37
|
-
maxTokens:
|
|
37
|
+
maxTokens: 200000 // Claude's full context window
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
groupName: 'styling',
|
|
41
41
|
fields: ['css'],
|
|
42
42
|
description: 'Widget-specific CSS styles - classes used in template',
|
|
43
|
-
maxTokens:
|
|
43
|
+
maxTokens: 200000 // Claude's full context window
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
46
|
groupName: 'configuration',
|
|
@@ -130,8 +130,8 @@ class SmartFieldFetcher {
|
|
|
130
130
|
description: group.description,
|
|
131
131
|
fields: group.fields
|
|
132
132
|
};
|
|
133
|
-
//
|
|
134
|
-
Object.assign(results, response
|
|
133
|
+
// FIX: getRecord returns direct object, not response.result[0]
|
|
134
|
+
Object.assign(results, response);
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
catch (error) {
|
|
@@ -232,8 +232,9 @@ class SmartFieldFetcher {
|
|
|
232
232
|
// Try using getRecord instead of searchRecords with short timeout
|
|
233
233
|
const directResponse = await (0, mcp_timeout_config_js_1.withMCPTimeout)(this.client.getRecord('sp_widget', sys_id), 5000, // 5 second timeout for direct fetch
|
|
234
234
|
`Direct widget fetch ${sys_id}`);
|
|
235
|
-
if (directResponse
|
|
236
|
-
|
|
235
|
+
if (directResponse) {
|
|
236
|
+
// FIX: getRecord returns direct object, not nested structure
|
|
237
|
+
const directData = directResponse;
|
|
237
238
|
// Merge any new data we got
|
|
238
239
|
Object.assign(results, directData);
|
|
239
240
|
console.log(`📊 Direct API retrieved:`);
|
|
@@ -292,6 +293,7 @@ class SmartFieldFetcher {
|
|
|
292
293
|
console.log(` 📄 Fetching field: ${field}`);
|
|
293
294
|
const response = await this.client.getRecord(table, sys_id);
|
|
294
295
|
if (response) {
|
|
296
|
+
// FIX: getRecord returns direct object
|
|
295
297
|
result.data[field] = response[field];
|
|
296
298
|
result._field_status[field] = 'success';
|
|
297
299
|
}
|
|
@@ -503,7 +505,7 @@ function createFetchStrategyHint(table, sys_id) {
|
|
|
503
505
|
return `
|
|
504
506
|
🔍 SMART FETCH STRATEGY for ${table} (${sys_id}):
|
|
505
507
|
|
|
506
|
-
When the artifact is too large (>
|
|
508
|
+
When the artifact is too large (>200000 tokens), I'll fetch fields in intelligent groups:
|
|
507
509
|
1. First fetch metadata (name, title, sys_id)
|
|
508
510
|
2. Then fetch each content field separately (template, script, client_script, css)
|
|
509
511
|
3. Maintain context: These fields work together!
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snow-flow",
|
|
3
|
-
"version": "4.2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "4.2.2",
|
|
4
|
+
"description": "Conversational ServiceNow development platform using Claude Code. Multi-agent orchestration with 20+ MCP servers providing 200+ ServiceNow tools for comprehensive platform development.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"bin": {
|
|
8
8
|
"snow-flow": "bin/snow-flow"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "tsc || true",
|
|
11
|
+
"build": "tsc --noEmitOnError false || true",
|
|
12
12
|
"dev": "tsc --watch",
|
|
13
13
|
"start": "node dist/index.js",
|
|
14
14
|
"test": "jest",
|
package/website/Dockerfile
CHANGED
|
@@ -29,8 +29,9 @@ EXPOSE 80
|
|
|
29
29
|
|
|
30
30
|
# Add metadata
|
|
31
31
|
LABEL maintainer="Snow-Flow Team" \
|
|
32
|
-
description="Snow-Flow
|
|
33
|
-
version="
|
|
32
|
+
description="Snow-Flow Enterprise Website v4.2.0" \
|
|
33
|
+
version="4.2.0" \
|
|
34
|
+
features="23 MCP Servers, 355+ Tools, ITAM, SecOps, Notifications"
|
|
34
35
|
|
|
35
36
|
# Start nginx
|
|
36
37
|
CMD ["nginx", "-g", "daemon off;"]
|
package/website/cloudbuild.yaml
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
# Snow-Flow Website - Google Cloud Build Configuration
|
|
2
2
|
steps:
|
|
3
|
-
# Build the Docker image
|
|
3
|
+
# Build the Docker image (FIXED PATH)
|
|
4
4
|
- name: 'gcr.io/cloud-builders/docker'
|
|
5
5
|
args: [
|
|
6
6
|
'build',
|
|
7
7
|
'-t', 'gcr.io/$PROJECT_ID/snow-flow-website:$COMMIT_SHA',
|
|
8
8
|
'-t', 'gcr.io/$PROJECT_ID/snow-flow-website:latest',
|
|
9
9
|
'--cache-from', 'gcr.io/$PROJECT_ID/snow-flow-website:latest',
|
|
10
|
-
'
|
|
10
|
+
'-f', 'website/Dockerfile', # Specify Dockerfile location from root
|
|
11
|
+
'website/' # Build context is website directory
|
|
11
12
|
]
|
|
12
|
-
dir: 'website'
|
|
13
|
+
# Remove dir: 'website' to run from root
|
|
13
14
|
|
|
14
15
|
# Push the Docker image to Container Registry
|
|
15
16
|
- name: 'gcr.io/cloud-builders/docker'
|