@vfarcic/dot-ai 1.0.3 → 1.2.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/README.md +1 -0
- package/dist/core/ai-provider.interface.d.ts +12 -8
- package/dist/core/ai-provider.interface.d.ts.map +1 -1
- package/dist/core/artifacthub.d.ts +1 -1
- package/dist/core/artifacthub.d.ts.map +1 -1
- package/dist/core/base-vector-service.d.ts +22 -9
- package/dist/core/base-vector-service.d.ts.map +1 -1
- package/dist/core/base-vector-service.js +106 -37
- package/dist/core/capabilities.d.ts.map +1 -1
- package/dist/core/capabilities.js +5 -2
- package/dist/core/capability-operations.d.ts +55 -7
- package/dist/core/capability-operations.d.ts.map +1 -1
- package/dist/core/capability-operations.js +1 -3
- package/dist/core/capability-scan-workflow.d.ts +64 -8
- package/dist/core/capability-scan-workflow.d.ts.map +1 -1
- package/dist/core/capability-scan-workflow.js +14 -13
- package/dist/core/capability-tools.d.ts +1 -1
- package/dist/core/capability-tools.d.ts.map +1 -1
- package/dist/core/capability-tools.js +1 -1
- package/dist/core/capability-vector-service.d.ts +3 -4
- package/dist/core/capability-vector-service.d.ts.map +1 -1
- package/dist/core/capability-vector-service.js +2 -2
- package/dist/core/command-executor.d.ts +3 -4
- package/dist/core/command-executor.d.ts.map +1 -1
- package/dist/core/command-executor.js +8 -4
- package/dist/core/crd-availability.d.ts +3 -5
- package/dist/core/crd-availability.d.ts.map +1 -1
- package/dist/core/crd-availability.js +8 -18
- package/dist/core/deploy-operation.d.ts +6 -5
- package/dist/core/deploy-operation.d.ts.map +1 -1
- package/dist/core/deploy-operation.js +16 -10
- package/dist/core/discovery.d.ts +6 -14
- package/dist/core/discovery.d.ts.map +1 -1
- package/dist/core/discovery.js +35 -51
- package/dist/core/embedding-service.d.ts.map +1 -1
- package/dist/core/embedding-service.js +1 -1
- package/dist/core/error-handling.d.ts +13 -13
- package/dist/core/error-handling.d.ts.map +1 -1
- package/dist/core/error-handling.js +2 -3
- package/dist/core/generic-session-manager.d.ts +2 -2
- package/dist/core/generic-session-manager.d.ts.map +1 -1
- package/dist/core/helm-types.d.ts +5 -5
- package/dist/core/helm-types.d.ts.map +1 -1
- package/dist/core/index.d.ts +4 -11
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +8 -14
- package/dist/core/knowledge-types.d.ts +114 -0
- package/dist/core/knowledge-types.d.ts.map +1 -0
- package/dist/core/knowledge-types.js +10 -0
- package/dist/core/memory.d.ts +12 -12
- package/dist/core/memory.d.ts.map +1 -1
- package/dist/core/mermaid-tools.d.ts +24 -1
- package/dist/core/mermaid-tools.d.ts.map +1 -1
- package/dist/core/mermaid-tools.js +10 -8
- package/dist/core/model-config.d.ts +1 -1
- package/dist/core/model-config.js +1 -1
- package/dist/core/packaging.d.ts +23 -1
- package/dist/core/packaging.d.ts.map +1 -1
- package/dist/core/pattern-operations.d.ts +32 -9
- package/dist/core/pattern-operations.d.ts.map +1 -1
- package/dist/core/pattern-operations.js +17 -22
- package/dist/core/pattern-vector-service.d.ts +3 -4
- package/dist/core/pattern-vector-service.d.ts.map +1 -1
- package/dist/core/pattern-vector-service.js +2 -2
- package/dist/core/platform-utils.d.ts +2 -2
- package/dist/core/platform-utils.d.ts.map +1 -1
- package/dist/core/plugin-manager.d.ts +6 -2
- package/dist/core/plugin-manager.d.ts.map +1 -1
- package/dist/core/plugin-manager.js +9 -16
- package/dist/core/plugin-registry.d.ts +59 -0
- package/dist/core/plugin-registry.d.ts.map +1 -0
- package/dist/core/plugin-registry.js +80 -0
- package/dist/core/policy-operations.d.ts +101 -21
- package/dist/core/policy-operations.d.ts.map +1 -1
- package/dist/core/policy-operations.js +45 -47
- package/dist/core/policy-vector-service.d.ts +3 -4
- package/dist/core/policy-vector-service.d.ts.map +1 -1
- package/dist/core/policy-vector-service.js +2 -2
- package/dist/core/providers/host-provider.d.ts +1 -1
- package/dist/core/providers/host-provider.d.ts.map +1 -1
- package/dist/core/providers/host-provider.js +2 -2
- package/dist/core/providers/provider-debug-utils.d.ts +2 -2
- package/dist/core/providers/provider-debug-utils.d.ts.map +1 -1
- package/dist/core/providers/tool-utils.d.ts +10 -2
- package/dist/core/providers/tool-utils.d.ts.map +1 -1
- package/dist/core/providers/tool-utils.js +2 -2
- package/dist/core/providers/vercel-provider.d.ts.map +1 -1
- package/dist/core/providers/vercel-provider.js +29 -23
- package/dist/core/resource-tools.d.ts +29 -1
- package/dist/core/resource-tools.d.ts.map +1 -1
- package/dist/core/resource-vector-service.d.ts +3 -4
- package/dist/core/resource-vector-service.d.ts.map +1 -1
- package/dist/core/resource-vector-service.js +2 -2
- package/dist/core/schema.d.ts +15 -14
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/schema.js +32 -34
- package/dist/core/shared-prompt-loader.d.ts +1 -1
- package/dist/core/shared-prompt-loader.d.ts.map +1 -1
- package/dist/core/solution-cr.js +1 -1
- package/dist/core/solution-utils.d.ts +22 -3
- package/dist/core/solution-utils.d.ts.map +1 -1
- package/dist/core/solution-utils.js +1 -1
- package/dist/core/telemetry/client.d.ts +0 -6
- package/dist/core/telemetry/client.d.ts.map +1 -1
- package/dist/core/telemetry/client.js +6 -17
- package/dist/core/telemetry/config.js +1 -1
- package/dist/core/telemetry/index.d.ts +1 -1
- package/dist/core/telemetry/index.d.ts.map +1 -1
- package/dist/core/telemetry/index.js +1 -2
- package/dist/core/tracing/tool-tracing.d.ts +1 -1
- package/dist/core/tracing/tool-tracing.d.ts.map +1 -1
- package/dist/core/unified-creation-session.d.ts +15 -8
- package/dist/core/unified-creation-session.d.ts.map +1 -1
- package/dist/core/unified-creation-session.js +19 -19
- package/dist/core/unified-creation-types.d.ts +2 -2
- package/dist/core/unified-creation-types.d.ts.map +1 -1
- package/dist/core/visualization.d.ts +1 -1
- package/dist/core/visualization.d.ts.map +1 -1
- package/dist/core/workflow.d.ts +8 -5
- package/dist/core/workflow.d.ts.map +1 -1
- package/dist/evaluation/dataset-analyzer.d.ts +13 -7
- package/dist/evaluation/dataset-analyzer.d.ts.map +1 -1
- package/dist/evaluation/dataset-analyzer.js +1 -1
- package/dist/evaluation/datasets/loader.d.ts +2 -2
- package/dist/evaluation/datasets/loader.d.ts.map +1 -1
- package/dist/evaluation/eval-runner.js +7 -5
- package/dist/evaluation/evaluators/base-comparative.d.ts +1 -1
- package/dist/evaluation/evaluators/base-comparative.d.ts.map +1 -1
- package/dist/evaluation/evaluators/base-comparative.js +4 -3
- package/dist/evaluation/evaluators/base.d.ts +5 -5
- package/dist/evaluation/evaluators/base.d.ts.map +1 -1
- package/dist/evaluation/evaluators/capability-comparative.js +1 -1
- package/dist/evaluation/platform-synthesizer.d.ts.map +1 -1
- package/dist/interfaces/mcp.d.ts.map +1 -1
- package/dist/interfaces/mcp.js +26 -15
- package/dist/interfaces/openapi-generator.d.ts +116 -12
- package/dist/interfaces/openapi-generator.d.ts.map +1 -1
- package/dist/interfaces/openapi-generator.js +500 -207
- package/dist/interfaces/rest-api.d.ts +28 -6
- package/dist/interfaces/rest-api.d.ts.map +1 -1
- package/dist/interfaces/rest-api.js +436 -245
- package/dist/interfaces/rest-registry.d.ts +5 -5
- package/dist/interfaces/rest-registry.d.ts.map +1 -1
- package/dist/interfaces/rest-registry.js +12 -27
- package/dist/interfaces/rest-route-registry.d.ts +165 -0
- package/dist/interfaces/rest-route-registry.d.ts.map +1 -0
- package/dist/interfaces/rest-route-registry.js +230 -0
- package/dist/interfaces/routes/index.d.ts +22 -0
- package/dist/interfaces/routes/index.d.ts.map +1 -0
- package/dist/interfaces/routes/index.js +347 -0
- package/dist/interfaces/schemas/common.d.ts +170 -0
- package/dist/interfaces/schemas/common.d.ts.map +1 -0
- package/dist/interfaces/schemas/common.js +114 -0
- package/dist/interfaces/schemas/events.d.ts +127 -0
- package/dist/interfaces/schemas/events.d.ts.map +1 -0
- package/dist/interfaces/schemas/events.js +66 -0
- package/dist/interfaces/schemas/index.d.ts +21 -0
- package/dist/interfaces/schemas/index.d.ts.map +1 -0
- package/dist/interfaces/schemas/index.js +138 -0
- package/dist/interfaces/schemas/knowledge.d.ts +201 -0
- package/dist/interfaces/schemas/knowledge.d.ts.map +1 -0
- package/dist/interfaces/schemas/knowledge.js +117 -0
- package/dist/interfaces/schemas/logs.d.ts +78 -0
- package/dist/interfaces/schemas/logs.d.ts.map +1 -0
- package/dist/interfaces/schemas/logs.js +46 -0
- package/dist/interfaces/schemas/prompts.d.ts +185 -0
- package/dist/interfaces/schemas/prompts.d.ts.map +1 -0
- package/dist/interfaces/schemas/prompts.js +91 -0
- package/dist/interfaces/schemas/resources.d.ts +363 -0
- package/dist/interfaces/schemas/resources.d.ts.map +1 -0
- package/dist/interfaces/schemas/resources.js +173 -0
- package/dist/interfaces/schemas/sessions.d.ts +87 -0
- package/dist/interfaces/schemas/sessions.d.ts.map +1 -0
- package/dist/interfaces/schemas/sessions.js +56 -0
- package/dist/interfaces/schemas/tools.d.ts +188 -0
- package/dist/interfaces/schemas/tools.d.ts.map +1 -0
- package/dist/interfaces/schemas/tools.js +101 -0
- package/dist/interfaces/schemas/visualization.d.ts +369 -0
- package/dist/interfaces/schemas/visualization.d.ts.map +1 -0
- package/dist/interfaces/schemas/visualization.js +134 -0
- package/dist/mcp/server.js +5 -4
- package/dist/tools/answer-question.d.ts +1 -1
- package/dist/tools/answer-question.d.ts.map +1 -1
- package/dist/tools/answer-question.js +9 -8
- package/dist/tools/deploy-manifests.d.ts +4 -2
- package/dist/tools/deploy-manifests.d.ts.map +1 -1
- package/dist/tools/deploy-manifests.js +10 -6
- package/dist/tools/generate-manifests.d.ts.map +1 -1
- package/dist/tools/generate-manifests.js +28 -20
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +6 -1
- package/dist/tools/manage-knowledge.d.ts +77 -0
- package/dist/tools/manage-knowledge.d.ts.map +1 -0
- package/dist/tools/manage-knowledge.js +573 -0
- package/dist/tools/operate-analysis.d.ts +31 -2
- package/dist/tools/operate-analysis.d.ts.map +1 -1
- package/dist/tools/operate-execution.d.ts +2 -3
- package/dist/tools/operate-execution.d.ts.map +1 -1
- package/dist/tools/operate-execution.js +7 -7
- package/dist/tools/operate.d.ts +7 -2
- package/dist/tools/operate.d.ts.map +1 -1
- package/dist/tools/operate.js +2 -2
- package/dist/tools/organizational-data.d.ts +30 -4
- package/dist/tools/organizational-data.d.ts.map +1 -1
- package/dist/tools/organizational-data.js +24 -19
- package/dist/tools/project-setup/discovery.d.ts.map +1 -1
- package/dist/tools/project-setup/generate-scope.d.ts +1 -1
- package/dist/tools/project-setup/generate-scope.d.ts.map +1 -1
- package/dist/tools/project-setup/types.d.ts +1 -0
- package/dist/tools/project-setup/types.d.ts.map +1 -1
- package/dist/tools/prompts.d.ts +29 -3
- package/dist/tools/prompts.d.ts.map +1 -1
- package/dist/tools/prompts.js +6 -3
- package/dist/tools/query.d.ts +17 -3
- package/dist/tools/query.d.ts.map +1 -1
- package/dist/tools/query.js +1 -7
- package/dist/tools/recommend.d.ts +24 -6
- package/dist/tools/recommend.d.ts.map +1 -1
- package/dist/tools/recommend.js +18 -15
- package/dist/tools/remediate.d.ts +12 -3
- package/dist/tools/remediate.d.ts.map +1 -1
- package/dist/tools/remediate.js +22 -14
- package/dist/tools/version.d.ts +19 -5
- package/dist/tools/version.d.ts.map +1 -1
- package/dist/tools/version.js +106 -54
- package/package.json +15 -9
- package/prompts/knowledge-ask.md +29 -0
- package/scripts/generate-openapi.sh +56 -0
- package/scripts/grafana-stack.nu +118 -0
- package/shared-prompts/prd-create.md +2 -0
- package/dist/core/vector-db-service.d.ts +0 -108
- package/dist/core/vector-db-service.d.ts.map +0 -1
- package/dist/core/vector-db-service.js +0 -647
|
@@ -16,12 +16,10 @@ exports.handlePolicyDeleteAll = handlePolicyDeleteAll;
|
|
|
16
16
|
exports.handlePolicyOperation = handlePolicyOperation;
|
|
17
17
|
const error_handling_1 = require("./error-handling");
|
|
18
18
|
const policy_vector_service_1 = require("./policy-vector-service");
|
|
19
|
-
const vector_db_service_1 = require("./vector-db-service");
|
|
20
19
|
const unified_creation_session_1 = require("./unified-creation-session");
|
|
20
|
+
const plugin_registry_1 = require("./plugin-registry");
|
|
21
21
|
const validation_1 = require("./constants/validation");
|
|
22
22
|
const constants_1 = require("./constants");
|
|
23
|
-
// Note: validateVectorDBConnection and validateEmbeddingService are shared utilities
|
|
24
|
-
// that remain in the main organizational-data.ts file as they're used by multiple domains
|
|
25
23
|
/**
|
|
26
24
|
* Get initialized policy service
|
|
27
25
|
*/
|
|
@@ -41,9 +39,10 @@ async function getPolicyService() {
|
|
|
41
39
|
/**
|
|
42
40
|
* Execute kubectl command via plugin
|
|
43
41
|
* PRD #343: All kubectl operations go through plugin
|
|
42
|
+
* PRD #359: Uses unified plugin registry
|
|
44
43
|
*/
|
|
45
|
-
async function executeKubectlViaPlugin(
|
|
46
|
-
const response = await
|
|
44
|
+
async function executeKubectlViaPlugin(args) {
|
|
45
|
+
const response = await (0, plugin_registry_1.invokePluginTool)('agentic-tools', 'kubectl_exec_command', { args });
|
|
47
46
|
if (response.success) {
|
|
48
47
|
if (typeof response.result === 'object' && response.result !== null) {
|
|
49
48
|
const result = response.result;
|
|
@@ -68,15 +67,15 @@ async function executeKubectlViaPlugin(pluginManager, args) {
|
|
|
68
67
|
}
|
|
69
68
|
/**
|
|
70
69
|
* Find Kyverno policies by policy intent ID using label selector
|
|
71
|
-
* PRD #
|
|
70
|
+
* PRD #359: Uses unified plugin registry
|
|
72
71
|
*/
|
|
73
|
-
async function findKyvernoPoliciesByPolicyId(policyId, logger, requestId
|
|
72
|
+
async function findKyvernoPoliciesByPolicyId(policyId, logger, requestId) {
|
|
74
73
|
try {
|
|
75
74
|
logger.info('Searching for Kyverno policies by policy ID', {
|
|
76
75
|
requestId,
|
|
77
76
|
policyId
|
|
78
77
|
});
|
|
79
|
-
const output = await executeKubectlViaPlugin(
|
|
78
|
+
const output = await executeKubectlViaPlugin(['get', 'clusterpolicy', '-l', `policy-intent/id=${policyId}`, '-o', 'json']);
|
|
80
79
|
const parsedOutput = JSON.parse(output || '{"items": []}');
|
|
81
80
|
const policies = parsedOutput.items || [];
|
|
82
81
|
logger.info('Found Kyverno policies for policy intent', {
|
|
@@ -86,7 +85,7 @@ async function findKyvernoPoliciesByPolicyId(policyId, logger, requestId, plugin
|
|
|
86
85
|
policyNames: policies.map((p) => p.metadata?.name)
|
|
87
86
|
});
|
|
88
87
|
return policies.map((p) => ({
|
|
89
|
-
name: p.metadata?.name,
|
|
88
|
+
name: p.metadata?.name || '',
|
|
90
89
|
labels: p.metadata?.labels,
|
|
91
90
|
creationTimestamp: p.metadata?.creationTimestamp
|
|
92
91
|
}));
|
|
@@ -102,14 +101,14 @@ async function findKyvernoPoliciesByPolicyId(policyId, logger, requestId, plugin
|
|
|
102
101
|
}
|
|
103
102
|
/**
|
|
104
103
|
* Find all Kyverno policies that have policy-intent/id labels
|
|
105
|
-
* PRD #
|
|
104
|
+
* PRD #359: Uses unified plugin registry
|
|
106
105
|
*/
|
|
107
|
-
async function findAllKyvernoPoliciesForPolicyIntents(logger, requestId
|
|
106
|
+
async function findAllKyvernoPoliciesForPolicyIntents(logger, requestId) {
|
|
108
107
|
try {
|
|
109
108
|
logger.info('Searching for all Kyverno policies with policy-intent labels', {
|
|
110
109
|
requestId
|
|
111
110
|
});
|
|
112
|
-
const output = await executeKubectlViaPlugin(
|
|
111
|
+
const output = await executeKubectlViaPlugin(['get', 'clusterpolicy', '-l', 'policy-intent/id', '-o', 'json']);
|
|
113
112
|
const parsedOutput = JSON.parse(output || '{"items": []}');
|
|
114
113
|
const policies = parsedOutput.items || [];
|
|
115
114
|
logger.info('Found all Kyverno policies for policy intents', {
|
|
@@ -118,7 +117,7 @@ async function findAllKyvernoPoliciesForPolicyIntents(logger, requestId, pluginM
|
|
|
118
117
|
policyNames: policies.map((p) => p.metadata?.name)
|
|
119
118
|
});
|
|
120
119
|
return policies.map((p) => ({
|
|
121
|
-
name: p.metadata?.name,
|
|
120
|
+
name: p.metadata?.name || '',
|
|
122
121
|
policyId: p.metadata?.labels?.['policy-intent/id'],
|
|
123
122
|
labels: p.metadata?.labels,
|
|
124
123
|
creationTimestamp: p.metadata?.creationTimestamp
|
|
@@ -134,15 +133,15 @@ async function findAllKyvernoPoliciesForPolicyIntents(logger, requestId, pluginM
|
|
|
134
133
|
}
|
|
135
134
|
/**
|
|
136
135
|
* Delete Kyverno policies by policy intent ID using label selector
|
|
137
|
-
* PRD #
|
|
136
|
+
* PRD #359: Uses unified plugin registry
|
|
138
137
|
*/
|
|
139
|
-
async function deleteKyvernoPoliciesByPolicyId(policyId, logger, requestId
|
|
138
|
+
async function deleteKyvernoPoliciesByPolicyId(policyId, logger, requestId) {
|
|
140
139
|
try {
|
|
141
140
|
logger.info('Deleting Kyverno policies by policy ID', {
|
|
142
141
|
requestId,
|
|
143
142
|
policyId
|
|
144
143
|
});
|
|
145
|
-
const output = await executeKubectlViaPlugin(
|
|
144
|
+
const output = await executeKubectlViaPlugin(['delete', 'clusterpolicy', '-l', `policy-intent/id=${policyId}`]);
|
|
146
145
|
logger.info('Kyverno policies deleted successfully', {
|
|
147
146
|
requestId,
|
|
148
147
|
policyId,
|
|
@@ -169,14 +168,14 @@ async function deleteKyvernoPoliciesByPolicyId(policyId, logger, requestId, plug
|
|
|
169
168
|
}
|
|
170
169
|
/**
|
|
171
170
|
* Delete all Kyverno policies that have policy-intent/id labels
|
|
172
|
-
* PRD #
|
|
171
|
+
* PRD #359: Uses unified plugin registry
|
|
173
172
|
*/
|
|
174
|
-
async function deleteAllKyvernoPoliciesForPolicyIntents(logger, requestId
|
|
173
|
+
async function deleteAllKyvernoPoliciesForPolicyIntents(logger, requestId) {
|
|
175
174
|
try {
|
|
176
175
|
logger.info('Deleting all Kyverno policies with policy-intent labels', {
|
|
177
176
|
requestId
|
|
178
177
|
});
|
|
179
|
-
const output = await executeKubectlViaPlugin(
|
|
178
|
+
const output = await executeKubectlViaPlugin(['delete', 'clusterpolicy', '-l', 'policy-intent/id']);
|
|
180
179
|
logger.info('All Kyverno policies deleted successfully', {
|
|
181
180
|
requestId,
|
|
182
181
|
output
|
|
@@ -201,9 +200,9 @@ async function deleteAllKyvernoPoliciesForPolicyIntents(logger, requestId, plugi
|
|
|
201
200
|
}
|
|
202
201
|
/**
|
|
203
202
|
* Handle individual policy delete with Kyverno cleanup
|
|
204
|
-
* PRD #
|
|
203
|
+
* PRD #359: Uses unified plugin registry
|
|
205
204
|
*/
|
|
206
|
-
async function handlePolicyDelete(policyId, policyService, args, logger, requestId
|
|
205
|
+
async function handlePolicyDelete(policyId, policyService, args, logger, requestId) {
|
|
207
206
|
try {
|
|
208
207
|
// Check if policy intent exists
|
|
209
208
|
const existingPolicyIntent = await policyService.getPolicyIntent(policyId);
|
|
@@ -217,7 +216,7 @@ async function handlePolicyDelete(policyId, policyService, args, logger, request
|
|
|
217
216
|
};
|
|
218
217
|
}
|
|
219
218
|
// Check if there are deployed Kyverno policies with this policy ID
|
|
220
|
-
const kyvernoPolicies = await findKyvernoPoliciesByPolicyId(policyId, logger, requestId
|
|
219
|
+
const kyvernoPolicies = await findKyvernoPoliciesByPolicyId(policyId, logger, requestId);
|
|
221
220
|
if (kyvernoPolicies.length > 0 && !args.response) {
|
|
222
221
|
// Show confirmation prompt for Kyverno cleanup
|
|
223
222
|
return {
|
|
@@ -240,7 +239,7 @@ async function handlePolicyDelete(policyId, policyService, args, logger, request
|
|
|
240
239
|
const response = args.response.trim();
|
|
241
240
|
if (response === '1' || response.toLowerCase().includes('delete everything')) {
|
|
242
241
|
// Delete Kyverno policies from cluster
|
|
243
|
-
kyvernoCleanupResults = await deleteKyvernoPoliciesByPolicyId(policyId, logger, requestId
|
|
242
|
+
kyvernoCleanupResults = await deleteKyvernoPoliciesByPolicyId(policyId, logger, requestId);
|
|
244
243
|
}
|
|
245
244
|
}
|
|
246
245
|
// Always delete the policy intent from Vector DB
|
|
@@ -272,9 +271,9 @@ async function handlePolicyDelete(policyId, policyService, args, logger, request
|
|
|
272
271
|
}
|
|
273
272
|
/**
|
|
274
273
|
* Handle deleteAll policies with batch Kyverno cleanup
|
|
275
|
-
* PRD #
|
|
274
|
+
* PRD #359: Uses unified plugin registry
|
|
276
275
|
*/
|
|
277
|
-
async function handlePolicyDeleteAll(policyService, args, logger,
|
|
276
|
+
async function handlePolicyDeleteAll(policyService, args, logger, requestId) {
|
|
278
277
|
try {
|
|
279
278
|
// Get all policy intents
|
|
280
279
|
const allPolicyIntents = await policyService.getAllPolicyIntents();
|
|
@@ -288,7 +287,7 @@ async function handlePolicyDeleteAll(policyService, args, logger, pluginManager,
|
|
|
288
287
|
};
|
|
289
288
|
}
|
|
290
289
|
// Find all deployed Kyverno policies for all policy intents
|
|
291
|
-
const allKyvernoPolicies = await findAllKyvernoPoliciesForPolicyIntents(logger, requestId
|
|
290
|
+
const allKyvernoPolicies = await findAllKyvernoPoliciesForPolicyIntents(logger, requestId);
|
|
292
291
|
if (allKyvernoPolicies.length > 0 && !args.response) {
|
|
293
292
|
// Show confirmation prompt for batch Kyverno cleanup
|
|
294
293
|
return {
|
|
@@ -311,7 +310,7 @@ async function handlePolicyDeleteAll(policyService, args, logger, pluginManager,
|
|
|
311
310
|
const response = args.response.trim();
|
|
312
311
|
if (response === '1' || response.toLowerCase().includes('delete everything')) {
|
|
313
312
|
// Delete all Kyverno policies from cluster
|
|
314
|
-
kyvernoCleanupResults = await deleteAllKyvernoPoliciesForPolicyIntents(logger, requestId
|
|
313
|
+
kyvernoCleanupResults = await deleteAllKyvernoPoliciesForPolicyIntents(logger, requestId);
|
|
315
314
|
}
|
|
316
315
|
}
|
|
317
316
|
// Always delete all policy intents from Vector DB
|
|
@@ -347,9 +346,9 @@ async function handlePolicyDeleteAll(policyService, args, logger, pluginManager,
|
|
|
347
346
|
/**
|
|
348
347
|
* Main policy operations handler - delegates to specific operation functions
|
|
349
348
|
* Requires shared validation utilities to be passed as parameters to avoid circular imports
|
|
350
|
-
* PRD #
|
|
349
|
+
* PRD #359: Uses unified plugin registry for kubectl operations
|
|
351
350
|
*/
|
|
352
|
-
async function handlePolicyOperation(operation, args, logger, requestId, validateVectorDBConnection, validateEmbeddingService
|
|
351
|
+
async function handlePolicyOperation(operation, args, logger, requestId, validateVectorDBConnection, validateEmbeddingService) {
|
|
353
352
|
// Get policy service and validate Vector DB connection
|
|
354
353
|
const policyService = await getPolicyService();
|
|
355
354
|
const connectionCheck = await validateVectorDBConnection(policyService, logger, requestId);
|
|
@@ -376,7 +375,7 @@ async function handlePolicyOperation(operation, args, logger, requestId, validat
|
|
|
376
375
|
};
|
|
377
376
|
}
|
|
378
377
|
}
|
|
379
|
-
const sessionManager = new unified_creation_session_1.UnifiedCreationSessionManager('policy'
|
|
378
|
+
const sessionManager = new unified_creation_session_1.UnifiedCreationSessionManager('policy');
|
|
380
379
|
switch (operation) {
|
|
381
380
|
case 'create': {
|
|
382
381
|
let workflowStep;
|
|
@@ -388,12 +387,12 @@ async function handlePolicyOperation(operation, args, logger, requestId, validat
|
|
|
388
387
|
});
|
|
389
388
|
if (args.response) {
|
|
390
389
|
// Process user response and move to next step
|
|
391
|
-
const updatedSession = sessionManager.processResponse(args.sessionId, args.response
|
|
390
|
+
const updatedSession = sessionManager.processResponse(args.sessionId, args.response);
|
|
392
391
|
workflowStep = await sessionManager.getNextWorkflowStep(updatedSession, args);
|
|
393
392
|
}
|
|
394
393
|
else {
|
|
395
394
|
// Just get current step without processing response
|
|
396
|
-
const session = sessionManager.loadSession(args.sessionId
|
|
395
|
+
const session = sessionManager.loadSession(args.sessionId);
|
|
397
396
|
if (!session) {
|
|
398
397
|
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.HIGH, `Session not found: ${args.sessionId}`, {
|
|
399
398
|
operation: 'policy_workflow_continue',
|
|
@@ -429,27 +428,26 @@ async function handlePolicyOperation(operation, args, logger, requestId, validat
|
|
|
429
428
|
// Always check if workflow is complete and store policy in Vector DB
|
|
430
429
|
let storageInfo = {};
|
|
431
430
|
const isComplete = !('nextStep' in workflowStep) || !workflowStep.nextStep; // Complete when no next step
|
|
432
|
-
const
|
|
431
|
+
const workflowData = workflowStep.data;
|
|
432
|
+
const hasPolicy = !!workflowData?.policy;
|
|
433
433
|
logger.info('Checking workflow completion', {
|
|
434
434
|
requestId,
|
|
435
435
|
nextStep: ('nextStep' in workflowStep) ? workflowStep.nextStep : 'complete',
|
|
436
436
|
hasPolicy,
|
|
437
|
-
policyId:
|
|
437
|
+
policyId: workflowData?.policy?.id
|
|
438
438
|
});
|
|
439
439
|
if (isComplete && hasPolicy) {
|
|
440
440
|
try {
|
|
441
|
-
await policyService.storePolicyIntent(
|
|
442
|
-
const vectorDBConfig = new vector_db_service_1.VectorDBService({ collectionName: 'policies' }).getConfig();
|
|
441
|
+
await policyService.storePolicyIntent(workflowData.policy);
|
|
443
442
|
storageInfo = {
|
|
444
443
|
stored: true,
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
policyId: workflowStep.data.policy.id
|
|
444
|
+
collectionName: 'policies',
|
|
445
|
+
policyId: workflowData.policy.id
|
|
448
446
|
};
|
|
449
447
|
logger.info('Policy stored in Vector DB successfully', {
|
|
450
448
|
requestId,
|
|
451
|
-
policyId:
|
|
452
|
-
description:
|
|
449
|
+
policyId: workflowData.policy.id,
|
|
450
|
+
description: workflowData.policy.description.substring(0, 50) + (workflowData.policy.description.length > 50 ? '...' : '')
|
|
453
451
|
});
|
|
454
452
|
}
|
|
455
453
|
catch (error) {
|
|
@@ -457,11 +455,11 @@ async function handlePolicyOperation(operation, args, logger, requestId, validat
|
|
|
457
455
|
storageInfo = {
|
|
458
456
|
stored: false,
|
|
459
457
|
error: errorMessage,
|
|
460
|
-
policyId:
|
|
458
|
+
policyId: workflowData.policy.id
|
|
461
459
|
};
|
|
462
460
|
logger.error('Failed to store policy in Vector DB', error instanceof Error ? error : new Error(String(error)), {
|
|
463
461
|
requestId,
|
|
464
|
-
policyId:
|
|
462
|
+
policyId: workflowData.policy.id
|
|
465
463
|
});
|
|
466
464
|
}
|
|
467
465
|
}
|
|
@@ -556,16 +554,16 @@ async function handlePolicyOperation(operation, args, logger, requestId, validat
|
|
|
556
554
|
error: validation_1.VALIDATION_MESSAGES.MISSING_PARAMETER('id')
|
|
557
555
|
};
|
|
558
556
|
}
|
|
559
|
-
if (!
|
|
557
|
+
if (!(0, plugin_registry_1.isPluginInitialized)()) {
|
|
560
558
|
throw new Error('Plugin system not available. Policy delete requires agentic-tools plugin for kubectl operations.');
|
|
561
559
|
}
|
|
562
|
-
return await handlePolicyDelete(args.id, policyService, args, logger, requestId
|
|
560
|
+
return await handlePolicyDelete(args.id, policyService, args, logger, requestId);
|
|
563
561
|
}
|
|
564
562
|
case 'deleteAll': {
|
|
565
|
-
if (!
|
|
563
|
+
if (!(0, plugin_registry_1.isPluginInitialized)()) {
|
|
566
564
|
throw new Error('Plugin system not available. Policy deleteAll requires agentic-tools plugin for kubectl operations.');
|
|
567
565
|
}
|
|
568
|
-
return await handlePolicyDeleteAll(policyService, args, logger,
|
|
566
|
+
return await handlePolicyDeleteAll(policyService, args, logger, requestId);
|
|
569
567
|
}
|
|
570
568
|
default:
|
|
571
569
|
return {
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* Handles policy intent-specific Vector DB operations
|
|
5
5
|
* Extends BaseVectorService for policy intents
|
|
6
6
|
*/
|
|
7
|
-
import { VectorDBService } from './vector-db-service';
|
|
8
7
|
import { PolicyIntent } from './organizational-types';
|
|
9
8
|
import { EmbeddingService } from './embedding-service';
|
|
10
9
|
import { BaseVectorService, BaseSearchOptions, BaseSearchResult } from './base-vector-service';
|
|
@@ -13,11 +12,11 @@ export interface PolicySearchOptions extends BaseSearchOptions {
|
|
|
13
12
|
export interface PolicySearchResult extends BaseSearchResult<PolicyIntent> {
|
|
14
13
|
}
|
|
15
14
|
export declare class PolicyVectorService extends BaseVectorService<PolicyIntent> {
|
|
16
|
-
constructor(
|
|
15
|
+
constructor(embeddingService?: EmbeddingService);
|
|
17
16
|
protected createSearchText(policyIntent: PolicyIntent): string;
|
|
18
17
|
protected extractId(policyIntent: PolicyIntent): string;
|
|
19
|
-
protected createPayload(policyIntent: PolicyIntent): Record<string,
|
|
20
|
-
protected payloadToData(payload: Record<string,
|
|
18
|
+
protected createPayload(policyIntent: PolicyIntent): Record<string, unknown>;
|
|
19
|
+
protected payloadToData(payload: Record<string, unknown>): PolicyIntent;
|
|
21
20
|
storePolicyIntent(policyIntent: PolicyIntent): Promise<void>;
|
|
22
21
|
searchPolicyIntents(query: string, options?: PolicySearchOptions): Promise<PolicySearchResult[]>;
|
|
23
22
|
getPolicyIntent(id: string): Promise<PolicyIntent | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy-vector-service.d.ts","sourceRoot":"","sources":["../../src/core/policy-vector-service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"policy-vector-service.d.ts","sourceRoot":"","sources":["../../src/core/policy-vector-service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAA2B,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAG/F,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;CAAG;AAEjE,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB,CAAC,YAAY,CAAC;CAAG;AAE7E,qBAAa,mBAAoB,SAAQ,iBAAiB,CAAC,YAAY,CAAC;gBAC1D,gBAAgB,CAAC,EAAE,gBAAgB;IAK/C,SAAS,CAAC,gBAAgB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM;IAM9D,SAAS,CAAC,SAAS,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM;IAIvD,SAAS,CAAC,aAAa,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAW5E,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY;IAajE,iBAAiB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5D,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAIpG,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAIzD,mBAAmB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAI9C,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC;CAG/C"}
|
|
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.PolicyVectorService = void 0;
|
|
10
10
|
const base_vector_service_1 = require("./base-vector-service");
|
|
11
11
|
class PolicyVectorService extends base_vector_service_1.BaseVectorService {
|
|
12
|
-
constructor(
|
|
13
|
-
super('policies',
|
|
12
|
+
constructor(embeddingService) {
|
|
13
|
+
super('policies', embeddingService);
|
|
14
14
|
}
|
|
15
15
|
// Implement abstract methods from BaseVectorService
|
|
16
16
|
createSearchText(policyIntent) {
|
|
@@ -12,7 +12,7 @@ export interface SamplingResult {
|
|
|
12
12
|
text: string;
|
|
13
13
|
} | string;
|
|
14
14
|
}
|
|
15
|
-
export type SamplingHandler = (messages: SamplingMessage[], systemPrompt?: string, options?:
|
|
15
|
+
export type SamplingHandler = (messages: SamplingMessage[], systemPrompt?: string, options?: Record<string, unknown>) => Promise<SamplingResult>;
|
|
16
16
|
export declare class HostProvider implements AIProvider {
|
|
17
17
|
private static samplingHandler?;
|
|
18
18
|
private debugMode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-provider.d.ts","sourceRoot":"","sources":["../../../src/core/providers/host-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,cAAc,EACf,MAAM,0BAA0B,CAAC;AAmBlC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC;CAClD;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC;CAClD;AAED,MAAM,MAAM,eAAe,GAAG,CAC5B,QAAQ,EAAE,eAAe,EAAE,EAC3B,YAAY,CAAC,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"host-provider.d.ts","sourceRoot":"","sources":["../../../src/core/providers/host-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,cAAc,EACf,MAAM,0BAA0B,CAAC;AAmBlC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC;CAClD;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC;CAClD;AAED,MAAM,MAAM,eAAe,GAAG,CAC5B,QAAQ,EAAE,eAAe,EAAE,EAC3B,YAAY,CAAC,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,OAAO,CAAC,cAAc,CAAC,CAAC;AAE7B,qBAAa,YAAa,YAAW,UAAU;IAC7C,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAkB;IACjD,OAAO,CAAC,SAAS,CAAU;;IAM3B,kBAAkB,CAAC,OAAO,EAAE,eAAe;IAI3C,aAAa,IAAI,OAAO;IAIxB,eAAe,IAAI,MAAM;IAIzB,eAAe,IAAI,MAAM;IAIzB,YAAY,IAAI,MAAM;IAItB,OAAO,CAAC,iBAAiB;IAwBnB,WAAW,CACf,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,MAAkB,EAC7B,iBAAiB,CAAC,EAAE;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GACA,OAAO,CAAC,UAAU,CAAC;IA4HtB;;;;;;;;;;OAUG;IACG,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;CAmN/D"}
|
|
@@ -274,7 +274,7 @@ class HostProvider {
|
|
|
274
274
|
try {
|
|
275
275
|
config.onIteration(iterations, toolCallsExecuted);
|
|
276
276
|
}
|
|
277
|
-
catch
|
|
277
|
+
catch {
|
|
278
278
|
// Ignore errors in callback
|
|
279
279
|
}
|
|
280
280
|
}
|
|
@@ -328,7 +328,7 @@ class HostProvider {
|
|
|
328
328
|
completionReason: 'max_iterations',
|
|
329
329
|
};
|
|
330
330
|
}
|
|
331
|
-
catch
|
|
331
|
+
catch {
|
|
332
332
|
// If wrap-up call fails, fall back to last message
|
|
333
333
|
const lastMessage = messages[messages.length - 2]; // -2 because we added wrap-up message
|
|
334
334
|
const lastContent = typeof lastMessage.content === 'string'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-debug-utils.d.ts","sourceRoot":"","sources":["../../../src/core/providers/provider-debug-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAErE;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAM7C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAKzD;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAEhC,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IAGnB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IAGrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAG3B,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE;QACZ,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IAGF,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IAGvB,gBAAgB,CAAC,EAAE,MAAM,GAAG;QAC1B,YAAY,EAAE,SAAS,GAAG,OAAO,GAAG,gBAAgB,CAAC;QACrD,cAAc,EAAE,MAAM,CAAC;QACvB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAGtE;AAED;;;GAGG;AACH;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,iBAAiB,EAC1B,SAAS,GAAE,OAAe,GACzB,IAAI,CAyEN;AAGD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE;IAChD,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"provider-debug-utils.d.ts","sourceRoot":"","sources":["../../../src/core/providers/provider-debug-utils.ts"],"names":[],"mappings":"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"}
|
|
@@ -4,10 +4,17 @@ import { AITool } from '../ai-provider.interface';
|
|
|
4
4
|
* Used by providers that don't support native tool calling or need manual prompting.
|
|
5
5
|
*/
|
|
6
6
|
export declare function formatToolDefinitions(tools: AITool[]): string;
|
|
7
|
+
/**
|
|
8
|
+
* Tool call structure
|
|
9
|
+
*/
|
|
10
|
+
interface ToolCall {
|
|
11
|
+
tool: string;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
7
14
|
/**
|
|
8
15
|
* Formats a tool execution result for inclusion in conversation history.
|
|
9
16
|
*/
|
|
10
|
-
export declare function formatToolOutput(toolName: string, output:
|
|
17
|
+
export declare function formatToolOutput(toolName: string, output: unknown): string;
|
|
11
18
|
/**
|
|
12
19
|
* Regex for extracting tool calls from markdown code blocks.
|
|
13
20
|
* Matches: ```json ... ``` and captures the content.
|
|
@@ -17,5 +24,6 @@ export declare const TOOL_CALL_REGEX: RegExp;
|
|
|
17
24
|
* Extracts tool calls from a string containing markdown code blocks.
|
|
18
25
|
* Handles nested objects and malformed JSON gracefully.
|
|
19
26
|
*/
|
|
20
|
-
export declare function extractToolCalls(content: string):
|
|
27
|
+
export declare function extractToolCalls(content: string): ToolCall[];
|
|
28
|
+
export {};
|
|
21
29
|
//# sourceMappingURL=tool-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-utils.d.ts","sourceRoot":"","sources":["../../../src/core/providers/tool-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAO7D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"tool-utils.d.ts","sourceRoot":"","sources":["../../../src/core/providers/tool-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAO7D;AAED;;GAEG;AACH,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAE1E;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAgC,CAAC;AAE7D;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,EAAE,CA8E5D"}
|
|
@@ -50,7 +50,7 @@ function extractToolCalls(content) {
|
|
|
50
50
|
toolCalls.push(parsed);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
catch
|
|
53
|
+
catch {
|
|
54
54
|
// Ignore parse errors
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -100,7 +100,7 @@ function extractToolCalls(content) {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
catch
|
|
103
|
+
catch {
|
|
104
104
|
// Ignore fallback errors
|
|
105
105
|
}
|
|
106
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel-provider.d.ts","sourceRoot":"","sources":["../../../src/core/providers/vercel-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"vercel-provider.d.ts","sourceRoot":"","sources":["../../../src/core/providers/vercel-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,OAAO,EACL,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,aAAa,EACd,MAAM,0BAA0B,CAAC;AA4DlC,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,aAAa,CAAiB;gBAE1B,MAAM,EAAE,gBAAgB;IAWpC,OAAO,CAAC,qBAAqB;IAY7B,OAAO,CAAC,eAAe;IAuFvB,eAAe,IAAI,MAAM;IAIzB,eAAe,IAAI,MAAM;IAIzB,YAAY,IAAI,MAAM;IAItB,aAAa,IAAI,OAAO;IAIxB,OAAO,CAAC,iBAAiB;IAyBnB,WAAW,CACf,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,MAAkB,EAC7B,iBAAiB,CAAC,EAAE;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GACA,OAAO,CAAC,UAAU,CAAC;IAoJtB;;;;;;;;;;;;OAYG;IACG,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;CAub/D"}
|
|
@@ -27,7 +27,7 @@ class VercelProvider {
|
|
|
27
27
|
apiKey;
|
|
28
28
|
debugMode;
|
|
29
29
|
baseURL; // PRD #194: Custom endpoint URL for OpenAI-compatible APIs
|
|
30
|
-
modelInstance; // Vercel AI SDK model instance
|
|
30
|
+
modelInstance; // Vercel AI SDK model instance - initialized by initializeModel()
|
|
31
31
|
constructor(config) {
|
|
32
32
|
this.apiKey = config.apiKey;
|
|
33
33
|
this.providerType = config.provider;
|
|
@@ -47,6 +47,7 @@ class VercelProvider {
|
|
|
47
47
|
}
|
|
48
48
|
initializeModel() {
|
|
49
49
|
try {
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Vercel AI SDK provider types vary
|
|
50
51
|
let provider;
|
|
51
52
|
switch (this.providerType) {
|
|
52
53
|
case 'openai':
|
|
@@ -376,6 +377,7 @@ class VercelProvider {
|
|
|
376
377
|
if (systemParam) {
|
|
377
378
|
generateConfig.system = systemParam;
|
|
378
379
|
}
|
|
380
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Vercel AI SDK types are complex, use any for compatibility
|
|
379
381
|
const result = await (0, ai_1.generateText)(generateConfig);
|
|
380
382
|
// Log raw response immediately after generation (before any processing)
|
|
381
383
|
let debugFiles = null;
|
|
@@ -394,25 +396,26 @@ class VercelProvider {
|
|
|
394
396
|
else if (Array.isArray(msg.content)) {
|
|
395
397
|
const contentParts = msg.content
|
|
396
398
|
.map(part => {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
+
const typedPart = part;
|
|
400
|
+
if (typedPart.type === 'text') {
|
|
401
|
+
return typedPart.text;
|
|
399
402
|
}
|
|
400
|
-
else if (
|
|
401
|
-
return `[TOOL_USE: ${
|
|
403
|
+
else if (typedPart.type === 'tool-call') {
|
|
404
|
+
return `[TOOL_USE: ${typedPart.toolName}]`;
|
|
402
405
|
}
|
|
403
|
-
else if (
|
|
404
|
-
const resultData =
|
|
405
|
-
|
|
406
|
-
|
|
406
|
+
else if (typedPart.type === 'tool-result') {
|
|
407
|
+
const resultData = typedPart.output ||
|
|
408
|
+
typedPart.result ||
|
|
409
|
+
typedPart.content;
|
|
407
410
|
if (typeof resultData === 'string') {
|
|
408
|
-
return `[TOOL_RESULT: ${
|
|
411
|
+
return `[TOOL_RESULT: ${typedPart.toolName}]\n${resultData}`;
|
|
409
412
|
}
|
|
410
413
|
else if (resultData) {
|
|
411
|
-
return `[TOOL_RESULT: ${
|
|
414
|
+
return `[TOOL_RESULT: ${typedPart.toolName}]\n${JSON.stringify(resultData, null, 2)}`;
|
|
412
415
|
}
|
|
413
|
-
return `[TOOL_RESULT: ${
|
|
416
|
+
return `[TOOL_RESULT: ${typedPart.toolName}]`;
|
|
414
417
|
}
|
|
415
|
-
return `[${
|
|
418
|
+
return `[${typedPart.type}]`;
|
|
416
419
|
})
|
|
417
420
|
.join(' ');
|
|
418
421
|
return `${msg.role}: ${contentParts}`;
|
|
@@ -471,23 +474,24 @@ class VercelProvider {
|
|
|
471
474
|
// However, testing still shows ~70% fewer tokens reported vs Anthropic native SDK.
|
|
472
475
|
// Root cause: We were using result.usage (final step only) instead of result.totalUsage (sum of all steps)!
|
|
473
476
|
const usage = result.totalUsage || result.usage;
|
|
477
|
+
const typedUsage = usage;
|
|
474
478
|
let cacheReadTokens = 0;
|
|
475
479
|
let cacheCreationTokens = 0;
|
|
476
480
|
// Anthropic via Vercel uses cachedInputTokens (confirmed in AI SDK 5+)
|
|
477
|
-
if (
|
|
478
|
-
cacheReadTokens =
|
|
481
|
+
if (typedUsage.cachedInputTokens) {
|
|
482
|
+
cacheReadTokens = typedUsage.cachedInputTokens;
|
|
479
483
|
}
|
|
480
484
|
// OpenAI uses cached_tokens or cachedTokens (automatic caching, no config needed)
|
|
481
|
-
if (
|
|
485
|
+
if (typedUsage.cachedTokens || typedUsage.cached_tokens) {
|
|
482
486
|
cacheReadTokens =
|
|
483
|
-
|
|
487
|
+
typedUsage.cachedTokens || typedUsage.cached_tokens || 0;
|
|
484
488
|
}
|
|
485
489
|
// Anthropic native SDK uses separate cache_creation and cache_read fields
|
|
486
|
-
if (
|
|
487
|
-
cacheCreationTokens =
|
|
490
|
+
if (typedUsage.cache_creation_input_tokens) {
|
|
491
|
+
cacheCreationTokens = typedUsage.cache_creation_input_tokens;
|
|
488
492
|
}
|
|
489
|
-
if (
|
|
490
|
-
cacheReadTokens =
|
|
493
|
+
if (typedUsage.cache_read_input_tokens) {
|
|
494
|
+
cacheReadTokens = typedUsage.cache_read_input_tokens;
|
|
491
495
|
}
|
|
492
496
|
// TODO: Check if Google Gemini reports cache metrics in future SDK versions
|
|
493
497
|
// Google Gemini may return cache-related metrics - check usage object structure
|
|
@@ -537,9 +541,10 @@ class VercelProvider {
|
|
|
537
541
|
}
|
|
538
542
|
// Add tool results as user messages
|
|
539
543
|
for (const toolResult of step.toolResults || []) {
|
|
544
|
+
const typedToolResult = toolResult;
|
|
540
545
|
wrapUpMessages.push({
|
|
541
546
|
role: 'user',
|
|
542
|
-
content: `Tool result from ${
|
|
547
|
+
content: `Tool result from ${typedToolResult.toolName}: ${JSON.stringify(typedToolResult.output || toolResult)}`,
|
|
543
548
|
});
|
|
544
549
|
}
|
|
545
550
|
}
|
|
@@ -560,6 +565,7 @@ class VercelProvider {
|
|
|
560
565
|
this.providerType !== 'anthropic_haiku') {
|
|
561
566
|
wrapUpConfig.system = config.systemPrompt;
|
|
562
567
|
}
|
|
568
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Vercel AI SDK types are complex, use any for compatibility
|
|
563
569
|
const wrapUpResult = await (0, ai_1.generateText)(wrapUpConfig);
|
|
564
570
|
finalText = wrapUpResult.text || finalText;
|
|
565
571
|
}
|
|
@@ -571,7 +577,7 @@ class VercelProvider {
|
|
|
571
577
|
// Log processed summary response (keep existing functionality)
|
|
572
578
|
if (this.debugMode && debugFiles === null) {
|
|
573
579
|
// Only log summary if we haven't already logged raw response
|
|
574
|
-
|
|
580
|
+
const finalPrompt = `System: ${config.systemPrompt}\n\nuser: ${config.userMessage}`;
|
|
575
581
|
const aiResponse = {
|
|
576
582
|
content: finalText || '',
|
|
577
583
|
usage: {
|
|
@@ -29,6 +29,33 @@ export declare const RESOURCE_TOOLS: AITool[];
|
|
|
29
29
|
* Respects QDRANT_RESOURCES_COLLECTION env var for collection name
|
|
30
30
|
*/
|
|
31
31
|
export declare function getResourceService(): Promise<ResourceVectorService>;
|
|
32
|
+
/**
|
|
33
|
+
* Input for search_resources tool
|
|
34
|
+
*/
|
|
35
|
+
export interface SearchResourcesInput {
|
|
36
|
+
query: string;
|
|
37
|
+
namespace?: string;
|
|
38
|
+
kind?: string;
|
|
39
|
+
apiVersion?: string;
|
|
40
|
+
limit?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Input for query_resources tool
|
|
44
|
+
*/
|
|
45
|
+
export interface QueryResourcesInput {
|
|
46
|
+
filter: Record<string, unknown>;
|
|
47
|
+
limit?: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Result from resource tool execution
|
|
51
|
+
*/
|
|
52
|
+
interface ResourceToolResult {
|
|
53
|
+
success: boolean;
|
|
54
|
+
data?: unknown[];
|
|
55
|
+
count?: number;
|
|
56
|
+
message: string;
|
|
57
|
+
error?: string;
|
|
58
|
+
}
|
|
32
59
|
/**
|
|
33
60
|
* Tool executor for resource-based tools
|
|
34
61
|
* Handles execution and error handling for all resource tool calls
|
|
@@ -37,7 +64,7 @@ export declare function getResourceService(): Promise<ResourceVectorService>;
|
|
|
37
64
|
* @param input - Tool input parameters
|
|
38
65
|
* @returns Tool execution result
|
|
39
66
|
*/
|
|
40
|
-
export declare function executeResourceTools(toolName: string, input:
|
|
67
|
+
export declare function executeResourceTools(toolName: string, input: SearchResourcesInput | QueryResourcesInput): Promise<ResourceToolResult>;
|
|
41
68
|
/**
|
|
42
69
|
* Reset the resource service (useful for testing)
|
|
43
70
|
*/
|
|
@@ -109,4 +136,5 @@ export declare function listResources(options: ListResourcesOptions): Promise<Li
|
|
|
109
136
|
* @returns Sorted array of namespace names
|
|
110
137
|
*/
|
|
111
138
|
export declare function getNamespaces(): Promise<string[]>;
|
|
139
|
+
export {};
|
|
112
140
|
//# sourceMappingURL=resource-tools.d.ts.map
|