@vfarcic/dot-ai 0.195.0 → 1.0.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.
Files changed (114) hide show
  1. package/README.md +2 -7
  2. package/dist/core/capability-scan-workflow.d.ts +4 -3
  3. package/dist/core/capability-scan-workflow.d.ts.map +1 -1
  4. package/dist/core/capability-scan-workflow.js +34 -39
  5. package/dist/core/circuit-breaker.d.ts +1 -0
  6. package/dist/core/circuit-breaker.d.ts.map +1 -1
  7. package/dist/core/circuit-breaker.js +11 -3
  8. package/dist/core/command-executor.d.ts +10 -1
  9. package/dist/core/command-executor.d.ts.map +1 -1
  10. package/dist/core/command-executor.js +63 -48
  11. package/dist/core/crd-availability.d.ts +6 -1
  12. package/dist/core/crd-availability.d.ts.map +1 -1
  13. package/dist/core/crd-availability.js +59 -49
  14. package/dist/core/deploy-operation.d.ts +17 -3
  15. package/dist/core/deploy-operation.d.ts.map +1 -1
  16. package/dist/core/deploy-operation.js +72 -21
  17. package/dist/core/discovery.d.ts +16 -43
  18. package/dist/core/discovery.d.ts.map +1 -1
  19. package/dist/core/discovery.js +128 -277
  20. package/dist/core/index.d.ts +10 -2
  21. package/dist/core/index.d.ts.map +1 -1
  22. package/dist/core/index.js +20 -9
  23. package/dist/core/pattern-operations.d.ts +3 -1
  24. package/dist/core/pattern-operations.d.ts.map +1 -1
  25. package/dist/core/pattern-operations.js +3 -2
  26. package/dist/core/plugin-client.d.ts +53 -0
  27. package/dist/core/plugin-client.d.ts.map +1 -0
  28. package/dist/core/plugin-client.js +148 -0
  29. package/dist/core/plugin-manager.d.ts +119 -0
  30. package/dist/core/plugin-manager.d.ts.map +1 -0
  31. package/dist/core/plugin-manager.js +366 -0
  32. package/dist/core/plugin-types.d.ts +100 -0
  33. package/dist/core/plugin-types.d.ts.map +1 -0
  34. package/dist/core/plugin-types.js +10 -0
  35. package/dist/core/policy-operations.d.ts +15 -7
  36. package/dist/core/policy-operations.d.ts.map +1 -1
  37. package/dist/core/policy-operations.js +59 -31
  38. package/dist/core/resource-tools.d.ts +2 -90
  39. package/dist/core/resource-tools.d.ts.map +1 -1
  40. package/dist/core/resource-tools.js +4 -178
  41. package/dist/core/schema.d.ts +18 -2
  42. package/dist/core/schema.d.ts.map +1 -1
  43. package/dist/core/schema.js +118 -16
  44. package/dist/core/telemetry/client.d.ts +7 -0
  45. package/dist/core/telemetry/client.d.ts.map +1 -1
  46. package/dist/core/telemetry/client.js +51 -51
  47. package/dist/core/telemetry/index.d.ts +1 -1
  48. package/dist/core/telemetry/index.d.ts.map +1 -1
  49. package/dist/core/telemetry/index.js +2 -1
  50. package/dist/core/telemetry/types.d.ts +1 -3
  51. package/dist/core/telemetry/types.d.ts.map +1 -1
  52. package/dist/core/tracing/index.d.ts +0 -1
  53. package/dist/core/tracing/index.d.ts.map +1 -1
  54. package/dist/core/tracing/index.js +1 -4
  55. package/dist/core/unified-creation-session.d.ts +6 -1
  56. package/dist/core/unified-creation-session.d.ts.map +1 -1
  57. package/dist/core/unified-creation-session.js +19 -11
  58. package/dist/interfaces/mcp.d.ts +8 -2
  59. package/dist/interfaces/mcp.d.ts.map +1 -1
  60. package/dist/interfaces/mcp.js +85 -34
  61. package/dist/interfaces/resource-sync-handler.d.ts.map +1 -1
  62. package/dist/interfaces/resource-sync-handler.js +37 -17
  63. package/dist/interfaces/rest-api.d.ts +4 -1
  64. package/dist/interfaces/rest-api.d.ts.map +1 -1
  65. package/dist/interfaces/rest-api.js +172 -49
  66. package/dist/mcp/server.js +39 -54
  67. package/dist/tools/deploy-manifests.d.ts +3 -1
  68. package/dist/tools/deploy-manifests.d.ts.map +1 -1
  69. package/dist/tools/deploy-manifests.js +112 -13
  70. package/dist/tools/generate-manifests.d.ts +3 -1
  71. package/dist/tools/generate-manifests.d.ts.map +1 -1
  72. package/dist/tools/generate-manifests.js +107 -33
  73. package/dist/tools/operate-analysis.d.ts +5 -1
  74. package/dist/tools/operate-analysis.d.ts.map +1 -1
  75. package/dist/tools/operate-analysis.js +37 -7
  76. package/dist/tools/operate-execution.d.ts +3 -1
  77. package/dist/tools/operate-execution.d.ts.map +1 -1
  78. package/dist/tools/operate-execution.js +6 -4
  79. package/dist/tools/operate.d.ts +7 -2
  80. package/dist/tools/operate.d.ts.map +1 -1
  81. package/dist/tools/operate.js +10 -6
  82. package/dist/tools/organizational-data.d.ts +3 -2
  83. package/dist/tools/organizational-data.d.ts.map +1 -1
  84. package/dist/tools/organizational-data.js +15 -13
  85. package/dist/tools/query.d.ts +5 -1
  86. package/dist/tools/query.d.ts.map +1 -1
  87. package/dist/tools/query.js +26 -18
  88. package/dist/tools/recommend.d.ts +3 -1
  89. package/dist/tools/recommend.d.ts.map +1 -1
  90. package/dist/tools/recommend.js +7 -7
  91. package/dist/tools/remediate.d.ts +5 -2
  92. package/dist/tools/remediate.d.ts.map +1 -1
  93. package/dist/tools/remediate.js +69 -20
  94. package/dist/tools/version.d.ts +20 -5
  95. package/dist/tools/version.d.ts.map +1 -1
  96. package/dist/tools/version.js +169 -161
  97. package/package.json +1 -1
  98. package/prompts/helm-generation.md +9 -0
  99. package/dist/core/cluster-utils.d.ts +0 -12
  100. package/dist/core/cluster-utils.d.ts.map +0 -1
  101. package/dist/core/cluster-utils.js +0 -27
  102. package/dist/core/helm-utils.d.ts +0 -66
  103. package/dist/core/helm-utils.d.ts.map +0 -1
  104. package/dist/core/helm-utils.js +0 -196
  105. package/dist/core/kubectl-tools.d.ts +0 -71
  106. package/dist/core/kubectl-tools.d.ts.map +0 -1
  107. package/dist/core/kubectl-tools.js +0 -546
  108. package/dist/core/kubernetes-utils.d.ts +0 -38
  109. package/dist/core/kubernetes-utils.d.ts.map +0 -1
  110. package/dist/core/kubernetes-utils.js +0 -288
  111. package/dist/core/tracing/k8s-tracing.d.ts +0 -57
  112. package/dist/core/tracing/k8s-tracing.d.ts.map +0 -1
  113. package/dist/core/tracing/k8s-tracing.js +0 -155
  114. package/scripts/toolhive.nu +0 -21
@@ -5,7 +5,7 @@
5
5
  * Shared intelligence for both CLI and MCP interfaces
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.CircuitOpenError = exports.CircuitState = exports.CircuitBreakerFactory = exports.CircuitBreaker = exports.buildAgentDisplayBlock = exports.VercelEmbeddingProvider = exports.EmbeddingService = exports.CapabilityVectorService = exports.PolicyVectorService = exports.PatternVectorService = exports.BaseVectorService = exports.VectorDBService = exports.deserializePattern = exports.serializePattern = exports.createPattern = exports.validatePattern = exports.ResourceRecommender = exports.ManifestValidator = exports.SchemaParser = exports.AIProviderFactory = exports.createAIProvider = exports.WorkflowEngine = exports.MemorySystem = exports.KubernetesDiscovery = exports.DotAI = void 0;
8
+ exports.PluginClientError = exports.PluginClient = exports.PluginDiscoveryError = exports.PluginManager = exports.CircuitOpenError = exports.CircuitState = exports.CircuitBreakerFactory = exports.CircuitBreaker = exports.buildAgentDisplayBlock = exports.VercelEmbeddingProvider = exports.EmbeddingService = exports.CapabilityVectorService = exports.PolicyVectorService = exports.PatternVectorService = exports.BaseVectorService = exports.VectorDBService = exports.deserializePattern = exports.serializePattern = exports.createPattern = exports.validatePattern = exports.ResourceRecommender = exports.ManifestValidator = exports.SchemaParser = exports.AIProviderFactory = exports.createAIProvider = exports.WorkflowEngine = exports.MemorySystem = exports.KubernetesDiscovery = exports.DotAI = void 0;
9
9
  const discovery_1 = require("./discovery");
10
10
  const memory_1 = require("./memory");
11
11
  const workflow_1 = require("./workflow");
@@ -20,14 +20,11 @@ class DotAI {
20
20
  workflow;
21
21
  ai;
22
22
  schema;
23
- constructor(config = {}) {
24
- this.config = {
25
- kubernetesConfig: config.kubernetesConfig || process.env.KUBECONFIG
26
- };
23
+ constructor() {
24
+ this.config = {};
27
25
  // Initialize modules
28
- this.discovery = new discovery_1.KubernetesDiscovery({
29
- kubeconfigPath: this.config.kubernetesConfig
30
- });
26
+ // PRD #343: KubernetesDiscovery no longer needs kubeconfig - all K8s ops go through plugin
27
+ this.discovery = new discovery_1.KubernetesDiscovery();
31
28
  this.memory = new memory_1.MemorySystem();
32
29
  this.workflow = new workflow_1.WorkflowEngine();
33
30
  this.ai = (0, ai_provider_factory_1.createAIProvider)();
@@ -88,7 +85,7 @@ class DotAI {
88
85
  async initialize() {
89
86
  try {
90
87
  // Initialize all modules
91
- await this.discovery.connect();
88
+ // PRD #343: K8s access via plugin - no connect() needed
92
89
  await this.memory.initialize();
93
90
  await this.workflow.initialize();
94
91
  this.initialized = true;
@@ -116,6 +113,13 @@ class DotAI {
116
113
  getVersion() {
117
114
  return '0.1.0';
118
115
  }
116
+ /**
117
+ * PRD #343: Set plugin manager for routing kubectl operations through plugin
118
+ * Must be called before any Kubernetes operations are performed
119
+ */
120
+ setPluginManager(pluginManager) {
121
+ this.discovery.setPluginManager(pluginManager);
122
+ }
119
123
  }
120
124
  exports.DotAI = DotAI;
121
125
  // Re-export all modules for convenience
@@ -158,5 +162,12 @@ Object.defineProperty(exports, "CircuitBreaker", { enumerable: true, get: functi
158
162
  Object.defineProperty(exports, "CircuitBreakerFactory", { enumerable: true, get: function () { return circuit_breaker_1.CircuitBreakerFactory; } });
159
163
  Object.defineProperty(exports, "CircuitState", { enumerable: true, get: function () { return circuit_breaker_1.CircuitState; } });
160
164
  Object.defineProperty(exports, "CircuitOpenError", { enumerable: true, get: function () { return circuit_breaker_1.CircuitOpenError; } });
165
+ // Plugin system (PRD #343)
166
+ var plugin_manager_1 = require("./plugin-manager");
167
+ Object.defineProperty(exports, "PluginManager", { enumerable: true, get: function () { return plugin_manager_1.PluginManager; } });
168
+ Object.defineProperty(exports, "PluginDiscoveryError", { enumerable: true, get: function () { return plugin_manager_1.PluginDiscoveryError; } });
169
+ var plugin_client_1 = require("./plugin-client");
170
+ Object.defineProperty(exports, "PluginClient", { enumerable: true, get: function () { return plugin_client_1.PluginClient; } });
171
+ Object.defineProperty(exports, "PluginClientError", { enumerable: true, get: function () { return plugin_client_1.PluginClientError; } });
161
172
  // Default export
162
173
  exports.default = DotAI;
@@ -7,6 +7,7 @@
7
7
  import { OrganizationalPattern, CreatePatternRequest } from './pattern-types';
8
8
  import { Logger } from './error-handling';
9
9
  import { PatternVectorService } from './index';
10
+ import type { PluginManager } from './plugin-manager';
10
11
  export declare function validatePattern(request: CreatePatternRequest): string[];
11
12
  export declare function createPattern(request: CreatePatternRequest): OrganizationalPattern;
12
13
  export declare function serializePattern(pattern: OrganizationalPattern): string;
@@ -14,6 +15,7 @@ export declare function deserializePattern(json: string): OrganizationalPattern;
14
15
  /**
15
16
  * Handle pattern operations with workflow support
16
17
  * Shared validation functions are passed as parameters to avoid circular dependencies
18
+ * PRD #343: pluginManager required for kubectl operations via plugin system
17
19
  */
18
20
  export declare function handlePatternOperation(operation: string, args: any, logger: Logger, requestId: string, validateVectorDBConnection: (vectorService: PatternVectorService, logger: Logger, requestId: string) => Promise<{
19
21
  success: boolean;
@@ -21,5 +23,5 @@ export declare function handlePatternOperation(operation: string, args: any, log
21
23
  }>, validateEmbeddingService: (logger: Logger, requestId: string) => Promise<{
22
24
  success: boolean;
23
25
  error?: any;
24
- }>): Promise<any>;
26
+ }>, pluginManager?: PluginManager): Promise<any>;
25
27
  //# sourceMappingURL=pattern-operations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pattern-operations.d.ts","sourceRoot":"","sources":["../../src/core/pattern-operations.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE9E,OAAO,EAA8C,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAGtF,OAAO,EAAmB,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAShE,wBAAgB,eAAe,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,EAAE,CA2BvE;AAGD,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,qBAAqB,CAwBlF;AAGD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,qBAAqB,GAA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;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,0BAA0B,EAAE,CAAC,aAAa,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAA;CAAE,CAAC,EAClJ,wBAAwB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAA;CAAE,CAAC,EAC3G,aAAa,CAAC,EAAE,aAAa,GAC5B,OAAO,CAAC,GAAG,CAAC,CAuYd"}
@@ -134,8 +134,9 @@ async function getPatternService() {
134
134
  /**
135
135
  * Handle pattern operations with workflow support
136
136
  * Shared validation functions are passed as parameters to avoid circular dependencies
137
+ * PRD #343: pluginManager required for kubectl operations via plugin system
137
138
  */
138
- async function handlePatternOperation(operation, args, logger, requestId, validateVectorDBConnection, validateEmbeddingService) {
139
+ async function handlePatternOperation(operation, args, logger, requestId, validateVectorDBConnection, validateEmbeddingService, pluginManager) {
139
140
  // Get pattern service and validate Vector DB connection
140
141
  const patternService = await getPatternService();
141
142
  const connectionCheck = await validateVectorDBConnection(patternService, logger, requestId);
@@ -162,7 +163,7 @@ async function handlePatternOperation(operation, args, logger, requestId, valida
162
163
  };
163
164
  }
164
165
  }
165
- const sessionManager = new unified_creation_session_1.UnifiedCreationSessionManager('pattern');
166
+ const sessionManager = new unified_creation_session_1.UnifiedCreationSessionManager('pattern', undefined, pluginManager);
166
167
  switch (operation) {
167
168
  case 'create': {
168
169
  let workflowStep;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Plugin Client for dot-ai Plugin System
3
+ *
4
+ * HTTP client for communicating with agentic plugins.
5
+ * Handles describe and invoke hooks via POST /execute endpoint.
6
+ *
7
+ * PRD #343: kubectl Plugin Migration
8
+ */
9
+ import { PluginConfig, DescribeResponse, InvokeResponse } from './plugin-types';
10
+ import { Logger } from './error-handling';
11
+ /**
12
+ * Error thrown when plugin communication fails
13
+ */
14
+ export declare class PluginClientError extends Error {
15
+ readonly pluginName: string;
16
+ readonly pluginUrl: string;
17
+ readonly cause?: Error | undefined;
18
+ constructor(message: string, pluginName: string, pluginUrl: string, cause?: Error | undefined);
19
+ }
20
+ /**
21
+ * HTTP client for a single plugin
22
+ */
23
+ export declare class PluginClient {
24
+ private readonly config;
25
+ private readonly logger;
26
+ private readonly timeout;
27
+ constructor(config: PluginConfig, logger: Logger);
28
+ /**
29
+ * Get plugin name
30
+ */
31
+ get name(): string;
32
+ /**
33
+ * Get plugin URL
34
+ */
35
+ get url(): string;
36
+ /**
37
+ * Call the describe hook to get tool definitions
38
+ */
39
+ describe(): Promise<DescribeResponse>;
40
+ /**
41
+ * Call the invoke hook to execute a tool
42
+ */
43
+ invoke(tool: string, args: Record<string, unknown>, state?: Record<string, unknown>, sessionId?: string): Promise<InvokeResponse>;
44
+ /**
45
+ * Check if plugin is healthy/reachable
46
+ */
47
+ healthCheck(): Promise<boolean>;
48
+ /**
49
+ * Execute a request to the plugin's /execute endpoint
50
+ */
51
+ private execute;
52
+ }
53
+ //# sourceMappingURL=plugin-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-client.d.ts","sourceRoot":"","sources":["../../src/core/plugin-client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,YAAY,EAEZ,gBAAgB,EAEhB,cAAc,EACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;aAGxB,UAAU,EAAE,MAAM;aAClB,SAAS,EAAE,MAAM;aACjB,KAAK,CAAC,EAAE,KAAK;gBAH7B,OAAO,EAAE,MAAM,EACC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,KAAK,YAAA;CAKhC;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM;IAQhD;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAqB3C;;OAEG;IACG,MAAM,CACV,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACnC,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,CAAC;IA8B1B;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IASrC;;OAEG;YACW,OAAO;CAqDtB"}
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ /**
3
+ * Plugin Client for dot-ai Plugin System
4
+ *
5
+ * HTTP client for communicating with agentic plugins.
6
+ * Handles describe and invoke hooks via POST /execute endpoint.
7
+ *
8
+ * PRD #343: kubectl Plugin Migration
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.PluginClient = exports.PluginClientError = void 0;
12
+ /**
13
+ * Error thrown when plugin communication fails
14
+ */
15
+ class PluginClientError extends Error {
16
+ pluginName;
17
+ pluginUrl;
18
+ cause;
19
+ constructor(message, pluginName, pluginUrl, cause) {
20
+ super(message);
21
+ this.pluginName = pluginName;
22
+ this.pluginUrl = pluginUrl;
23
+ this.cause = cause;
24
+ this.name = 'PluginClientError';
25
+ }
26
+ }
27
+ exports.PluginClientError = PluginClientError;
28
+ /**
29
+ * HTTP client for a single plugin
30
+ */
31
+ class PluginClient {
32
+ config;
33
+ logger;
34
+ timeout;
35
+ constructor(config, logger) {
36
+ this.config = config;
37
+ this.logger = logger;
38
+ // PRD #343: Increased default timeout from 30s to 5m for Helm operations
39
+ // Helm install/upgrade with --wait can take several minutes for complex charts
40
+ this.timeout = config.timeout ?? 300000;
41
+ }
42
+ /**
43
+ * Get plugin name
44
+ */
45
+ get name() {
46
+ return this.config.name;
47
+ }
48
+ /**
49
+ * Get plugin URL
50
+ */
51
+ get url() {
52
+ return this.config.url;
53
+ }
54
+ /**
55
+ * Call the describe hook to get tool definitions
56
+ */
57
+ async describe() {
58
+ const request = {
59
+ hook: 'describe',
60
+ };
61
+ this.logger.debug('Calling plugin describe hook', {
62
+ plugin: this.config.name,
63
+ url: this.config.url,
64
+ });
65
+ const response = await this.execute(request);
66
+ this.logger.debug('Plugin describe response', {
67
+ plugin: this.config.name,
68
+ version: response.version,
69
+ toolCount: response.tools.length,
70
+ });
71
+ return response;
72
+ }
73
+ /**
74
+ * Call the invoke hook to execute a tool
75
+ */
76
+ async invoke(tool, args, state = {}, sessionId) {
77
+ const payload = {
78
+ tool,
79
+ args,
80
+ state,
81
+ };
82
+ const request = {
83
+ hook: 'invoke',
84
+ sessionId,
85
+ payload,
86
+ };
87
+ this.logger.debug('Calling plugin invoke hook', {
88
+ plugin: this.config.name,
89
+ tool,
90
+ sessionId,
91
+ });
92
+ const response = await this.execute(request);
93
+ this.logger.debug('Plugin invoke response', {
94
+ plugin: this.config.name,
95
+ tool,
96
+ success: response.success,
97
+ });
98
+ return response;
99
+ }
100
+ /**
101
+ * Check if plugin is healthy/reachable
102
+ */
103
+ async healthCheck() {
104
+ try {
105
+ await this.describe();
106
+ return true;
107
+ }
108
+ catch {
109
+ return false;
110
+ }
111
+ }
112
+ /**
113
+ * Execute a request to the plugin's /execute endpoint
114
+ */
115
+ async execute(request) {
116
+ const executeUrl = `${this.config.url}/execute`;
117
+ try {
118
+ const controller = new AbortController();
119
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
120
+ const response = await fetch(executeUrl, {
121
+ method: 'POST',
122
+ headers: {
123
+ 'Content-Type': 'application/json',
124
+ },
125
+ body: JSON.stringify(request),
126
+ signal: controller.signal,
127
+ });
128
+ clearTimeout(timeoutId);
129
+ if (!response.ok) {
130
+ const errorText = await response.text().catch(() => 'Unknown error');
131
+ throw new PluginClientError(`Plugin returned HTTP ${response.status}: ${errorText}`, this.config.name, this.config.url);
132
+ }
133
+ const data = await response.json();
134
+ return data;
135
+ }
136
+ catch (error) {
137
+ if (error instanceof PluginClientError) {
138
+ throw error;
139
+ }
140
+ const cause = error instanceof Error ? error : new Error(String(error));
141
+ if (cause.name === 'AbortError') {
142
+ throw new PluginClientError(`Plugin request timed out after ${this.timeout}ms`, this.config.name, this.config.url, cause);
143
+ }
144
+ throw new PluginClientError(`Failed to communicate with plugin: ${cause.message}`, this.config.name, this.config.url, cause);
145
+ }
146
+ }
147
+ }
148
+ exports.PluginClient = PluginClient;
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Plugin Manager for dot-ai Plugin System
3
+ *
4
+ * Discovers plugins at startup and manages tool routing.
5
+ * Provides discovered tools to the MCP server for registration.
6
+ *
7
+ * PRD #343: kubectl Plugin Migration
8
+ */
9
+ import { PluginConfig, DiscoveredPlugin, InvokeResponse } from './plugin-types';
10
+ import { Logger } from './error-handling';
11
+ import { AITool, ToolExecutor } from './ai-provider.interface';
12
+ /**
13
+ * Error thrown when plugin discovery fails
14
+ */
15
+ export declare class PluginDiscoveryError extends Error {
16
+ readonly failedPlugins: Array<{
17
+ name: string;
18
+ error: string;
19
+ }>;
20
+ constructor(message: string, failedPlugins: Array<{
21
+ name: string;
22
+ error: string;
23
+ }>);
24
+ }
25
+ /**
26
+ * Manages plugin discovery, registration, and tool routing
27
+ */
28
+ export declare class PluginManager {
29
+ private readonly logger;
30
+ private readonly plugins;
31
+ private readonly discoveredPlugins;
32
+ private readonly toolToPlugin;
33
+ constructor(logger: Logger);
34
+ /**
35
+ * Parse plugin configuration from file
36
+ *
37
+ * Reads from /etc/dot-ai/plugins.json (mounted from ConfigMap in K8s).
38
+ * Returns empty array if file doesn't exist (plugins only work in-cluster).
39
+ * Throws on invalid JSON or malformed plugin configuration.
40
+ */
41
+ static parsePluginConfig(): PluginConfig[];
42
+ /**
43
+ * Discover all configured plugins
44
+ *
45
+ * Calls describe hook on each plugin and registers their tools.
46
+ * Non-required plugins that fail to respond are logged but don't fail startup.
47
+ */
48
+ discoverPlugins(configs: PluginConfig[]): Promise<void>;
49
+ /**
50
+ * Discover a single plugin with retry logic
51
+ *
52
+ * Retries with exponential backoff to handle Kubernetes startup ordering
53
+ * where plugin service may not be ready when MCP server starts.
54
+ */
55
+ private discoverPlugin;
56
+ /**
57
+ * Get all discovered tools as AITool format for registration
58
+ *
59
+ * Only returns tools where the tool-to-plugin mapping is canonical.
60
+ * This filters out duplicate tools when multiple plugins define the same tool name.
61
+ */
62
+ getDiscoveredTools(): AITool[];
63
+ /**
64
+ * Get tools from a specific plugin
65
+ */
66
+ getPluginTools(pluginName: string): AITool[];
67
+ /**
68
+ * Check if a tool is provided by a plugin
69
+ */
70
+ isPluginTool(toolName: string): boolean;
71
+ /**
72
+ * Get the plugin name for a tool
73
+ */
74
+ getToolPlugin(toolName: string): string | undefined;
75
+ /**
76
+ * Invoke a tool on its plugin
77
+ */
78
+ invokeTool(toolName: string, args: Record<string, unknown>, state?: Record<string, unknown>, sessionId?: string): Promise<InvokeResponse>;
79
+ /**
80
+ * Create a ToolExecutor that routes plugin tools to plugins
81
+ *
82
+ * Returns a function compatible with toolLoop's toolExecutor parameter.
83
+ * Plugin tools are routed to their plugins via HTTP; non-plugin tools
84
+ * are routed to the optional fallback executor.
85
+ *
86
+ * @param fallbackExecutor Optional executor for non-plugin tools
87
+ * @returns ToolExecutor function for use in agentic tool loops
88
+ */
89
+ createToolExecutor(fallbackExecutor?: ToolExecutor): ToolExecutor;
90
+ /**
91
+ * Get list of discovered plugin names
92
+ */
93
+ getDiscoveredPluginNames(): string[];
94
+ /**
95
+ * Get discovered plugin metadata
96
+ */
97
+ getDiscoveredPlugin(name: string): DiscoveredPlugin | undefined;
98
+ /**
99
+ * Get all discovered plugins
100
+ */
101
+ getAllDiscoveredPlugins(): DiscoveredPlugin[];
102
+ /**
103
+ * Get plugin statistics
104
+ */
105
+ getStats(): {
106
+ pluginCount: number;
107
+ toolCount: number;
108
+ plugins: Array<{
109
+ name: string;
110
+ version: string;
111
+ toolCount: number;
112
+ }>;
113
+ };
114
+ /**
115
+ * Convert PluginToolDefinition to AITool format
116
+ */
117
+ private convertToAITool;
118
+ }
119
+ //# sourceMappingURL=plugin-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-manager.d.ts","sourceRoot":"","sources":["../../src/core/plugin-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,YAAY,EAEZ,gBAAgB,EAChB,cAAc,EACf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAK/D;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;aAG3B,aAAa,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;gBADrE,OAAO,EAAE,MAAM,EACC,aAAa,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAKxE;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,C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