@vfarcic/dot-ai 0.105.0 → 0.107.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 CHANGED
@@ -22,10 +22,13 @@ DevOps AI Toolkit is an AI-powered development productivity platform that enhanc
22
22
  - **SRE Teams**: Automate root cause analysis and generate executable remediation commands
23
23
  - **Support Teams**: Handle incident response with AI-guided investigation and repair workflows
24
24
 
25
+ <!--
25
26
  ### Platform Building
27
+ DEVELOPER NOTE: This tool is under active development with incomplete functionality. Not recommended for production use.
26
28
  - **Platform Engineers**: Install and configure platform tools conversationally without memorizing script paths and commands
27
29
  - **New Team Members**: Build platform infrastructure through zero-knowledge guided workflows
28
30
  - **DevOps Teams**: Create and manage Kubernetes clusters through natural language interactions
31
+ -->
29
32
 
30
33
  ### Documentation Testing
31
34
  - **Documentation Maintainers**: Automatically validate documentation accuracy and catch outdated content
@@ -84,7 +87,9 @@ Result: Finds sqls.devopstoolkit.live as perfect match ✨
84
87
 
85
88
  📖 [Learn more →](./docs/mcp-remediate-guide.md)
86
89
 
90
+ <!--
87
91
  ### Platform Building
92
+ DEVELOPER NOTE: This tool is under active development with incomplete functionality. Not recommended for production use.
88
93
  🗣️ **Natural Language Operations**: Install tools and create clusters through conversation without memorizing commands
89
94
  🔍 **Dynamic Discovery**: Automatically discovers 21+ available platform operations from infrastructure scripts
90
95
  🤖 **AI-Powered Intent Mapping**: Understands variations like "Install Argo CD", "Set up ArgoCD", "Deploy Argo CD"
@@ -92,6 +97,7 @@ Result: Finds sqls.devopstoolkit.live as perfect match ✨
92
97
  🎯 **Zero-Knowledge Onboarding**: New users successfully build platforms without documentation
93
98
 
94
99
  📖 [Learn more →](./docs/mcp-build-platform-guide.md)
100
+ -->
95
101
 
96
102
  ### Documentation Testing & Validation
97
103
  📖 **Automated Testing**: Validates documentation by executing commands and testing examples
@@ -68,6 +68,66 @@ export interface AIProviderConfig {
68
68
  /** Enable debug mode for logging AI interactions */
69
69
  debugMode?: boolean;
70
70
  }
71
+ /**
72
+ * Tool definition for AI providers
73
+ * Defines a tool that the AI can call during agentic loops
74
+ */
75
+ export interface AITool {
76
+ /** Unique tool name (e.g., 'kubectl_get', 'search_capabilities') */
77
+ name: string;
78
+ /** Human-readable description of what the tool does and when to use it */
79
+ description: string;
80
+ /** JSON schema for tool input parameters */
81
+ inputSchema: {
82
+ type: 'object';
83
+ properties: Record<string, any>;
84
+ required?: string[];
85
+ };
86
+ }
87
+ /**
88
+ * Tool executor function type
89
+ * Called by the provider when AI requests a tool execution
90
+ */
91
+ export type ToolExecutor = (toolName: string, input: any) => Promise<any>;
92
+ /**
93
+ * Configuration for agentic tool loop
94
+ */
95
+ export interface ToolLoopConfig {
96
+ /** System prompt with context and strategic guidance */
97
+ systemPrompt: string;
98
+ /** User message/query to respond to */
99
+ userMessage: string;
100
+ /** Available tools for this workflow (scoped to workflow needs) */
101
+ tools: AITool[];
102
+ /** Function to execute tool calls */
103
+ toolExecutor: ToolExecutor;
104
+ /** Maximum number of AI iterations (default: 20) */
105
+ maxIterations?: number;
106
+ /** Optional callback invoked after each iteration */
107
+ onIteration?: (iteration: number, toolCalls: any[]) => void;
108
+ /** Optional operation identifier for metrics and debugging */
109
+ operation?: string;
110
+ }
111
+ /**
112
+ * Result from agentic tool loop
113
+ */
114
+ export interface AgenticResult {
115
+ /** Final text response from AI after completing tool loop */
116
+ finalMessage: string;
117
+ /** Number of iterations executed */
118
+ iterations: number;
119
+ /** All tool calls executed during the loop */
120
+ toolCallsExecuted: Array<{
121
+ tool: string;
122
+ input: any;
123
+ output: any;
124
+ }>;
125
+ /** Token usage statistics */
126
+ totalTokens: {
127
+ input: number;
128
+ output: number;
129
+ };
130
+ }
71
131
  /**
72
132
  * AI Provider Interface
73
133
  *
@@ -112,5 +172,37 @@ export interface AIProvider {
112
172
  * @returns Provider identifier (e.g., 'anthropic', 'openai', 'google')
113
173
  */
114
174
  getProviderType(): string;
175
+ /**
176
+ * Execute agentic loop with tool calling (NEW - PRD #136)
177
+ *
178
+ * AI autonomously decides which tools to call and when to stop.
179
+ * Supports multi-turn conversations with tool execution.
180
+ *
181
+ * NOTE: Currently NOT USED in codebase. PRD #136 analysis showed JSON-based loops
182
+ * achieve same goals without SDK overhead. Kept for potential future use.
183
+ *
184
+ * IMPLEMENTATION STATUS:
185
+ * - AnthropicProvider: ✅ Implemented
186
+ * - VercelAIProvider: ❌ Not implemented (not needed for current workflows)
187
+ *
188
+ * @param config Tool loop configuration with system prompt, tools, and executor
189
+ * @returns Agentic result with final message, iterations, tool calls, and token usage
190
+ */
191
+ toolLoop(config: ToolLoopConfig): Promise<AgenticResult>;
192
+ /**
193
+ * Single-shot message with tool calling enabled (NEW - PRD #136)
194
+ *
195
+ * AI can call tools, but only processes one round.
196
+ * Useful for simple tool use cases that don't require iteration.
197
+ *
198
+ * @param message The message/prompt to send
199
+ * @param tools Available tools for this request
200
+ * @param toolExecutor Function to execute tool calls
201
+ * @param operation Optional operation identifier for debugging
202
+ * @returns AI response with content, usage, and any tool calls made
203
+ */
204
+ sendMessageWithTools(message: string, tools: AITool[], toolExecutor: ToolExecutor, operation?: string): Promise<AIResponse & {
205
+ toolCalls?: any[];
206
+ }>;
115
207
  }
116
208
  //# sourceMappingURL=ai-provider.interface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-provider.interface.d.ts","sourceRoot":"","sources":["../../src/core/ai-provider.interface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE;QACL,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,0BAA0B,GAC1B,uBAA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AC,CAAC;IAEH,6BAA6B;IAC7B,WAAW,EAAE;QACX,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;;;OAUG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAEtE;;;;;;OAMG;IACH,aAAa,IAAI,OAAO,CAAC;IAEzB;;;;;;;OAOG;IACH,eAAe,IAAI,MAAM,CAAC;IAE1B;;;;;;OAMG;IACH,eAAe,IAAI,MAAM,CAAC;IAE1B;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAEzD;;;;;;;;;;;OAWG;IACH,oBAAoB,CAClB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EAAE,EACf,YAAY,EAAE,YAAY,EAC1B,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,UAAU,GAAG;QAAE,SAAS,CAAC,EAAE,GAAG,EAAE,CAAA;KAAE,CAAC,CAAC;CAChD"}
@@ -1,20 +1,13 @@
1
1
  /**
2
2
  * Platform Operations Discovery
3
3
  *
4
- * Discovers available Nu shell script operations and maps user intent to operations
5
- * using AI-powered parsing and matching.
4
+ * Orchestrates tool-based discovery and mapping of Nu shell script operations.
5
+ * All data fetching logic lives in tools, this module handles orchestration.
6
6
  */
7
7
  import { AIProvider } from './ai-provider.interface';
8
8
  import { Logger } from './error-handling';
9
- export interface OperationCommand {
10
- name: string;
11
- command: string[];
12
- }
13
- export interface Operation {
14
- name: string;
15
- description: string;
16
- operations: OperationCommand[];
17
- }
9
+ export { Operation, OperationCommand } from '../tools/platform/discover-operations.tool';
10
+ import { Operation } from '../tools/platform/discover-operations.tool';
18
11
  export interface MatchedOperation {
19
12
  tool: string;
20
13
  operation: string;
@@ -45,7 +38,8 @@ export interface PlatformSession {
45
38
  updatedAt: string;
46
39
  }
47
40
  /**
48
- * Discover available operations from Nu shell scripts using AI parsing
41
+ * Discover available operations from Nu shell scripts
42
+ * Uses tool for data fetching and prompt injection for AI parsing
49
43
  */
50
44
  export declare function discoverOperations(aiProvider: AIProvider, logger: Logger): Promise<Operation[]>;
51
45
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"platform-operations.d.ts","sourceRoot":"","sources":["../../src/core/platform-operations.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AA4B1C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,gBAAgB,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IACjD,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,EAAE,C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,EAAE,CAAA;CAAE,CAAC,CAkE/F"}
@@ -2,8 +2,8 @@
2
2
  /**
3
3
  * Platform Operations Discovery
4
4
  *
5
- * Discovers available Nu shell script operations and maps user intent to operations
6
- * using AI-powered parsing and matching.
5
+ * Orchestrates tool-based discovery and mapping of Nu shell script operations.
6
+ * All data fetching logic lives in tools, this module handles orchestration.
7
7
  */
8
8
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
9
  if (k2 === undefined) k2 = k;
@@ -45,52 +45,31 @@ exports.getOperationParameters = getOperationParameters;
45
45
  exports.createSession = createSession;
46
46
  exports.loadSession = loadSession;
47
47
  exports.executeOperation = executeOperation;
48
- const child_process_1 = require("child_process");
49
- const util_1 = require("util");
50
48
  const fs = __importStar(require("fs"));
51
49
  const path = __importStar(require("path"));
52
- const execAsync = (0, util_1.promisify)(child_process_1.exec);
50
+ const platform_utils_1 = require("./platform-utils");
53
51
  /**
54
- * Get the scripts directory path, works in both development and installed npm package
55
- */
56
- function getScriptsDir() {
57
- // In CommonJS (after TypeScript compilation), __dirname is available
58
- // Go up from dist/core/ to project root, then into scripts/
59
- return path.join(__dirname, '..', '..', 'scripts');
60
- }
61
- /**
62
- * Strip markdown code blocks from AI response
63
- */
64
- function stripMarkdownCodeBlocks(content) {
65
- let jsonContent = content.trim();
66
- if (jsonContent.startsWith('```json')) {
67
- jsonContent = jsonContent.replace(/^```json\s*/, '').replace(/\s*```$/, '');
68
- }
69
- else if (jsonContent.startsWith('```')) {
70
- jsonContent = jsonContent.replace(/^```\s*/, '').replace(/\s*```$/, '');
71
- }
72
- return jsonContent;
73
- }
74
- /**
75
- * Discover available operations from Nu shell scripts using AI parsing
52
+ * Discover available operations from Nu shell scripts
53
+ * Uses tool for data fetching and prompt injection for AI parsing
76
54
  */
77
55
  async function discoverOperations(aiProvider, logger) {
78
56
  try {
79
- // Execute Nu script help command
80
- const scriptPath = path.join(getScriptsDir(), 'dot.nu');
81
- const { stdout, stderr } = await execAsync(`nu ${scriptPath} --help`);
82
- if (stderr) {
83
- logger.warn?.('Nu script help command produced stderr', { stderr });
57
+ // Import the tool execution function
58
+ const { executeDiscoverOperations } = await Promise.resolve().then(() => __importStar(require('../tools/platform/discover-operations.tool')));
59
+ // Execute tool directly to get help output
60
+ const toolResult = await executeDiscoverOperations({}, aiProvider, logger);
61
+ if (!toolResult.success || !toolResult.helpOutput) {
62
+ throw new Error(toolResult.error || 'Failed to get Nu script help output');
84
63
  }
85
- // Load AI prompt template for parsing help output
86
- const promptPath = path.join(process.cwd(), 'prompts', 'parse-script-operations.md');
64
+ // Load the parsing prompt template
65
+ const promptPath = path.join(process.cwd(), 'prompts', 'platform-operations-parse-script-help.md');
87
66
  const promptTemplate = fs.readFileSync(promptPath, 'utf8');
88
- // Replace template variable with actual help output
89
- const prompt = promptTemplate.replace('{helpOutput}', stdout);
90
- // Send to AI provider for AI-powered parsing
91
- const response = await aiProvider.sendMessage(prompt);
92
- // Strip markdown code blocks and parse JSON
93
- const jsonContent = stripMarkdownCodeBlocks(response.content);
67
+ // Inject help output into prompt
68
+ const prompt = promptTemplate.replace('{helpOutput}', toolResult.helpOutput);
69
+ // Single AI call with injected data
70
+ const response = await aiProvider.sendMessage(prompt, 'platform-discover-operations');
71
+ // Parse operations from AI response
72
+ const jsonContent = (0, platform_utils_1.stripMarkdownCodeBlocks)(response.content);
94
73
  const operations = JSON.parse(jsonContent);
95
74
  logger.info?.('Discovered operations from Nu scripts', {
96
75
  count: operations.length
@@ -115,9 +94,9 @@ async function mapIntentToOperation(intent, operations, aiProvider, logger) {
115
94
  .replace('{intent}', intent)
116
95
  .replace('{operations}', JSON.stringify(operations, null, 2));
117
96
  // Send to AI provider for AI-powered intent matching
118
- const response = await aiProvider.sendMessage(prompt);
97
+ const response = await aiProvider.sendMessage(prompt, 'platform-map-intent');
119
98
  // Strip markdown code blocks and parse JSON
120
- const jsonContent = stripMarkdownCodeBlocks(response.content);
99
+ const jsonContent = (0, platform_utils_1.stripMarkdownCodeBlocks)(response.content);
121
100
  const mapping = JSON.parse(jsonContent);
122
101
  // Validate that AI returned required fields
123
102
  if (mapping.matched && mapping.operation) {
@@ -146,9 +125,9 @@ async function getOperationParameters(command, logger) {
146
125
  // Build the full command name that Nushell expects
147
126
  const commandName = `main ${command.join(' ')}`;
148
127
  // Execute Nu script to get structured command metadata
149
- const scriptPath = path.join(getScriptsDir(), 'dot.nu');
128
+ const scriptPath = path.join((0, platform_utils_1.getScriptsDir)(), 'dot.nu');
150
129
  const nuCommand = `source ${scriptPath}; scope commands | where name == "${commandName}" | to json`;
151
- const { stdout, stderr } = await execAsync(`nu -c '${nuCommand}'`);
130
+ const { stdout, stderr } = await (0, platform_utils_1.execAsync)(`nu -c '${nuCommand}'`);
152
131
  if (stderr) {
153
132
  logger.warn?.('Nu scope commands produced stderr', { stderr });
154
133
  }
@@ -278,7 +257,7 @@ async function executeOperation(session, answers, logger) {
278
257
  }
279
258
  }
280
259
  // Build Nu script command
281
- const scriptPath = path.join(getScriptsDir(), 'dot.nu');
260
+ const scriptPath = path.join((0, platform_utils_1.getScriptsDir)(), 'dot.nu');
282
261
  const command = session.matchedOperation.command;
283
262
  // Build command arguments
284
263
  const args = [];
@@ -294,7 +273,7 @@ async function executeOperation(session, answers, logger) {
294
273
  sessionId: session.sessionId,
295
274
  command: fullCommand
296
275
  });
297
- const { stdout, stderr } = await execAsync(fullCommand);
276
+ const { stdout, stderr } = await (0, platform_utils_1.execAsync)(fullCommand);
298
277
  if (stderr) {
299
278
  logger.warn?.('Operation produced stderr', { stderr });
300
279
  }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Platform Utilities
3
+ *
4
+ * Shared utility functions for platform operations and tools.
5
+ */
6
+ import { exec } from 'child_process';
7
+ export declare const execAsync: typeof exec.__promisify__;
8
+ /**
9
+ * Get the scripts directory path, works in both development and installed npm package
10
+ */
11
+ export declare function getScriptsDir(): string;
12
+ /**
13
+ * Strip markdown code blocks from AI response
14
+ */
15
+ export declare function stripMarkdownCodeBlocks(content: string): string;
16
+ //# sourceMappingURL=platform-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-utils.d.ts","sourceRoot":"","sources":["../../src/core/platform-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAIrC,eAAO,MAAM,SAAS,2BAAkB,CAAC;AAEzC;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAItC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQ/D"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ /**
3
+ * Platform Utilities
4
+ *
5
+ * Shared utility functions for platform operations and tools.
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.execAsync = void 0;
42
+ exports.getScriptsDir = getScriptsDir;
43
+ exports.stripMarkdownCodeBlocks = stripMarkdownCodeBlocks;
44
+ const child_process_1 = require("child_process");
45
+ const util_1 = require("util");
46
+ const path = __importStar(require("path"));
47
+ exports.execAsync = (0, util_1.promisify)(child_process_1.exec);
48
+ /**
49
+ * Get the scripts directory path, works in both development and installed npm package
50
+ */
51
+ function getScriptsDir() {
52
+ // In CommonJS (after TypeScript compilation), __dirname is available
53
+ // Go up from dist/core/ to project root, then into scripts/
54
+ return path.join(__dirname, '..', '..', 'scripts');
55
+ }
56
+ /**
57
+ * Strip markdown code blocks from AI response
58
+ */
59
+ function stripMarkdownCodeBlocks(content) {
60
+ let jsonContent = content.trim();
61
+ if (jsonContent.startsWith('```json')) {
62
+ jsonContent = jsonContent.replace(/^```json\s*/, '').replace(/\s*```$/, '');
63
+ }
64
+ else if (jsonContent.startsWith('```')) {
65
+ jsonContent = jsonContent.replace(/^```\s*/, '').replace(/\s*```$/, '');
66
+ }
67
+ return jsonContent;
68
+ }
@@ -4,7 +4,7 @@
4
4
  * Implements AIProvider interface using Anthropic SDK directly.
5
5
  * Supports streaming for long operations and debug logging.
6
6
  */
7
- import { AIProvider, AIResponse, AIProviderConfig } from '../ai-provider.interface';
7
+ import { AIProvider, AIResponse, AIProviderConfig, AITool, ToolExecutor, ToolLoopConfig, AgenticResult } from '../ai-provider.interface';
8
8
  export declare class AnthropicProvider implements AIProvider {
9
9
  private client;
10
10
  private apiKey;
@@ -15,18 +15,30 @@ export declare class AnthropicProvider implements AIProvider {
15
15
  getProviderType(): string;
16
16
  getDefaultModel(): string;
17
17
  isInitialized(): boolean;
18
+ sendMessage(message: string, operation?: string): Promise<AIResponse>;
18
19
  /**
19
- * Create debug directory if it doesn't exist
20
- */
21
- private ensureDebugDirectory;
22
- /**
23
- * Generate unique identifier for debug files with operation context
24
- */
25
- private generateDebugId;
26
- /**
27
- * Save AI interaction for debugging when DEBUG_DOT_AI=true
20
+ * Agentic tool loop implementation
21
+ *
22
+ * NOTE: This method is currently NOT USED in the codebase (as of PRD #136 completion).
23
+ *
24
+ * Analysis showed that SDK-based tool loops and JSON-based agentic loops are functionally
25
+ * equivalent - both allow AI to decide which tools to call and when to stop. The JSON-based
26
+ * approach we already use provides the same capabilities without the token overhead of
27
+ * tool schemas in every request.
28
+ *
29
+ * This implementation is kept for potential future use cases where SDK-managed tool loops
30
+ * might provide advantages (e.g., better provider-specific optimizations, simpler code for
31
+ * highly exploratory workflows).
32
+ *
33
+ * ONLY IMPLEMENTED IN ANTHROPIC PROVIDER - VercelAIProvider does not implement this method
34
+ * as it's not needed for current workflows. If you need toolLoop for other providers, you'll
35
+ * need to implement it there as well.
36
+ *
37
+ * See PRD #136 for full architecture analysis and decision rationale.
28
38
  */
29
- private debugLogInteraction;
30
- sendMessage(message: string, operation?: string): Promise<AIResponse>;
39
+ toolLoop(config: ToolLoopConfig): Promise<AgenticResult>;
40
+ sendMessageWithTools(message: string, tools: AITool[], toolExecutor: ToolExecutor, operation?: string): Promise<AIResponse & {
41
+ toolCalls?: any[];
42
+ }>;
31
43
  }
32
44
  //# sourceMappingURL=anthropic-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic-provider.d.ts","sourceRoot":"","sources":["../../../src/core/providers/anthropic-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EACL,UAAU,EACV,UAAU,EACV,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAElC,qBAAa,iBAAkB,YAAW,UAAU;IAClD,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,SAAS,CAAU;gBAEf,MAAM,EAAE,gBAAgB;IAWpC,OAA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