@vfarcic/dot-ai 1.2.4 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/artifacthub.d.ts.map +1 -1
- package/dist/core/artifacthub.js +16 -10
- package/dist/core/base-vector-service.d.ts.map +1 -1
- package/dist/core/base-vector-service.js +19 -10
- package/dist/core/capabilities.d.ts.map +1 -1
- package/dist/core/capabilities.js +17 -11
- package/dist/core/capability-operations.d.ts.map +1 -1
- package/dist/core/capability-operations.js +118 -98
- package/dist/core/crd-availability.d.ts.map +1 -1
- package/dist/core/crd-availability.js +2 -2
- package/dist/core/deploy-operation.d.ts.map +1 -1
- package/dist/core/deploy-operation.js +9 -6
- package/dist/core/discovery.d.ts.map +1 -1
- package/dist/core/discovery.js +157 -56
- package/dist/core/embedding-service.d.ts +1 -1
- package/dist/core/embedding-service.d.ts.map +1 -1
- package/dist/core/embedding-service.js +76 -43
- package/dist/core/model-config.d.ts +3 -3
- package/dist/core/model-config.js +3 -3
- package/dist/core/packaging.d.ts.map +1 -1
- package/dist/core/packaging.js +11 -10
- package/dist/core/platform-utils.d.ts.map +1 -1
- package/dist/core/platform-utils.js +6 -2
- package/dist/core/plugin-manager.d.ts.map +1 -1
- package/dist/core/plugin-manager.js +26 -20
- package/dist/core/policy-operations.d.ts.map +1 -1
- package/dist/core/policy-operations.js +111 -65
- package/dist/core/providers/host-provider.d.ts.map +1 -1
- package/dist/core/providers/host-provider.js +12 -5
- package/dist/core/providers/vercel-provider.d.ts.map +1 -1
- package/dist/core/providers/vercel-provider.js +4 -2
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/schema.js +173 -95
- package/dist/core/session-utils.d.ts.map +1 -1
- package/dist/core/session-utils.js +3 -3
- package/dist/core/user-prompts-loader.d.ts.map +1 -1
- package/dist/core/user-prompts-loader.js +2 -4
- package/dist/evaluation/datasets/loader.d.ts.map +1 -1
- package/dist/evaluation/datasets/loader.js +7 -3
- package/dist/interfaces/embedding-migration-handler.d.ts +16 -0
- package/dist/interfaces/embedding-migration-handler.d.ts.map +1 -0
- package/dist/interfaces/embedding-migration-handler.js +296 -0
- package/dist/interfaces/rest-api.d.ts +8 -0
- package/dist/interfaces/rest-api.d.ts.map +1 -1
- package/dist/interfaces/rest-api.js +294 -132
- package/dist/interfaces/rest-route-registry.js +3 -3
- package/dist/interfaces/routes/index.d.ts.map +1 -1
- package/dist/interfaces/routes/index.js +72 -12
- package/dist/interfaces/schemas/common.d.ts +2 -0
- package/dist/interfaces/schemas/common.d.ts.map +1 -1
- package/dist/interfaces/schemas/common.js +2 -0
- package/dist/interfaces/schemas/embeddings.d.ts +138 -0
- package/dist/interfaces/schemas/embeddings.d.ts.map +1 -0
- package/dist/interfaces/schemas/embeddings.js +79 -0
- package/dist/interfaces/schemas/index.d.ts +2 -1
- package/dist/interfaces/schemas/index.d.ts.map +1 -1
- package/dist/interfaces/schemas/index.js +14 -2
- package/dist/interfaces/schemas/prompts.d.ts +37 -0
- package/dist/interfaces/schemas/prompts.d.ts.map +1 -1
- package/dist/interfaces/schemas/prompts.js +18 -1
- package/dist/tools/answer-question.d.ts.map +1 -1
- package/dist/tools/answer-question.js +109 -81
- package/dist/tools/generate-manifests.d.ts.map +1 -1
- package/dist/tools/generate-manifests.js +163 -103
- package/dist/tools/operate-analysis.d.ts.map +1 -1
- package/dist/tools/operate-analysis.js +35 -18
- package/dist/tools/operate.d.ts.map +1 -1
- package/dist/tools/operate.js +47 -17
- package/dist/tools/prompts.d.ts.map +1 -1
- package/dist/tools/prompts.js +1 -1
- package/dist/tools/remediate.d.ts.map +1 -1
- package/dist/tools/remediate.js +205 -116
- package/package.json +6 -6
- package/prompts/remediate-system.md +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-utils.d.ts","sourceRoot":"","sources":["../../src/core/session-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAS5C;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"session-utils.d.ts","sourceRoot":"","sources":["../../src/core/session-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAS5C;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,YAAY,GAAE,OAAe,GAC5B,IAAI,CAwDN;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,YAAY,GAAE,OAAe,GAC5B,MAAM,CAIR"}
|
|
@@ -90,14 +90,14 @@ function validateSessionDirectory(sessionDir, requireWrite = false) {
|
|
|
90
90
|
}
|
|
91
91
|
// Handle permission errors
|
|
92
92
|
if (error.message.includes('EACCES')) {
|
|
93
|
-
throw new Error(`Session directory is not accessible: ${sessionDir}. Check permissions
|
|
93
|
+
throw new Error(`Session directory is not accessible: ${sessionDir}. Check permissions.`, { cause: error });
|
|
94
94
|
}
|
|
95
95
|
// Handle write permission errors
|
|
96
96
|
if (requireWrite) {
|
|
97
|
-
throw new Error(`Session directory is not writable: ${sessionDir}. Error: ${error.message}
|
|
97
|
+
throw new Error(`Session directory is not writable: ${sessionDir}. Error: ${error.message}`, { cause: error });
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
throw new Error(`Session directory validation failed: ${sessionDir}. Error: ${error}
|
|
100
|
+
throw new Error(`Session directory validation failed: ${sessionDir}. Error: ${error}`, { cause: error });
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-prompts-loader.d.ts","sourceRoot":"","sources":["../../src/core/user-prompts-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAkB,MAAM,kBAAkB,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,UAAU,UAAU;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAKD;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"user-prompts-loader.d.ts","sourceRoot":"","sources":["../../src/core/user-prompts-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAkB,MAAM,kBAAkB,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,UAAU,UAAU;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAKD;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,GAAG,IAAI,CAsB/D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAqB1C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CASnE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAUzD;AA+JD;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,YAAY,GAAE,OAAe,GAC5B,OAAO,CAAC,MAAM,EAAE,CAAC,CA0DnB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,UAAU,GAAG,IAAI,CAE5D"}
|
|
@@ -188,7 +188,7 @@ async function cloneRepository(config, localPath, logger) {
|
|
|
188
188
|
url: sanitizedUrl,
|
|
189
189
|
branch: config.branch,
|
|
190
190
|
});
|
|
191
|
-
throw new Error(`Failed to clone user prompts repository: ${sanitizedError}
|
|
191
|
+
throw new Error(`Failed to clone user prompts repository: ${sanitizedError}`, { cause: error });
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
/**
|
|
@@ -250,9 +250,7 @@ async function ensureRepository(config, logger, forceRefresh = false) {
|
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
252
|
// Return path to prompts directory (with optional subPath)
|
|
253
|
-
return config.subPath
|
|
254
|
-
? path.join(localPath, config.subPath)
|
|
255
|
-
: localPath;
|
|
253
|
+
return config.subPath ? path.join(localPath, config.subPath) : localPath;
|
|
256
254
|
}
|
|
257
255
|
/**
|
|
258
256
|
* Load user prompts from the configured git repository
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/evaluation/datasets/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;QACtC,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QAC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AwDtB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,GACZ,kBAAkB,EAAE,CAEtB"}
|
|
@@ -58,13 +58,16 @@ function loadEvalDataset(datasetName, filter) {
|
|
|
58
58
|
throw new Error(`Dataset not found: ${datasetPath}`);
|
|
59
59
|
}
|
|
60
60
|
const fileContent = fs.readFileSync(datasetPath, 'utf8');
|
|
61
|
-
const lines = fileContent
|
|
61
|
+
const lines = fileContent
|
|
62
|
+
.trim()
|
|
63
|
+
.split('\n')
|
|
64
|
+
.filter(line => line.trim());
|
|
62
65
|
const samples = lines.map((line, index) => {
|
|
63
66
|
try {
|
|
64
67
|
return JSON.parse(line);
|
|
65
68
|
}
|
|
66
69
|
catch (error) {
|
|
67
|
-
throw new Error(`Invalid JSON at line ${index + 1} in ${datasetName}.jsonl: ${error}
|
|
70
|
+
throw new Error(`Invalid JSON at line ${index + 1} in ${datasetName}.jsonl: ${error}`, { cause: error });
|
|
68
71
|
}
|
|
69
72
|
});
|
|
70
73
|
// Apply filters if provided
|
|
@@ -73,7 +76,8 @@ function loadEvalDataset(datasetName, filter) {
|
|
|
73
76
|
if (filter.category && sample.metadata.category !== filter.category) {
|
|
74
77
|
return false;
|
|
75
78
|
}
|
|
76
|
-
if (filter.complexity &&
|
|
79
|
+
if (filter.complexity &&
|
|
80
|
+
sample.metadata.complexity !== filter.complexity) {
|
|
77
81
|
return false;
|
|
78
82
|
}
|
|
79
83
|
if (filter.phase && sample.metadata.phase !== filter.phase) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embedding Migration Handler
|
|
3
|
+
*
|
|
4
|
+
* Handles POST /api/v1/embeddings/migrate requests.
|
|
5
|
+
* Re-embeds all data in vector collections when switching embedding providers
|
|
6
|
+
* (e.g., OpenAI 1536-dim → local TEI 384-dim).
|
|
7
|
+
*
|
|
8
|
+
* PRD #384: Optional Local Embedding Service
|
|
9
|
+
*/
|
|
10
|
+
import { Logger } from '../core/error-handling';
|
|
11
|
+
import { RestApiResponse } from './rest-api';
|
|
12
|
+
/**
|
|
13
|
+
* Handle embedding migration request
|
|
14
|
+
*/
|
|
15
|
+
export declare function handleEmbeddingMigration(body: unknown, logger: Logger, requestId: string): Promise<RestApiResponse>;
|
|
16
|
+
//# sourceMappingURL=embedding-migration-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedding-migration-handler.d.ts","sourceRoot":"","sources":["../../src/interfaces/embedding-migration-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA+N7C;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,eAAe,CAAC,CA8I1B"}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Embedding Migration Handler
|
|
4
|
+
*
|
|
5
|
+
* Handles POST /api/v1/embeddings/migrate requests.
|
|
6
|
+
* Re-embeds all data in vector collections when switching embedding providers
|
|
7
|
+
* (e.g., OpenAI 1536-dim → local TEI 384-dim).
|
|
8
|
+
*
|
|
9
|
+
* PRD #384: Optional Local Embedding Service
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.handleEmbeddingMigration = handleEmbeddingMigration;
|
|
13
|
+
const embedding_service_1 = require("../core/embedding-service");
|
|
14
|
+
const plugin_registry_1 = require("../core/plugin-registry");
|
|
15
|
+
const PLUGIN_NAME = 'agentic-tools';
|
|
16
|
+
const BATCH_SIZE = 50;
|
|
17
|
+
/**
|
|
18
|
+
* Invoke a plugin tool and extract the result data
|
|
19
|
+
*/
|
|
20
|
+
async function invokePlugin(tool, args) {
|
|
21
|
+
const response = await (0, plugin_registry_1.invokePluginTool)(PLUGIN_NAME, tool, args);
|
|
22
|
+
if (!response.success) {
|
|
23
|
+
const error = response.error;
|
|
24
|
+
const message = typeof error === 'object' && error?.message
|
|
25
|
+
? error.message
|
|
26
|
+
: String(error || `Plugin tool ${tool} failed`);
|
|
27
|
+
throw new Error(message);
|
|
28
|
+
}
|
|
29
|
+
const toolResult = response.result;
|
|
30
|
+
if (!toolResult || typeof toolResult !== 'object') {
|
|
31
|
+
throw new Error(`Plugin tool ${tool} returned invalid result`);
|
|
32
|
+
}
|
|
33
|
+
if (toolResult.success === false) {
|
|
34
|
+
throw new Error(toolResult.error || toolResult.message || `Plugin tool ${tool} failed`);
|
|
35
|
+
}
|
|
36
|
+
return toolResult.data;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Migrate a single collection: read all points, re-embed, recreate collection, store
|
|
40
|
+
*/
|
|
41
|
+
async function migrateCollection(collectionName, embeddingService, targetDimensions, logger, requestId) {
|
|
42
|
+
// Get current collection stats
|
|
43
|
+
const stats = await invokePlugin('collection_stats', {
|
|
44
|
+
collection: collectionName,
|
|
45
|
+
});
|
|
46
|
+
if (!stats.exists) {
|
|
47
|
+
return {
|
|
48
|
+
collection: collectionName,
|
|
49
|
+
status: 'failed',
|
|
50
|
+
previousDimensions: 0,
|
|
51
|
+
newDimensions: targetDimensions,
|
|
52
|
+
total: 0,
|
|
53
|
+
processed: 0,
|
|
54
|
+
failed: 0,
|
|
55
|
+
error: `Collection '${collectionName}' does not exist`,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const previousDimensions = stats.vectorSize;
|
|
59
|
+
// Skip if dimensions already match
|
|
60
|
+
if (previousDimensions === targetDimensions) {
|
|
61
|
+
return {
|
|
62
|
+
collection: collectionName,
|
|
63
|
+
status: 'skipped',
|
|
64
|
+
previousDimensions,
|
|
65
|
+
newDimensions: targetDimensions,
|
|
66
|
+
total: stats.pointsCount,
|
|
67
|
+
processed: 0,
|
|
68
|
+
failed: 0,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
logger.info('Starting collection migration', {
|
|
72
|
+
requestId,
|
|
73
|
+
collection: collectionName,
|
|
74
|
+
previousDimensions,
|
|
75
|
+
targetDimensions,
|
|
76
|
+
pointsCount: stats.pointsCount,
|
|
77
|
+
});
|
|
78
|
+
// List all points (payload only, no vectors)
|
|
79
|
+
const documents = await invokePlugin('vector_list', {
|
|
80
|
+
collection: collectionName,
|
|
81
|
+
limit: 10000,
|
|
82
|
+
});
|
|
83
|
+
const total = documents.length;
|
|
84
|
+
// Extract searchText from each document
|
|
85
|
+
const pointsWithText = documents.map(doc => ({
|
|
86
|
+
id: doc.id,
|
|
87
|
+
payload: doc.payload,
|
|
88
|
+
searchText: doc.payload.searchText || '',
|
|
89
|
+
}));
|
|
90
|
+
// Filter out points without searchText
|
|
91
|
+
const migrateablePoints = pointsWithText.filter(p => p.searchText.length > 0);
|
|
92
|
+
const skippedNoText = total - migrateablePoints.length;
|
|
93
|
+
if (skippedNoText > 0) {
|
|
94
|
+
logger.warn('Some points have no searchText and will be skipped', {
|
|
95
|
+
requestId,
|
|
96
|
+
collection: collectionName,
|
|
97
|
+
skippedNoText,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
// Batch re-embed all texts
|
|
101
|
+
const allTexts = migrateablePoints.map(p => p.searchText);
|
|
102
|
+
const allEmbeddings = [];
|
|
103
|
+
let failedEmbeddings = 0;
|
|
104
|
+
for (let i = 0; i < allTexts.length; i += BATCH_SIZE) {
|
|
105
|
+
const batch = allTexts.slice(i, i + BATCH_SIZE);
|
|
106
|
+
try {
|
|
107
|
+
const embeddings = await embeddingService.generateEmbeddings(batch);
|
|
108
|
+
allEmbeddings.push(...embeddings);
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
logger.error('Batch embedding failed', error instanceof Error ? error : new Error(String(error)), {
|
|
112
|
+
requestId,
|
|
113
|
+
collection: collectionName,
|
|
114
|
+
batchStart: i,
|
|
115
|
+
batchSize: batch.length,
|
|
116
|
+
});
|
|
117
|
+
// Fill with empty arrays to track failures
|
|
118
|
+
for (let j = 0; j < batch.length; j++) {
|
|
119
|
+
allEmbeddings.push([]);
|
|
120
|
+
}
|
|
121
|
+
failedEmbeddings += batch.length;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Recreate collection with new dimensions (initializeCollection auto-deletes on mismatch)
|
|
125
|
+
await invokePlugin('collection_initialize', {
|
|
126
|
+
collection: collectionName,
|
|
127
|
+
vectorSize: targetDimensions,
|
|
128
|
+
createTextIndex: true,
|
|
129
|
+
});
|
|
130
|
+
// Store all re-embedded points
|
|
131
|
+
let processed = 0;
|
|
132
|
+
let failed = failedEmbeddings + skippedNoText;
|
|
133
|
+
for (let i = 0; i < migrateablePoints.length; i++) {
|
|
134
|
+
const point = migrateablePoints[i];
|
|
135
|
+
const embedding = allEmbeddings[i];
|
|
136
|
+
// Skip points where embedding failed
|
|
137
|
+
if (!embedding || embedding.length === 0) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
try {
|
|
141
|
+
await invokePlugin('vector_store', {
|
|
142
|
+
collection: collectionName,
|
|
143
|
+
id: point.id,
|
|
144
|
+
embedding,
|
|
145
|
+
payload: point.payload,
|
|
146
|
+
});
|
|
147
|
+
processed++;
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
logger.error('Failed to store re-embedded point', error instanceof Error ? error : new Error(String(error)), {
|
|
151
|
+
requestId,
|
|
152
|
+
collection: collectionName,
|
|
153
|
+
pointId: point.id,
|
|
154
|
+
});
|
|
155
|
+
failed++;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
logger.info('Collection migration complete', {
|
|
159
|
+
requestId,
|
|
160
|
+
collection: collectionName,
|
|
161
|
+
total,
|
|
162
|
+
processed,
|
|
163
|
+
failed,
|
|
164
|
+
});
|
|
165
|
+
return {
|
|
166
|
+
collection: collectionName,
|
|
167
|
+
status: 'migrated',
|
|
168
|
+
previousDimensions,
|
|
169
|
+
newDimensions: targetDimensions,
|
|
170
|
+
total,
|
|
171
|
+
processed,
|
|
172
|
+
failed,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Handle embedding migration request
|
|
177
|
+
*/
|
|
178
|
+
async function handleEmbeddingMigration(body, logger, requestId) {
|
|
179
|
+
// Check plugin availability
|
|
180
|
+
if (!(0, plugin_registry_1.isPluginInitialized)()) {
|
|
181
|
+
return {
|
|
182
|
+
success: false,
|
|
183
|
+
error: {
|
|
184
|
+
code: 'PLUGIN_UNAVAILABLE',
|
|
185
|
+
message: 'Plugin system is not initialized. Vector database operations are unavailable.',
|
|
186
|
+
},
|
|
187
|
+
meta: {
|
|
188
|
+
timestamp: new Date().toISOString(),
|
|
189
|
+
requestId,
|
|
190
|
+
version: 'v1',
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
// Check embedding service availability
|
|
195
|
+
const embeddingService = new embedding_service_1.EmbeddingService();
|
|
196
|
+
if (!embeddingService.isAvailable()) {
|
|
197
|
+
const status = embeddingService.getStatus();
|
|
198
|
+
return {
|
|
199
|
+
success: false,
|
|
200
|
+
error: {
|
|
201
|
+
code: 'EMBEDDING_SERVICE_UNAVAILABLE',
|
|
202
|
+
message: `Embedding service is not available: ${status.reason || 'No embedding provider configured'}`,
|
|
203
|
+
},
|
|
204
|
+
meta: {
|
|
205
|
+
timestamp: new Date().toISOString(),
|
|
206
|
+
requestId,
|
|
207
|
+
version: 'v1',
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
const targetDimensions = embeddingService.getDimensions();
|
|
212
|
+
// Parse request body
|
|
213
|
+
const parsedBody = body && typeof body === 'object' ? body : {};
|
|
214
|
+
const requestedCollection = typeof parsedBody.collection === 'string'
|
|
215
|
+
? parsedBody.collection
|
|
216
|
+
: undefined;
|
|
217
|
+
// Discover collections
|
|
218
|
+
let collectionsToMigrate;
|
|
219
|
+
if (requestedCollection) {
|
|
220
|
+
collectionsToMigrate = [requestedCollection];
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
try {
|
|
224
|
+
collectionsToMigrate = await invokePlugin('collection_list', {});
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
228
|
+
return {
|
|
229
|
+
success: false,
|
|
230
|
+
error: {
|
|
231
|
+
code: 'MIGRATION_ERROR',
|
|
232
|
+
message: `Failed to list collections: ${message}`,
|
|
233
|
+
},
|
|
234
|
+
meta: {
|
|
235
|
+
timestamp: new Date().toISOString(),
|
|
236
|
+
requestId,
|
|
237
|
+
version: 'v1',
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
logger.info('Starting embedding migration', {
|
|
243
|
+
requestId,
|
|
244
|
+
targetDimensions,
|
|
245
|
+
collections: collectionsToMigrate,
|
|
246
|
+
requestedCollection: requestedCollection || 'all',
|
|
247
|
+
});
|
|
248
|
+
// Migrate each collection
|
|
249
|
+
const results = [];
|
|
250
|
+
for (const collectionName of collectionsToMigrate) {
|
|
251
|
+
try {
|
|
252
|
+
const result = await migrateCollection(collectionName, embeddingService, targetDimensions, logger, requestId);
|
|
253
|
+
results.push(result);
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
257
|
+
logger.error('Collection migration failed', error instanceof Error ? error : new Error(message), {
|
|
258
|
+
requestId,
|
|
259
|
+
collection: collectionName,
|
|
260
|
+
});
|
|
261
|
+
results.push({
|
|
262
|
+
collection: collectionName,
|
|
263
|
+
status: 'failed',
|
|
264
|
+
previousDimensions: 0,
|
|
265
|
+
newDimensions: targetDimensions,
|
|
266
|
+
total: 0,
|
|
267
|
+
processed: 0,
|
|
268
|
+
failed: 0,
|
|
269
|
+
error: message,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
// Build summary
|
|
274
|
+
const summary = {
|
|
275
|
+
totalCollections: results.length,
|
|
276
|
+
migrated: results.filter(r => r.status === 'migrated').length,
|
|
277
|
+
skipped: results.filter(r => r.status === 'skipped').length,
|
|
278
|
+
failed: results.filter(r => r.status === 'failed').length,
|
|
279
|
+
};
|
|
280
|
+
logger.info('Embedding migration complete', {
|
|
281
|
+
requestId,
|
|
282
|
+
summary,
|
|
283
|
+
});
|
|
284
|
+
return {
|
|
285
|
+
success: true,
|
|
286
|
+
data: {
|
|
287
|
+
collections: results,
|
|
288
|
+
summary,
|
|
289
|
+
},
|
|
290
|
+
meta: {
|
|
291
|
+
timestamp: new Date().toISOString(),
|
|
292
|
+
requestId,
|
|
293
|
+
version: 'v1',
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
}
|
|
@@ -220,6 +220,10 @@ export declare class RestApiRouter {
|
|
|
220
220
|
* Handle prompt get requests
|
|
221
221
|
*/
|
|
222
222
|
private handlePromptsGetRequest;
|
|
223
|
+
/**
|
|
224
|
+
* Handle prompts cache refresh requests (PRD #386)
|
|
225
|
+
*/
|
|
226
|
+
private handlePromptsCacheRefresh;
|
|
223
227
|
/**
|
|
224
228
|
* Handle visualization requests (PRD #317)
|
|
225
229
|
* Returns structured visualization data for a query session
|
|
@@ -244,6 +248,10 @@ export declare class RestApiRouter {
|
|
|
244
248
|
* Uses an agentic approach with toolLoop to allow multiple searches if needed.
|
|
245
249
|
*/
|
|
246
250
|
private handleKnowledgeAsk;
|
|
251
|
+
/**
|
|
252
|
+
* Handle embedding migration request (PRD #384)
|
|
253
|
+
*/
|
|
254
|
+
private handleEmbeddingMigrationRequest;
|
|
247
255
|
/**
|
|
248
256
|
* Set CORS headers
|
|
249
257
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest-api.d.ts","sourceRoot":"","sources":["../../src/interfaces/rest-api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAc,MAAM,uBAAuB,CAAC;AAEtE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"rest-api.d.ts","sourceRoot":"","sources":["../../src/interfaces/rest-api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAc,MAAM,uBAAuB,CAAC;AAEtE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAoCtC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAQvD;;GAEG;AACH,oBAAY,UAAU;IACpB,EAAE,MAAM;IACR,WAAW,MAAM;IACjB,SAAS,MAAM;IACf,kBAAkB,MAAM;IACxB,qBAAqB,MAAM;IAC3B,WAAW,MAAM;IACjB,mBAAmB,MAAM;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;IACF,IAAI,CAAC,EAAE;QACL,SAAS,EAAE,MAAM,CAAC;Q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