@jagilber-org/index-server 1.22.0 → 1.26.1
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/CHANGELOG.md +87 -2
- package/CODE_OF_CONDUCT.md +2 -0
- package/CONTRIBUTING.md +32 -2
- package/README.md +83 -20
- package/SECURITY.md +17 -5
- package/dist/config/dashboardConfig.d.ts +3 -0
- package/dist/config/dashboardConfig.js +3 -0
- package/dist/config/defaultValues.d.ts +1 -1
- package/dist/config/defaultValues.js +1 -1
- package/dist/config/featureConfig.d.ts +2 -0
- package/dist/config/featureConfig.js +6 -1
- package/dist/config/runtimeConfig.d.ts +1 -1
- package/dist/config/runtimeConfig.js +8 -9
- package/dist/dashboard/client/admin.html +173 -54
- package/dist/dashboard/client/css/admin.css +151 -0
- package/dist/dashboard/client/js/admin.auth.js +25 -11
- package/dist/dashboard/client/js/admin.config.js +1 -1
- package/dist/dashboard/client/js/admin.feedback.js +328 -0
- package/dist/dashboard/client/js/admin.graph.js +120 -18
- package/dist/dashboard/client/js/admin.instructions.js +27 -13
- package/dist/dashboard/client/js/admin.logs.js +1 -5
- package/dist/dashboard/client/js/admin.maintenance.js +53 -8
- package/dist/dashboard/client/js/admin.messaging.js +1 -4
- package/dist/dashboard/client/js/admin.overview.js +5 -1
- package/dist/dashboard/client/js/admin.sessions.js +1 -1
- package/dist/dashboard/client/js/admin.utils.js +43 -1
- package/dist/dashboard/client/js/mermaid.min.js +813 -537
- package/dist/dashboard/export/DataExporter.js +2 -1
- package/dist/dashboard/server/AdminPanel.d.ts +3 -0
- package/dist/dashboard/server/AdminPanel.js +132 -35
- package/dist/dashboard/server/ApiRoutes.js +40 -9
- package/dist/dashboard/server/DashboardServer.js +1 -1
- package/dist/dashboard/server/FileMetricsStorage.d.ts +19 -0
- package/dist/dashboard/server/FileMetricsStorage.js +52 -5
- package/dist/dashboard/server/HttpTransport.js +6 -0
- package/dist/dashboard/server/InstanceManager.js +7 -2
- package/dist/dashboard/server/KnowledgeStore.js +7 -2
- package/dist/dashboard/server/MetricsCollector.d.ts +16 -0
- package/dist/dashboard/server/MetricsCollector.js +113 -17
- package/dist/dashboard/server/legacyDashboardHtml.js +7 -2
- package/dist/dashboard/server/middleware/ensureLoadedMiddleware.d.ts +1 -1
- package/dist/dashboard/server/middleware/ensureLoadedMiddleware.js +8 -3
- package/dist/dashboard/server/routes/admin.feedback.routes.d.ts +15 -0
- package/dist/dashboard/server/routes/admin.feedback.routes.js +188 -0
- package/dist/dashboard/server/routes/admin.routes.js +35 -27
- package/dist/dashboard/server/routes/alerts.routes.js +4 -3
- package/dist/dashboard/server/routes/api.feedback.routes.js +2 -1
- package/dist/dashboard/server/routes/api.usage.routes.js +8 -7
- package/dist/dashboard/server/routes/embeddings.routes.d.ts +2 -1
- package/dist/dashboard/server/routes/embeddings.routes.js +18 -9
- package/dist/dashboard/server/routes/graph.routes.js +10 -13
- package/dist/dashboard/server/routes/index.d.ts +1 -0
- package/dist/dashboard/server/routes/index.js +74 -39
- package/dist/dashboard/server/routes/instances.routes.js +2 -1
- package/dist/dashboard/server/routes/instructions.routes.js +46 -27
- package/dist/dashboard/server/routes/knowledge.routes.js +4 -3
- package/dist/dashboard/server/routes/logs.routes.js +5 -4
- package/dist/dashboard/server/routes/messaging.routes.js +15 -14
- package/dist/dashboard/server/routes/metrics.routes.js +14 -13
- package/dist/dashboard/server/routes/scripts.routes.js +6 -3
- package/dist/dashboard/server/routes/status.routes.js +25 -6
- package/dist/dashboard/server/routes/synthetic.routes.js +3 -2
- package/dist/dashboard/server/routes/usage.routes.js +2 -1
- package/dist/dashboard/server/utils/escapeHtml.d.ts +1 -0
- package/dist/dashboard/server/utils/escapeHtml.js +11 -0
- package/dist/dashboard/server/utils/pathContainment.d.ts +1 -0
- package/dist/dashboard/server/utils/pathContainment.js +15 -0
- package/dist/dashboard/server/wsInit.js +2 -2
- package/dist/lib/mcpStdioLogging.d.ts +165 -0
- package/dist/lib/mcpStdioLogging.js +287 -0
- package/dist/schemas/index.d.ts +37 -2
- package/dist/schemas/index.js +27 -3
- package/dist/server/backgroundServicesStartup.d.ts +7 -1
- package/dist/server/backgroundServicesStartup.js +25 -8
- package/dist/server/certInit.d.ts +97 -0
- package/dist/server/certInit.js +359 -0
- package/dist/server/certInit.types.d.ts +92 -0
- package/dist/server/certInit.types.js +34 -0
- package/dist/server/handshake/fallbackFrames.d.ts +31 -0
- package/dist/server/handshake/fallbackFrames.js +38 -0
- package/dist/server/handshake/initializeDetector.d.ts +31 -0
- package/dist/server/handshake/initializeDetector.js +88 -0
- package/dist/server/handshake/protocol.d.ts +15 -0
- package/dist/server/handshake/protocol.js +37 -0
- package/dist/server/handshake/readyEmitter.d.ts +6 -0
- package/dist/server/handshake/readyEmitter.js +88 -0
- package/dist/server/handshake/safetyFallbacks.d.ts +1 -0
- package/dist/server/handshake/safetyFallbacks.js +134 -0
- package/dist/server/handshake/stdinSniffer.d.ts +1 -0
- package/dist/server/handshake/stdinSniffer.js +260 -0
- package/dist/server/handshake/tracing.d.ts +16 -0
- package/dist/server/handshake/tracing.js +95 -0
- package/dist/server/handshakeManager.d.ts +23 -23
- package/dist/server/handshakeManager.js +36 -466
- package/dist/server/index-server.d.ts +23 -0
- package/dist/server/index-server.js +194 -9
- package/dist/server/mcpReadOnlySurfaces.d.ts +44 -0
- package/dist/server/mcpReadOnlySurfaces.js +297 -0
- package/dist/server/sdkServer.js +69 -7
- package/dist/server/transport.d.ts +5 -6
- package/dist/server/transport.js +46 -64
- package/dist/server/transportFactory.d.ts +3 -9
- package/dist/server/transportFactory.js +18 -380
- package/dist/services/atomicFs.d.ts +3 -0
- package/dist/services/atomicFs.js +171 -13
- package/dist/services/auditLog.d.ts +17 -2
- package/dist/services/auditLog.js +75 -14
- package/dist/services/bootstrapGating.js +1 -1
- package/dist/services/categoryRules.d.ts +10 -0
- package/dist/services/categoryRules.js +17 -0
- package/dist/services/classificationService.js +7 -5
- package/dist/services/embeddingService.d.ts +27 -11
- package/dist/services/embeddingService.js +51 -14
- package/dist/services/feedbackStorage.d.ts +39 -0
- package/dist/services/feedbackStorage.js +88 -0
- package/dist/services/handlers/instructions.add.js +429 -317
- package/dist/services/handlers/instructions.groom.js +128 -31
- package/dist/services/handlers/instructions.import.js +56 -23
- package/dist/services/handlers/instructions.patch.js +43 -32
- package/dist/services/handlers/instructions.query.js +20 -29
- package/dist/services/handlers/instructions.shared.d.ts +54 -0
- package/dist/services/handlers/instructions.shared.js +126 -1
- package/dist/services/handlers.activation.js +83 -81
- package/dist/services/handlers.dashboardConfig.d.ts +2 -2
- package/dist/services/handlers.dashboardConfig.js +1 -2
- package/dist/services/handlers.diagnostics.js +75 -54
- package/dist/services/handlers.feedback.d.ts +4 -11
- package/dist/services/handlers.feedback.js +11 -333
- package/dist/services/handlers.gates.js +69 -37
- package/dist/services/handlers.graph.js +2 -2
- package/dist/services/handlers.help.js +2 -2
- package/dist/services/handlers.instructionSchema.js +4 -2
- package/dist/services/handlers.integrity.js +42 -22
- package/dist/services/handlers.messaging.js +1 -1
- package/dist/services/handlers.metrics.js +51 -6
- package/dist/services/handlers.prompt.js +10 -2
- package/dist/services/handlers.search.js +94 -44
- package/dist/services/handlers.trace.js +1 -1
- package/dist/services/handlers.usage.js +38 -7
- package/dist/services/indexContext.d.ts +21 -1
- package/dist/services/indexContext.js +267 -82
- package/dist/services/indexLoader.d.ts +1 -0
- package/dist/services/indexLoader.js +28 -8
- package/dist/services/instructionRecordValidation.d.ts +39 -0
- package/dist/services/instructionRecordValidation.js +388 -0
- package/dist/services/instructions.dispatcher.js +4 -4
- package/dist/services/loaderSchemaValidator.d.ts +15 -0
- package/dist/services/loaderSchemaValidator.js +69 -0
- package/dist/services/logger.js +11 -2
- package/dist/services/mcpLogBridge.d.ts +49 -0
- package/dist/services/mcpLogBridge.js +83 -0
- package/dist/services/ownershipService.js +18 -8
- package/dist/services/performanceBaseline.js +23 -22
- package/dist/services/promptReviewService.d.ts +3 -1
- package/dist/services/promptReviewService.js +41 -13
- package/dist/services/regexSafety.d.ts +6 -0
- package/dist/services/regexSafety.js +46 -0
- package/dist/services/seedBootstrap.js +4 -4
- package/dist/services/storage/factory.d.ts +14 -1
- package/dist/services/storage/factory.js +61 -1
- package/dist/services/storage/jsonEmbeddingStore.d.ts +15 -0
- package/dist/services/storage/jsonEmbeddingStore.js +83 -0
- package/dist/services/storage/jsonFileStore.d.ts +3 -1
- package/dist/services/storage/jsonFileStore.js +8 -6
- package/dist/services/storage/migrationEngine.d.ts +13 -0
- package/dist/services/storage/migrationEngine.js +31 -0
- package/dist/services/storage/sqliteEmbeddingStore.d.ts +30 -0
- package/dist/services/storage/sqliteEmbeddingStore.js +222 -0
- package/dist/services/storage/sqliteStore.d.ts +3 -1
- package/dist/services/storage/sqliteStore.js +2 -2
- package/dist/services/storage/types.d.ts +48 -1
- package/dist/services/toolRegistry.js +77 -67
- package/dist/services/toolRegistry.zod.js +89 -86
- package/dist/services/tracing.js +5 -4
- package/dist/utils/envUtils.d.ts +4 -0
- package/dist/utils/envUtils.js +7 -0
- package/dist/utils/memoryMonitor.js +11 -10
- package/package.json +11 -4
- package/schemas/instruction.schema.json +38 -1
- package/scripts/copy-dashboard-assets.mjs +1 -1
- package/scripts/dist/README.md +1 -1
- package/scripts/setup-wizard.mjs +781 -0
- package/server.json +1 -0
- package/dist/externalClientLib.d.ts +0 -1
- package/dist/externalClientLib.js +0 -2
- package/dist/portableClientWrapper.d.ts +0 -1
- package/dist/portableClientWrapper.js +0 -2
- package/dist/services/indexingService.d.ts +0 -1
- package/dist/services/indexingService.js +0 -2
|
@@ -10,8 +10,55 @@ exports.getToolRegistry = getToolRegistry;
|
|
|
10
10
|
*/
|
|
11
11
|
const schemas_1 = require("../schemas");
|
|
12
12
|
const featureFlags_1 = require("./featureFlags");
|
|
13
|
+
const envUtils_1 = require("../utils/envUtils");
|
|
14
|
+
const runtimeConfig_1 = require("../config/runtimeConfig");
|
|
13
15
|
// Input schema helpers (keep intentionally permissive if params optional)
|
|
14
16
|
const stringReq = (name) => ({ type: 'object', additionalProperties: false, required: [name], properties: { [name]: { type: 'string' } } });
|
|
17
|
+
const extensionsInputSchema = {
|
|
18
|
+
type: 'object',
|
|
19
|
+
additionalProperties: {
|
|
20
|
+
anyOf: [
|
|
21
|
+
{ type: 'string' },
|
|
22
|
+
{ type: 'number' },
|
|
23
|
+
{ type: 'boolean' },
|
|
24
|
+
{ type: 'array', items: {} },
|
|
25
|
+
{ type: 'object', additionalProperties: true },
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const DANGEROUS_DIAGNOSTIC_TOOLS = new Set([
|
|
30
|
+
'diagnostics_block',
|
|
31
|
+
'diagnostics_microtaskFlood',
|
|
32
|
+
'diagnostics_memoryPressure',
|
|
33
|
+
]);
|
|
34
|
+
function buildInstructionBodyInputSchema(baseDescription) {
|
|
35
|
+
const maxLength = (0, runtimeConfig_1.getRuntimeConfig)().index.bodyWarnLength;
|
|
36
|
+
return {
|
|
37
|
+
type: 'string',
|
|
38
|
+
maxLength,
|
|
39
|
+
description: `${baseDescription} Current write limit: ${maxLength} characters via INDEX_SERVER_BODY_WARN_LENGTH. Split oversized content into cross-linked instructions.`,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function withDynamicInstructionBodyLimits(name, inputSchema) {
|
|
43
|
+
const schema = JSON.parse(JSON.stringify(inputSchema));
|
|
44
|
+
if (name === 'index_add') {
|
|
45
|
+
const entryProps = schema.properties?.entry?.properties ?? {};
|
|
46
|
+
entryProps.body = buildInstructionBodyInputSchema('Instruction body.');
|
|
47
|
+
}
|
|
48
|
+
else if (name === 'index_import') {
|
|
49
|
+
const entries = schema.properties?.entries?.oneOf;
|
|
50
|
+
const arrayVariant = Array.isArray(entries) ? entries.find((candidate) => candidate.type === 'array') : undefined;
|
|
51
|
+
const itemProps = arrayVariant?.items?.properties ?? {};
|
|
52
|
+
itemProps.body = buildInstructionBodyInputSchema('Instruction body.');
|
|
53
|
+
}
|
|
54
|
+
else if (name === 'index_dispatch') {
|
|
55
|
+
const props = schema.properties ?? {};
|
|
56
|
+
const entryProps = props.entry?.properties ?? {};
|
|
57
|
+
entryProps.body = buildInstructionBodyInputSchema('Instruction body for action="add".');
|
|
58
|
+
props.body = buildInstructionBodyInputSchema('Flat instruction body for action="add".');
|
|
59
|
+
}
|
|
60
|
+
return schema;
|
|
61
|
+
}
|
|
15
62
|
// Explicit param schemas derived from handlers in toolHandlers.ts
|
|
16
63
|
const INPUT_SCHEMAS = {
|
|
17
64
|
// graph export (Phase 1 + Phase 2 enrichment). All params optional.
|
|
@@ -47,7 +94,7 @@ const INPUT_SCHEMAS = {
|
|
|
47
94
|
keywords: { type: 'array', items: { type: 'string' }, description: 'Explicit keyword array for search action when the caller wants direct token control.' },
|
|
48
95
|
ids: { type: 'array', items: { type: 'string' }, description: 'Array of instruction IDs for remove or export actions.' },
|
|
49
96
|
category: { type: 'string', description: 'Filter by category for list action.' },
|
|
50
|
-
contentType: { type: 'string', description: 'Filter by content type for list, search, or query actions.' },
|
|
97
|
+
contentType: { type: 'string', enum: ['instruction', 'template', 'chat-session', 'reference', 'example', 'agent'], description: 'Filter by content type for list, search, or query actions, or specify the entry content type for add action.' },
|
|
51
98
|
text: { type: 'string', description: 'Full-text search within query action.' },
|
|
52
99
|
includeCategories: { type: 'boolean', description: 'Search categories in addition to id/title/semanticSummary/body for search action.' },
|
|
53
100
|
caseSensitive: { type: 'boolean', description: 'Enable case-sensitive matching for search action.' },
|
|
@@ -59,6 +106,15 @@ const INPUT_SCHEMAS = {
|
|
|
59
106
|
offset: { type: 'number', description: 'Pagination offset (query action).' },
|
|
60
107
|
// Mutation params for add action (flat-param support: agents can pass these at top level instead of nested entry wrapper)
|
|
61
108
|
entry: { type: 'object', description: 'Instruction entry object for add action. Alternatively, pass id/body/title as top-level params.', additionalProperties: true, properties: { id: { type: 'string' }, title: { type: 'string' }, body: { type: 'string' } } },
|
|
109
|
+
priority: { type: 'number' },
|
|
110
|
+
audience: { type: 'string' },
|
|
111
|
+
requirement: { type: 'string' },
|
|
112
|
+
categories: { type: 'array', items: { type: 'string' } },
|
|
113
|
+
deprecatedBy: { type: 'string' },
|
|
114
|
+
riskScore: { type: 'number' },
|
|
115
|
+
version: { type: 'string' },
|
|
116
|
+
priorityTier: { type: 'string', enum: ['P1', 'P2', 'P3', 'P4'] },
|
|
117
|
+
classification: { type: 'string', enum: ['public', 'internal', 'restricted'] },
|
|
62
118
|
overwrite: { type: 'boolean', description: 'Allow overwriting existing instruction (add action).' },
|
|
63
119
|
lax: { type: 'boolean', description: 'Enable lax mode with default fills for missing optional fields (add action).' },
|
|
64
120
|
// Import action params
|
|
@@ -66,8 +122,8 @@ const INPUT_SCHEMAS = {
|
|
|
66
122
|
source: { type: 'string', description: 'Directory path containing .json instruction files to import (import action).' },
|
|
67
123
|
mode: { description: 'Import conflict resolution mode (import action) or groom mode object (groom action).' },
|
|
68
124
|
// Governance update params
|
|
69
|
-
owner: { type: 'string', description: 'Owner identifier for governanceUpdate action.' },
|
|
70
|
-
status: { type: 'string', description: 'Governance status for governanceUpdate action.', enum: ['approved', 'draft', 'deprecated'] },
|
|
125
|
+
owner: { type: 'string', description: 'Owner identifier for governanceUpdate action or add action.' },
|
|
126
|
+
status: { type: 'string', description: 'Governance status for governanceUpdate action or add action.', enum: ['approved', 'draft', 'review', 'deprecated'] },
|
|
71
127
|
bump: { type: 'string', description: 'Version bump level for governanceUpdate action.', enum: ['patch', 'minor', 'major', 'none'] },
|
|
72
128
|
lastReviewedAt: { type: 'string', description: 'Last review date (ISO 8601) for governanceUpdate action.' },
|
|
73
129
|
nextReviewDue: { type: 'string', description: 'Next review due date (ISO 8601) for governanceUpdate action.' },
|
|
@@ -91,8 +147,8 @@ const INPUT_SCHEMAS = {
|
|
|
91
147
|
// legacy read-only instruction method schemas removed in favor of dispatcher
|
|
92
148
|
'index_import': { type: 'object', additionalProperties: false, properties: {
|
|
93
149
|
entries: { oneOf: [
|
|
94
|
-
{ type: 'array', minItems: 1, items: { type: 'object', required: ['id', 'title', 'body', 'priority', 'audience', 'requirement'], additionalProperties:
|
|
95
|
-
id: { type: 'string' }, title: { type: 'string' }, body: { type: 'string',
|
|
150
|
+
{ type: 'array', minItems: 1, items: { type: 'object', required: ['id', 'title', 'body', 'priority', 'audience', 'requirement'], additionalProperties: false, properties: {
|
|
151
|
+
id: { type: 'string' }, title: { type: 'string' }, body: { type: 'string' }, rationale: { type: 'string' }, priority: { type: 'number' }, audience: { type: 'string' }, requirement: { type: 'string' }, categories: { type: 'array', items: { type: 'string' } }, version: { type: 'string' }, owner: { type: 'string' }, status: { type: 'string', enum: ['approved', 'draft', 'review', 'deprecated'] }, priorityTier: { type: 'string', enum: ['P1', 'P2', 'P3', 'P4'] }, classification: { type: 'string', enum: ['public', 'internal', 'restricted'] }, lastReviewedAt: { type: 'string' }, nextReviewDue: { type: 'string' }, semanticSummary: { type: 'string' }, changeLog: { type: 'array', items: { type: 'object', additionalProperties: true } }, contentType: { type: 'string', enum: ['instruction', 'template', 'chat-session', 'reference', 'example', 'agent'] }, extensions: extensionsInputSchema, mode: { type: 'string' }
|
|
96
152
|
} } },
|
|
97
153
|
{ type: 'string', description: 'Stringified JSON array of instruction entries, or a file path to a JSON array of instruction entries' }
|
|
98
154
|
] },
|
|
@@ -100,8 +156,8 @@ const INPUT_SCHEMAS = {
|
|
|
100
156
|
mode: { enum: ['skip', 'overwrite'] }
|
|
101
157
|
} },
|
|
102
158
|
'index_add': { type: 'object', additionalProperties: false, required: ['entry'], properties: {
|
|
103
|
-
entry: { type: 'object', required: ['id', 'body'], additionalProperties:
|
|
104
|
-
id: { type: 'string' }, title: { type: 'string' }, body: { type: 'string',
|
|
159
|
+
entry: { type: 'object', required: ['id', 'body'], additionalProperties: false, properties: {
|
|
160
|
+
id: { type: 'string', maxLength: 120 }, title: { type: 'string' }, body: { type: 'string' }, rationale: { type: 'string' }, priority: { type: 'number' }, audience: { type: 'string' }, requirement: { type: 'string' }, categories: { type: 'array', items: { type: 'string' } }, deprecatedBy: { type: 'string' }, riskScore: { type: 'number' }, version: { type: 'string' }, owner: { type: 'string' }, status: { type: 'string', enum: ['approved', 'draft', 'review', 'deprecated'] }, priorityTier: { type: 'string', enum: ['P1', 'P2', 'P3', 'P4'] }, classification: { type: 'string', enum: ['public', 'internal', 'restricted'] }, lastReviewedAt: { type: 'string' }, nextReviewDue: { type: 'string' }, semanticSummary: { type: 'string' }, changeLog: { type: 'array', items: { type: 'object', additionalProperties: true } }, contentType: { type: 'string', enum: ['instruction', 'template', 'chat-session', 'reference', 'example', 'agent'] }, extensions: extensionsInputSchema
|
|
105
161
|
} },
|
|
106
162
|
overwrite: { type: 'boolean' },
|
|
107
163
|
lax: { type: 'boolean' }
|
|
@@ -152,46 +208,6 @@ const INPUT_SCHEMAS = {
|
|
|
152
208
|
metadata: { type: 'object', additionalProperties: true },
|
|
153
209
|
tags: { type: 'array', maxItems: 10, items: { type: 'string' } }
|
|
154
210
|
} },
|
|
155
|
-
'feedback_list': { type: 'object', additionalProperties: false, properties: {
|
|
156
|
-
type: { type: 'string', enum: ['issue', 'status', 'security', 'feature-request', 'bug-report', 'performance', 'usability', 'other'] },
|
|
157
|
-
severity: { type: 'string', enum: ['low', 'medium', 'high', 'critical'] },
|
|
158
|
-
status: { type: 'string', enum: ['new', 'acknowledged', 'in-progress', 'resolved', 'closed'] },
|
|
159
|
-
limit: { type: 'number', minimum: 1, maximum: 200 },
|
|
160
|
-
offset: { type: 'number', minimum: 0 },
|
|
161
|
-
since: { type: 'string' },
|
|
162
|
-
tags: { type: 'array', items: { type: 'string' } }
|
|
163
|
-
} },
|
|
164
|
-
'feedback_get': { type: 'object', additionalProperties: false, required: ['id'], properties: {
|
|
165
|
-
id: { type: 'string' }
|
|
166
|
-
} },
|
|
167
|
-
'feedback_update': { type: 'object', additionalProperties: false, required: ['id'], properties: {
|
|
168
|
-
id: { type: 'string' },
|
|
169
|
-
status: { type: 'string', enum: ['new', 'acknowledged', 'in-progress', 'resolved', 'closed'] },
|
|
170
|
-
metadata: { type: 'object', additionalProperties: true }
|
|
171
|
-
} },
|
|
172
|
-
'feedback_stats': { type: 'object', additionalProperties: false, properties: {
|
|
173
|
-
since: { type: 'string' }
|
|
174
|
-
} },
|
|
175
|
-
'feedback_health': { type: 'object', additionalProperties: true },
|
|
176
|
-
// Unified feedback dispatch (002 Phase 2a)
|
|
177
|
-
'feedback_dispatch': { type: 'object', additionalProperties: true, required: ['action'], properties: {
|
|
178
|
-
action: { type: 'string', enum: ['submit', 'list', 'get', 'update', 'stats', 'health', 'rate'], description: 'Feedback action to perform.' },
|
|
179
|
-
instructionId: { type: 'string', description: 'Instruction ID to rate (rate action).' },
|
|
180
|
-
rating: { type: 'string', enum: ['useful', 'not-useful', 'outdated', 'incomplete'], description: 'Rating value (rate action).' },
|
|
181
|
-
comment: { type: 'string', maxLength: 1000, description: 'Optional comment with rating (rate action).' },
|
|
182
|
-
type: { type: 'string', enum: ['issue', 'status', 'security', 'feature-request', 'bug-report', 'performance', 'usability', 'other'] },
|
|
183
|
-
severity: { type: 'string', enum: ['low', 'medium', 'high', 'critical'] },
|
|
184
|
-
title: { type: 'string', maxLength: 200 },
|
|
185
|
-
description: { type: 'string', maxLength: 10000, description: 'Feedback description/body text (submit).' },
|
|
186
|
-
body: { type: 'string', maxLength: 10000, description: 'Alias for description (submit).' },
|
|
187
|
-
id: { type: 'string' },
|
|
188
|
-
status: { type: 'string', enum: ['new', 'acknowledged', 'in-progress', 'resolved', 'closed'] },
|
|
189
|
-
limit: { type: 'number', minimum: 1, maximum: 200 },
|
|
190
|
-
offset: { type: 'number', minimum: 0 },
|
|
191
|
-
since: { type: 'string' },
|
|
192
|
-
tags: { type: 'array', items: { type: 'string' } },
|
|
193
|
-
metadata: { type: 'object', additionalProperties: true }
|
|
194
|
-
} },
|
|
195
211
|
// instructions search tool - PRIMARY discovery mechanism
|
|
196
212
|
'index_search': { type: 'object', additionalProperties: false, required: ['keywords'], properties: {
|
|
197
213
|
keywords: {
|
|
@@ -226,9 +242,9 @@ const INPUT_SCHEMAS = {
|
|
|
226
242
|
token: { type: 'string', description: 'Token for confirm action.' }
|
|
227
243
|
} },
|
|
228
244
|
// diagnostics / test-only tools (not stable)
|
|
229
|
-
'diagnostics_block': { type: 'object', additionalProperties: false, required: ['ms'], properties: { ms: { type: 'number', minimum: 0, maximum:
|
|
230
|
-
'diagnostics_microtaskFlood': { type: 'object', additionalProperties: false, properties: { count: { type: 'number', minimum: 0, maximum:
|
|
231
|
-
'diagnostics_memoryPressure': { type: 'object', additionalProperties: false, properties: { mb: { type: 'number', minimum: 1, maximum:
|
|
245
|
+
'diagnostics_block': { type: 'object', additionalProperties: false, required: ['ms'], properties: { ms: { type: 'number', minimum: 0, maximum: 1000 } } },
|
|
246
|
+
'diagnostics_microtaskFlood': { type: 'object', additionalProperties: false, properties: { count: { type: 'number', minimum: 0, maximum: 25000 } } },
|
|
247
|
+
'diagnostics_memoryPressure': { type: 'object', additionalProperties: false, properties: { mb: { type: 'number', minimum: 1, maximum: 64 } } }
|
|
232
248
|
};
|
|
233
249
|
// Inject new schema after definition block (kept outside literal to avoid large diff churn if ordering changes)
|
|
234
250
|
// Provide permissive object with optional includeTrace boolean.
|
|
@@ -305,20 +321,19 @@ INPUT_SCHEMAS['trace_dump'] = { type: 'object', additionalProperties: false, pro
|
|
|
305
321
|
file: { type: 'string', description: 'Optional path to write the trace buffer JSON file' }
|
|
306
322
|
} };
|
|
307
323
|
// Stable & mutation classification lists (mirrors usage in toolHandlers; exported to remove duplication there).
|
|
308
|
-
exports.STABLE = new Set(['health_check', 'graph_export', 'index_dispatch', 'index_search', 'index_governanceHash', 'prompt_review', 'integrity_verify', 'usage_track', 'usage_hotset', 'metrics_snapshot', 'gates_evaluate', 'meta_tools', 'help_overview', 'index_schema', '
|
|
309
|
-
exports.MUTATION = new Set(['index_add', 'index_import', 'index_repair', 'index_reload', 'index_remove', 'index_groom', 'index_enrich', 'index_governanceUpdate', 'index_normalize', 'usage_flush', 'feedback_submit', '
|
|
324
|
+
exports.STABLE = new Set(['health_check', 'graph_export', 'index_dispatch', 'index_search', 'index_governanceHash', 'prompt_review', 'integrity_verify', 'usage_track', 'usage_hotset', 'metrics_snapshot', 'gates_evaluate', 'meta_tools', 'help_overview', 'index_schema', 'manifest_status', 'index_diagnostics', 'meta_activation_guide', 'meta_check_activation', 'bootstrap', 'bootstrap_status', 'feature_status', 'index_health', 'index_inspect', 'index_debug', 'integrity_manifest', 'messaging_read', 'messaging_list_channels', 'messaging_stats', 'messaging_get', 'messaging_thread', 'trace_dump']);
|
|
325
|
+
exports.MUTATION = new Set(['index_add', 'index_import', 'index_repair', 'index_reload', 'index_remove', 'index_groom', 'index_enrich', 'index_governanceUpdate', 'index_normalize', 'usage_flush', 'feedback_submit', 'manifest_refresh', 'manifest_repair', 'promote_from_repo', 'bootstrap_request', 'bootstrap_confirmFinalize', 'messaging_send', 'messaging_ack', 'messaging_update', 'messaging_purge', 'messaging_reply', 'diagnostics_block', 'diagnostics_microtaskFlood', 'diagnostics_memoryPressure']);
|
|
310
326
|
// Tool tier classification (002-tool-consolidation spec)
|
|
311
327
|
// core: always visible, essential daily use
|
|
312
328
|
// extended: opt-in via INDEX_SERVER_FLAG_TOOLS_EXTENDED=1 or flags.json tools_extended:true
|
|
313
329
|
// admin: opt-in via INDEX_SERVER_FLAG_TOOLS_ADMIN=1, rarely needed ops/debug tools
|
|
314
330
|
const TOOL_TIERS = {
|
|
315
|
-
// Core (7)
|
|
331
|
+
// Core (7 → 6 after feedback_dispatch removal)
|
|
316
332
|
'health_check': 'core',
|
|
317
333
|
'index_dispatch': 'core',
|
|
318
334
|
'index_search': 'core',
|
|
319
335
|
'prompt_review': 'core',
|
|
320
336
|
'help_overview': 'core',
|
|
321
|
-
'feedback_dispatch': 'core',
|
|
322
337
|
'bootstrap': 'core',
|
|
323
338
|
// Extended (14)
|
|
324
339
|
'graph_export': 'extended',
|
|
@@ -337,8 +352,6 @@ const TOOL_TIERS = {
|
|
|
337
352
|
'index_schema': 'extended',
|
|
338
353
|
// Admin (everything else)
|
|
339
354
|
'feedback_submit': 'admin',
|
|
340
|
-
'feedback_list': 'admin',
|
|
341
|
-
'feedback_get': 'admin',
|
|
342
355
|
'meta_tools': 'admin',
|
|
343
356
|
'meta_activation_guide': 'admin',
|
|
344
357
|
'meta_check_activation': 'admin',
|
|
@@ -350,9 +363,6 @@ const TOOL_TIERS = {
|
|
|
350
363
|
'index_enrich': 'admin',
|
|
351
364
|
'index_normalize': 'admin',
|
|
352
365
|
'usage_flush': 'admin',
|
|
353
|
-
'feedback_update': 'admin',
|
|
354
|
-
'feedback_stats': 'admin',
|
|
355
|
-
'feedback_health': 'admin',
|
|
356
366
|
'manifest_status': 'admin',
|
|
357
367
|
'manifest_refresh': 'admin',
|
|
358
368
|
'manifest_repair': 'admin',
|
|
@@ -391,12 +401,18 @@ function resolveActiveTier() {
|
|
|
391
401
|
function getToolRegistry(filter) {
|
|
392
402
|
const maxTier = filter?.tier ?? resolveActiveTier();
|
|
393
403
|
const maxLevel = TIER_LEVEL[maxTier];
|
|
404
|
+
const diagnosticsEnabled = (0, envUtils_1.dangerousDiagnosticsEnabled)();
|
|
394
405
|
const entries = [];
|
|
395
406
|
const names = new Set([...exports.STABLE, ...exports.MUTATION]);
|
|
396
407
|
// Ensure we also expose any tools that have schemas even if not in STABLE/MUTATION lists.
|
|
397
|
-
for (const k of Object.keys(INPUT_SCHEMAS))
|
|
408
|
+
for (const k of Object.keys(INPUT_SCHEMAS)) {
|
|
409
|
+
if (!diagnosticsEnabled && DANGEROUS_DIAGNOSTIC_TOOLS.has(k))
|
|
410
|
+
continue;
|
|
398
411
|
names.add(k);
|
|
412
|
+
}
|
|
399
413
|
for (const name of Array.from(names).sort()) {
|
|
414
|
+
if (!diagnosticsEnabled && DANGEROUS_DIAGNOSTIC_TOOLS.has(name))
|
|
415
|
+
continue;
|
|
400
416
|
const tier = TOOL_TIERS[name] || 'admin';
|
|
401
417
|
if (TIER_LEVEL[tier] > maxLevel)
|
|
402
418
|
continue;
|
|
@@ -407,7 +423,7 @@ function getToolRegistry(filter) {
|
|
|
407
423
|
stable: exports.STABLE.has(name),
|
|
408
424
|
mutation: exports.MUTATION.has(name),
|
|
409
425
|
tier,
|
|
410
|
-
inputSchema: INPUT_SCHEMAS[name] || { type: 'object' },
|
|
426
|
+
inputSchema: withDynamicInstructionBodyLimits(name, INPUT_SCHEMAS[name] || { type: 'object' }),
|
|
411
427
|
outputSchema,
|
|
412
428
|
// zodSchema to be attached incrementally by a forthcoming zodRegistry enhancer.
|
|
413
429
|
});
|
|
@@ -443,12 +459,6 @@ function describeTool(name) {
|
|
|
443
459
|
case 'meta_tools': return 'Enumerate available tools & their metadata.';
|
|
444
460
|
// feedback system descriptions
|
|
445
461
|
case 'feedback_submit': return 'Submit feedback entry (issue, status report, security alert, feature request, etc.).';
|
|
446
|
-
case 'feedback_list': return 'List feedback entries with filtering options (type, severity, status, date range).';
|
|
447
|
-
case 'feedback_get': return 'Get specific feedback entry by ID with full details.';
|
|
448
|
-
case 'feedback_update': return 'Update feedback entry status and metadata (admin function).';
|
|
449
|
-
case 'feedback_stats': return 'Get feedback system statistics and metrics dashboard.';
|
|
450
|
-
case 'feedback_health': return 'Health check for feedback system storage and configuration.';
|
|
451
|
-
case 'feedback_dispatch': return 'Unified feedback dispatcher. Actions: submit, list, get, update, stats, health, rate.';
|
|
452
462
|
case 'bootstrap': return 'Unified bootstrap dispatcher. Actions: request, confirm, status.';
|
|
453
463
|
case 'manifest_status': return 'Report index manifest presence and drift summary.';
|
|
454
464
|
case 'manifest_refresh': return 'Rewrite manifest from current index state.';
|
|
@@ -5,6 +5,7 @@ exports.getZodSchema = getZodSchema;
|
|
|
5
5
|
exports.hasZodSchema = hasZodSchema;
|
|
6
6
|
const zod_1 = require("zod");
|
|
7
7
|
const toolRegistry_1 = require("./toolRegistry");
|
|
8
|
+
const runtimeConfig_1 = require("../config/runtimeConfig");
|
|
8
9
|
/**
|
|
9
10
|
* Complete Zod schema registry for all MCP index tools.
|
|
10
11
|
* Zod schemas provide runtime validation with richer type inference.
|
|
@@ -13,6 +14,13 @@ const toolRegistry_1 = require("./toolRegistry");
|
|
|
13
14
|
// ── Reusable primitives ──────────────────────────────────────────────────────
|
|
14
15
|
const zEmpty = zod_1.z.object({}).passthrough();
|
|
15
16
|
const zStringId = zod_1.z.object({ id: zod_1.z.string().min(1) }).strict();
|
|
17
|
+
const zExtensionValue = zod_1.z.lazy(() => zod_1.z.union([
|
|
18
|
+
zod_1.z.string(),
|
|
19
|
+
zod_1.z.number(),
|
|
20
|
+
zod_1.z.boolean(),
|
|
21
|
+
zod_1.z.array(zExtensionValue),
|
|
22
|
+
zod_1.z.record(zod_1.z.string(), zExtensionValue),
|
|
23
|
+
]));
|
|
16
24
|
// ── Index dispatcher ───────────────────────────────────────────────────────
|
|
17
25
|
const zDispatch = zod_1.z.object({
|
|
18
26
|
action: zod_1.z.enum([
|
|
@@ -27,7 +35,7 @@ const zDispatch = zod_1.z.object({
|
|
|
27
35
|
keywords: zod_1.z.array(zod_1.z.string()).optional(),
|
|
28
36
|
ids: zod_1.z.array(zod_1.z.string()).optional(),
|
|
29
37
|
category: zod_1.z.string().optional(),
|
|
30
|
-
contentType: zod_1.z.
|
|
38
|
+
contentType: zod_1.z.enum(['instruction', 'template', 'chat-session', 'reference', 'example', 'agent']).optional(),
|
|
31
39
|
text: zod_1.z.string().optional(),
|
|
32
40
|
includeCategories: zod_1.z.boolean().optional(),
|
|
33
41
|
caseSensitive: zod_1.z.boolean().optional(),
|
|
@@ -38,13 +46,26 @@ const zDispatch = zod_1.z.object({
|
|
|
38
46
|
limit: zod_1.z.number().optional(),
|
|
39
47
|
offset: zod_1.z.number().optional(),
|
|
40
48
|
entry: zod_1.z.object({}).passthrough().optional(),
|
|
49
|
+
title: zod_1.z.string().optional(),
|
|
50
|
+
body: zod_1.z.string().optional(),
|
|
51
|
+
rationale: zod_1.z.string().optional(),
|
|
52
|
+
priority: zod_1.z.number().optional(),
|
|
53
|
+
audience: zod_1.z.string().optional(),
|
|
54
|
+
requirement: zod_1.z.string().optional(),
|
|
55
|
+
categories: zod_1.z.array(zod_1.z.string()).optional(),
|
|
56
|
+
deprecatedBy: zod_1.z.string().optional(),
|
|
57
|
+
riskScore: zod_1.z.number().optional(),
|
|
58
|
+
priorityTier: zod_1.z.enum(['P1', 'P2', 'P3', 'P4']).optional(),
|
|
59
|
+
classification: zod_1.z.enum(['public', 'internal', 'restricted']).optional(),
|
|
60
|
+
semanticSummary: zod_1.z.string().optional(),
|
|
61
|
+
changeLog: zod_1.z.array(zod_1.z.object({}).passthrough()).optional(),
|
|
41
62
|
overwrite: zod_1.z.boolean().optional(),
|
|
42
63
|
lax: zod_1.z.boolean().optional(),
|
|
43
64
|
entries: zod_1.z.union([zod_1.z.array(zod_1.z.object({}).passthrough()), zod_1.z.string()]).optional(),
|
|
44
65
|
source: zod_1.z.string().optional(),
|
|
45
66
|
mode: zod_1.z.unknown().optional(),
|
|
46
67
|
owner: zod_1.z.string().optional(),
|
|
47
|
-
status: zod_1.z.
|
|
68
|
+
status: zod_1.z.enum(['approved', 'draft', 'review', 'deprecated']).optional(),
|
|
48
69
|
bump: zod_1.z.enum(['patch', 'minor', 'major', 'none']).optional(),
|
|
49
70
|
lastReviewedAt: zod_1.z.string().optional(),
|
|
50
71
|
nextReviewDue: zod_1.z.string().optional(),
|
|
@@ -53,43 +74,62 @@ const zDispatch = zod_1.z.object({
|
|
|
53
74
|
dryRun: zod_1.z.boolean().optional()
|
|
54
75
|
}).passthrough();
|
|
55
76
|
// ── Index CRUD ─────────────────────────────────────────────────────────────
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
zod_1.z.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
zod_1.z.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
77
|
+
function zInstructionBody() {
|
|
78
|
+
return zod_1.z.string().min(1).max((0, runtimeConfig_1.getRuntimeConfig)().index.bodyWarnLength);
|
|
79
|
+
}
|
|
80
|
+
function buildZIndexEntry() {
|
|
81
|
+
return zod_1.z.object({
|
|
82
|
+
id: zod_1.z.string().min(1),
|
|
83
|
+
title: zod_1.z.string().min(1).optional(),
|
|
84
|
+
body: zInstructionBody(),
|
|
85
|
+
rationale: zod_1.z.string().optional(),
|
|
86
|
+
priority: zod_1.z.number().int().min(1).max(100).optional(),
|
|
87
|
+
audience: zod_1.z.string().optional(),
|
|
88
|
+
requirement: zod_1.z.string().optional(),
|
|
89
|
+
categories: zod_1.z.array(zod_1.z.string()).max(50).optional(),
|
|
90
|
+
deprecatedBy: zod_1.z.string().optional(),
|
|
91
|
+
riskScore: zod_1.z.number().optional(),
|
|
92
|
+
version: zod_1.z.string().optional(),
|
|
93
|
+
owner: zod_1.z.string().optional(),
|
|
94
|
+
status: zod_1.z.enum(['approved', 'draft', 'review', 'deprecated']).optional(),
|
|
95
|
+
priorityTier: zod_1.z.enum(['P1', 'P2', 'P3', 'P4']).optional(),
|
|
96
|
+
classification: zod_1.z.enum(['public', 'internal', 'restricted']).optional(),
|
|
97
|
+
lastReviewedAt: zod_1.z.string().optional(),
|
|
98
|
+
nextReviewDue: zod_1.z.string().optional(),
|
|
99
|
+
semanticSummary: zod_1.z.string().optional(),
|
|
100
|
+
changeLog: zod_1.z.array(zod_1.z.object({}).passthrough()).optional(),
|
|
101
|
+
contentType: zod_1.z.enum(['instruction', 'template', 'chat-session', 'reference', 'example', 'agent']).optional(),
|
|
102
|
+
extensions: zod_1.z.record(zod_1.z.string(), zExtensionValue).optional()
|
|
103
|
+
}).strict();
|
|
104
|
+
}
|
|
105
|
+
function buildZAdd() {
|
|
106
|
+
return zod_1.z.object({
|
|
107
|
+
entry: buildZIndexEntry(),
|
|
108
|
+
overwrite: zod_1.z.boolean().optional(),
|
|
109
|
+
lax: zod_1.z.boolean().optional()
|
|
110
|
+
}).strict();
|
|
111
|
+
}
|
|
112
|
+
function buildZImport() {
|
|
113
|
+
return zod_1.z.object({
|
|
114
|
+
entries: zod_1.z.union([
|
|
115
|
+
zod_1.z.array(zod_1.z.object({
|
|
116
|
+
id: zod_1.z.string(),
|
|
117
|
+
title: zod_1.z.string(),
|
|
118
|
+
body: zInstructionBody(),
|
|
119
|
+
rationale: zod_1.z.string().optional(),
|
|
120
|
+
priority: zod_1.z.number(),
|
|
121
|
+
audience: zod_1.z.string(),
|
|
122
|
+
requirement: zod_1.z.string(),
|
|
123
|
+
categories: zod_1.z.array(zod_1.z.string()).optional(),
|
|
124
|
+
extensions: zod_1.z.record(zod_1.z.string(), zExtensionValue).optional(),
|
|
125
|
+
mode: zod_1.z.string().optional()
|
|
126
|
+
}).passthrough()).min(1),
|
|
127
|
+
zod_1.z.string()
|
|
128
|
+
]).optional(),
|
|
129
|
+
source: zod_1.z.string().optional(),
|
|
130
|
+
mode: zod_1.z.enum(['skip', 'overwrite']).optional()
|
|
131
|
+
}).strict();
|
|
132
|
+
}
|
|
93
133
|
const zRemove = zod_1.z.object({
|
|
94
134
|
ids: zod_1.z.array(zod_1.z.string()).min(1),
|
|
95
135
|
missingOk: zod_1.z.boolean().optional(),
|
|
@@ -142,42 +182,6 @@ const zFeedbackSubmit = zod_1.z.object({
|
|
|
142
182
|
metadata: zod_1.z.object({}).passthrough().optional(),
|
|
143
183
|
tags: zod_1.z.array(zod_1.z.string()).max(10).optional()
|
|
144
184
|
}).strict();
|
|
145
|
-
const zFeedbackList = zod_1.z.object({
|
|
146
|
-
type: zod_1.z.enum(['issue', 'status', 'security', 'feature-request', 'bug-report', 'performance', 'usability', 'other']).optional(),
|
|
147
|
-
severity: zod_1.z.enum(['low', 'medium', 'high', 'critical']).optional(),
|
|
148
|
-
status: zod_1.z.enum(['new', 'acknowledged', 'in-progress', 'resolved', 'closed']).optional(),
|
|
149
|
-
limit: zod_1.z.number().int().min(1).max(200).optional(),
|
|
150
|
-
offset: zod_1.z.number().int().min(0).optional(),
|
|
151
|
-
since: zod_1.z.string().optional(),
|
|
152
|
-
tags: zod_1.z.array(zod_1.z.string()).optional()
|
|
153
|
-
}).strict();
|
|
154
|
-
const zFeedbackGet = zStringId;
|
|
155
|
-
const zFeedbackUpdate = zod_1.z.object({
|
|
156
|
-
id: zod_1.z.string().min(1),
|
|
157
|
-
status: zod_1.z.enum(['new', 'acknowledged', 'in-progress', 'resolved', 'closed']).optional(),
|
|
158
|
-
metadata: zod_1.z.object({}).passthrough().optional()
|
|
159
|
-
}).strict();
|
|
160
|
-
const zFeedbackStats = zod_1.z.object({
|
|
161
|
-
since: zod_1.z.string().optional()
|
|
162
|
-
}).strict();
|
|
163
|
-
const zFeedbackDispatch = zod_1.z.object({
|
|
164
|
-
action: zod_1.z.enum(['submit', 'list', 'get', 'update', 'stats', 'health', 'rate']),
|
|
165
|
-
instructionId: zod_1.z.string().optional(),
|
|
166
|
-
rating: zod_1.z.enum(['useful', 'not-useful', 'outdated', 'incomplete']).optional(),
|
|
167
|
-
comment: zod_1.z.string().max(1000).optional(),
|
|
168
|
-
type: zod_1.z.enum(['issue', 'status', 'security', 'feature-request', 'bug-report', 'performance', 'usability', 'other']).optional(),
|
|
169
|
-
severity: zod_1.z.enum(['low', 'medium', 'high', 'critical']).optional(),
|
|
170
|
-
title: zod_1.z.string().max(200).optional(),
|
|
171
|
-
description: zod_1.z.string().max(10000).optional(),
|
|
172
|
-
body: zod_1.z.string().max(10000).optional(),
|
|
173
|
-
id: zod_1.z.string().optional(),
|
|
174
|
-
status: zod_1.z.enum(['new', 'acknowledged', 'in-progress', 'resolved', 'closed']).optional(),
|
|
175
|
-
limit: zod_1.z.number().int().min(1).max(200).optional(),
|
|
176
|
-
offset: zod_1.z.number().int().min(0).optional(),
|
|
177
|
-
since: zod_1.z.string().optional(),
|
|
178
|
-
tags: zod_1.z.array(zod_1.z.string()).optional(),
|
|
179
|
-
metadata: zod_1.z.object({}).passthrough().optional()
|
|
180
|
-
}).passthrough();
|
|
181
185
|
// ── Usage ────────────────────────────────────────────────────────────────────
|
|
182
186
|
const zUsageTrack = zod_1.z.object({
|
|
183
187
|
id: zod_1.z.string().min(1),
|
|
@@ -257,14 +261,11 @@ const zodMap = {
|
|
|
257
261
|
'index_search': zSearch,
|
|
258
262
|
'prompt_review': zPromptReview,
|
|
259
263
|
'help_overview': zEmpty,
|
|
260
|
-
'feedback_dispatch': zFeedbackDispatch,
|
|
261
264
|
'bootstrap': zBootstrap,
|
|
262
265
|
// Extended tools
|
|
263
266
|
'graph_export': zGraphExport,
|
|
264
267
|
'usage_track': zUsageTrack,
|
|
265
268
|
'usage_hotset': zHotset,
|
|
266
|
-
'index_add': zAdd,
|
|
267
|
-
'index_import': zImport,
|
|
268
269
|
'index_remove': zRemove,
|
|
269
270
|
'index_reload': zEmpty,
|
|
270
271
|
'index_governanceHash': zEmpty,
|
|
@@ -276,11 +277,6 @@ const zodMap = {
|
|
|
276
277
|
'index_schema': zEmpty,
|
|
277
278
|
// Admin tools
|
|
278
279
|
'feedback_submit': zFeedbackSubmit,
|
|
279
|
-
'feedback_list': zFeedbackList,
|
|
280
|
-
'feedback_get': zFeedbackGet,
|
|
281
|
-
'feedback_update': zFeedbackUpdate,
|
|
282
|
-
'feedback_stats': zFeedbackStats,
|
|
283
|
-
'feedback_health': zEmpty,
|
|
284
280
|
'meta_tools': zEmpty,
|
|
285
281
|
'meta_activation_guide': zEmpty,
|
|
286
282
|
'meta_check_activation': zMetaCheckActivation,
|
|
@@ -305,10 +301,17 @@ const zodMap = {
|
|
|
305
301
|
'diagnostics_microtaskFlood': zDiagnosticsMicrotaskFlood,
|
|
306
302
|
'diagnostics_memoryPressure': zDiagnosticsMemoryPressure,
|
|
307
303
|
};
|
|
304
|
+
function getZodSchemaForTool(toolName) {
|
|
305
|
+
if (toolName === 'index_add')
|
|
306
|
+
return buildZAdd();
|
|
307
|
+
if (toolName === 'index_import')
|
|
308
|
+
return buildZImport();
|
|
309
|
+
return zodMap[toolName];
|
|
310
|
+
}
|
|
308
311
|
function getZodEnhancedRegistry() {
|
|
309
312
|
const base = (0, toolRegistry_1.getToolRegistry)({ tier: 'admin' });
|
|
310
313
|
for (const e of base) {
|
|
311
|
-
const zSchema =
|
|
314
|
+
const zSchema = getZodSchemaForTool(e.name);
|
|
312
315
|
if (zSchema) {
|
|
313
316
|
e.zodSchema = zSchema;
|
|
314
317
|
}
|
|
@@ -317,9 +320,9 @@ function getZodEnhancedRegistry() {
|
|
|
317
320
|
}
|
|
318
321
|
/** Get the Zod schema for a specific tool by name */
|
|
319
322
|
function getZodSchema(toolName) {
|
|
320
|
-
return
|
|
323
|
+
return getZodSchemaForTool(toolName);
|
|
321
324
|
}
|
|
322
325
|
/** Check if a tool has a Zod schema registered */
|
|
323
326
|
function hasZodSchema(toolName) {
|
|
324
|
-
return toolName in zodMap;
|
|
327
|
+
return toolName === 'index_add' || toolName === 'index_import' || toolName in zodMap;
|
|
325
328
|
}
|
package/dist/services/tracing.js
CHANGED
|
@@ -12,7 +12,9 @@ exports.getTraceFile = getTraceFile;
|
|
|
12
12
|
exports.summarizeTraceEnv = summarizeTraceEnv;
|
|
13
13
|
const fs_1 = __importDefault(require("fs"));
|
|
14
14
|
const path_1 = __importDefault(require("path"));
|
|
15
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
15
16
|
const runtimeConfig_1 = require("../config/runtimeConfig");
|
|
17
|
+
const logger_js_1 = require("./logger.js");
|
|
16
18
|
let cachedLevel = 0;
|
|
17
19
|
let lastLevelCheck = 0;
|
|
18
20
|
let traceStream = null;
|
|
@@ -72,7 +74,7 @@ function resolveSessionId() {
|
|
|
72
74
|
return cachedSessionId;
|
|
73
75
|
const tracing = (0, runtimeConfig_1.getRuntimeConfig)().tracing;
|
|
74
76
|
const provided = tracing.sessionId && tracing.sessionId.trim().length ? tracing.sessionId.trim() : undefined;
|
|
75
|
-
cachedSessionId = provided ||
|
|
77
|
+
cachedSessionId = provided || crypto_1.default.randomBytes(4).toString('hex');
|
|
76
78
|
return cachedSessionId;
|
|
77
79
|
}
|
|
78
80
|
function categoriesAllow(label, categories) {
|
|
@@ -218,8 +220,7 @@ function emitTrace(label, data, min = 1) {
|
|
|
218
220
|
rec.func = caller;
|
|
219
221
|
pushBuffer(rec, tracing.buffer);
|
|
220
222
|
try {
|
|
221
|
-
|
|
222
|
-
console.error(label, JSON.stringify(rec));
|
|
223
|
+
(0, logger_js_1.logError)(label, JSON.stringify(rec));
|
|
223
224
|
}
|
|
224
225
|
catch { /* ignore */ }
|
|
225
226
|
if (!(tracing.persist || tracing.file))
|
|
@@ -230,7 +231,7 @@ function emitTrace(label, data, min = 1) {
|
|
|
230
231
|
return;
|
|
231
232
|
const line = `${label} ${JSON.stringify(rec)}\n`;
|
|
232
233
|
try {
|
|
233
|
-
stream.write(line);
|
|
234
|
+
stream.write(line); // lgtm[js/http-to-file-access] — trace stream targets config-controlled trace file
|
|
234
235
|
traceBytesWritten += Buffer.byteLength(line);
|
|
235
236
|
rotateIfNeeded();
|
|
236
237
|
if (tracing.fsync) {
|
package/dist/utils/envUtils.d.ts
CHANGED
|
@@ -40,3 +40,7 @@ export declare function parseBooleanEnv(envVar: string | undefined, defaultValue
|
|
|
40
40
|
* @returns boolean value
|
|
41
41
|
*/
|
|
42
42
|
export declare function getBooleanEnv(name: string, defaultValue?: boolean): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Dangerous diagnostics are only available in explicit debug / stress sessions.
|
|
45
|
+
*/
|
|
46
|
+
export declare function dangerousDiagnosticsEnabled(): boolean;
|
package/dist/utils/envUtils.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.isFalsyExtended = isFalsyExtended;
|
|
|
10
10
|
exports.isDebugOrVerbose = isDebugOrVerbose;
|
|
11
11
|
exports.parseBooleanEnv = parseBooleanEnv;
|
|
12
12
|
exports.getBooleanEnv = getBooleanEnv;
|
|
13
|
+
exports.dangerousDiagnosticsEnabled = dangerousDiagnosticsEnabled;
|
|
13
14
|
// ── Canonical truthy / falsy value sets ──────────────────────────────
|
|
14
15
|
exports.TRUTHY_VALUES = ['1', 'true', 'yes', 'on'];
|
|
15
16
|
exports.FALSY_VALUES = ['0', 'false', 'no', 'off'];
|
|
@@ -78,3 +79,9 @@ function parseBooleanEnv(envVar, defaultValue = false) {
|
|
|
78
79
|
function getBooleanEnv(name, defaultValue = false) {
|
|
79
80
|
return parseBooleanEnv(process.env[name], defaultValue);
|
|
80
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Dangerous diagnostics are only available in explicit debug / stress sessions.
|
|
84
|
+
*/
|
|
85
|
+
function dangerousDiagnosticsEnabled() {
|
|
86
|
+
return getBooleanEnv('INDEX_SERVER_STRESS_DIAG') || getBooleanEnv('INDEX_SERVER_DEBUG');
|
|
87
|
+
}
|