@sowonai/crewx-cli 0.4.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +529 -0
- package/dist/ai-provider.service.d.ts +36 -0
- package/dist/ai-provider.service.js +191 -0
- package/dist/ai-provider.service.js.map +1 -0
- package/dist/ai.service.d.ts +57 -0
- package/dist/ai.service.js +628 -0
- package/dist/ai.service.js.map +1 -0
- package/dist/app.module.d.ts +5 -0
- package/dist/app.module.js +103 -0
- package/dist/app.module.js.map +1 -0
- package/dist/cli/agent.handler.d.ts +2 -0
- package/dist/cli/agent.handler.js +140 -0
- package/dist/cli/agent.handler.js.map +1 -0
- package/dist/cli/chat.handler.d.ts +19 -0
- package/dist/cli/chat.handler.js +431 -0
- package/dist/cli/chat.handler.js.map +1 -0
- package/dist/cli/cli.handler.d.ts +4 -0
- package/dist/cli/cli.handler.js +97 -0
- package/dist/cli/cli.handler.js.map +1 -0
- package/dist/cli/doctor.handler.d.ts +36 -0
- package/dist/cli/doctor.handler.js +382 -0
- package/dist/cli/doctor.handler.js.map +1 -0
- package/dist/cli/execute.handler.d.ts +2 -0
- package/dist/cli/execute.handler.js +319 -0
- package/dist/cli/execute.handler.js.map +1 -0
- package/dist/cli/help.handler.d.ts +2 -0
- package/dist/cli/help.handler.js +10 -0
- package/dist/cli/help.handler.js.map +1 -0
- package/dist/cli/init.handler.d.ts +26 -0
- package/dist/cli/init.handler.js +450 -0
- package/dist/cli/init.handler.js.map +1 -0
- package/dist/cli/mcp.handler.d.ts +3 -0
- package/dist/cli/mcp.handler.js +121 -0
- package/dist/cli/mcp.handler.js.map +1 -0
- package/dist/cli/query.handler.d.ts +2 -0
- package/dist/cli/query.handler.js +380 -0
- package/dist/cli/query.handler.js.map +1 -0
- package/dist/cli/templates.handler.d.ts +2 -0
- package/dist/cli/templates.handler.js +100 -0
- package/dist/cli/templates.handler.js.map +1 -0
- package/dist/cli-options.d.ts +29 -0
- package/dist/cli-options.js +234 -0
- package/dist/cli-options.js.map +1 -0
- package/dist/config/timeout.config.d.ts +14 -0
- package/dist/config/timeout.config.js +34 -0
- package/dist/config/timeout.config.js.map +1 -0
- package/dist/conversation/base-conversation-history.provider.d.ts +12 -0
- package/dist/conversation/base-conversation-history.provider.js +45 -0
- package/dist/conversation/base-conversation-history.provider.js.map +1 -0
- package/dist/conversation/cli-conversation-history.provider.d.ts +16 -0
- package/dist/conversation/cli-conversation-history.provider.js +111 -0
- package/dist/conversation/cli-conversation-history.provider.js.map +1 -0
- package/dist/conversation/conversation-provider.factory.d.ts +10 -0
- package/dist/conversation/conversation-provider.factory.js +50 -0
- package/dist/conversation/conversation-provider.factory.js.map +1 -0
- package/dist/conversation/index.d.ts +6 -0
- package/dist/conversation/index.js +27 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/conversation/slack-conversation-history.provider.d.ts +28 -0
- package/dist/conversation/slack-conversation-history.provider.js +278 -0
- package/dist/conversation/slack-conversation-history.provider.js.map +1 -0
- package/dist/crewx.tool.d.ts +332 -0
- package/dist/crewx.tool.js +1461 -0
- package/dist/crewx.tool.js.map +1 -0
- package/dist/guards/bearer-auth.guard.d.ts +7 -0
- package/dist/guards/bearer-auth.guard.js +44 -0
- package/dist/guards/bearer-auth.guard.js.map +1 -0
- package/dist/health.controller.d.ts +6 -0
- package/dist/health.controller.js +32 -0
- package/dist/health.controller.js.map +1 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +267 -0
- package/dist/main.js.map +1 -0
- package/dist/mcp.controller.d.ts +8 -0
- package/dist/mcp.controller.js +62 -0
- package/dist/mcp.controller.js.map +1 -0
- package/dist/project.service.d.ts +44 -0
- package/dist/project.service.js +299 -0
- package/dist/project.service.js.map +1 -0
- package/dist/providers/base-ai.provider.d.ts +50 -0
- package/dist/providers/base-ai.provider.js +624 -0
- package/dist/providers/base-ai.provider.js.map +1 -0
- package/dist/providers/claude.provider.d.ts +25 -0
- package/dist/providers/claude.provider.js +362 -0
- package/dist/providers/claude.provider.js.map +1 -0
- package/dist/providers/codex.provider.d.ts +17 -0
- package/dist/providers/codex.provider.js +99 -0
- package/dist/providers/codex.provider.js.map +1 -0
- package/dist/providers/copilot.provider.d.ts +25 -0
- package/dist/providers/copilot.provider.js +266 -0
- package/dist/providers/copilot.provider.js.map +1 -0
- package/dist/providers/dynamic-provider.factory.d.ts +55 -0
- package/dist/providers/dynamic-provider.factory.js +586 -0
- package/dist/providers/dynamic-provider.factory.js.map +1 -0
- package/dist/providers/gemini.provider.d.ts +22 -0
- package/dist/providers/gemini.provider.js +147 -0
- package/dist/providers/gemini.provider.js.map +1 -0
- package/dist/services/agent-loader.service.d.ts +29 -0
- package/dist/services/agent-loader.service.js +370 -0
- package/dist/services/agent-loader.service.js.map +1 -0
- package/dist/services/auth.service.d.ts +9 -0
- package/dist/services/auth.service.js +47 -0
- package/dist/services/auth.service.js.map +1 -0
- package/dist/services/config-validator.service.d.ts +28 -0
- package/dist/services/config-validator.service.js +467 -0
- package/dist/services/config-validator.service.js.map +1 -0
- package/dist/services/config.service.d.ts +45 -0
- package/dist/services/config.service.js +180 -0
- package/dist/services/config.service.js.map +1 -0
- package/dist/services/context-enhancement.service.d.ts +13 -0
- package/dist/services/context-enhancement.service.js +169 -0
- package/dist/services/context-enhancement.service.js.map +1 -0
- package/dist/services/document-loader.service.d.ts +16 -0
- package/dist/services/document-loader.service.js +137 -0
- package/dist/services/document-loader.service.js.map +1 -0
- package/dist/services/help.service.d.ts +5 -0
- package/dist/services/help.service.js +117 -0
- package/dist/services/help.service.js.map +1 -0
- package/dist/services/intelligent-compression.service.d.ts +20 -0
- package/dist/services/intelligent-compression.service.js +179 -0
- package/dist/services/intelligent-compression.service.js.map +1 -0
- package/dist/services/mcp-client.service.d.ts +26 -0
- package/dist/services/mcp-client.service.js +81 -0
- package/dist/services/mcp-client.service.js.map +1 -0
- package/dist/services/parallel-processing.service.d.ts +108 -0
- package/dist/services/parallel-processing.service.js +268 -0
- package/dist/services/parallel-processing.service.js.map +1 -0
- package/dist/services/remote-agent.service.d.ts +49 -0
- package/dist/services/remote-agent.service.js +215 -0
- package/dist/services/remote-agent.service.js.map +1 -0
- package/dist/services/result-formatter.service.d.ts +27 -0
- package/dist/services/result-formatter.service.js +126 -0
- package/dist/services/result-formatter.service.js.map +1 -0
- package/dist/services/task-management.service.d.ts +63 -0
- package/dist/services/task-management.service.js +272 -0
- package/dist/services/task-management.service.js.map +1 -0
- package/dist/services/template.service.d.ts +36 -0
- package/dist/services/template.service.js +195 -0
- package/dist/services/template.service.js.map +1 -0
- package/dist/services/tool-call.service.d.ts +53 -0
- package/dist/services/tool-call.service.js +1061 -0
- package/dist/services/tool-call.service.js.map +1 -0
- package/dist/slack/formatters/message.formatter.d.ts +25 -0
- package/dist/slack/formatters/message.formatter.js +246 -0
- package/dist/slack/formatters/message.formatter.js.map +1 -0
- package/dist/slack/slack-bot.d.ts +24 -0
- package/dist/slack/slack-bot.js +467 -0
- package/dist/slack/slack-bot.js.map +1 -0
- package/dist/stderr.logger.d.ts +8 -0
- package/dist/stderr.logger.js +26 -0
- package/dist/stderr.logger.js.map +1 -0
- package/dist/utils/config-utils.d.ts +15 -0
- package/dist/utils/config-utils.js +69 -0
- package/dist/utils/config-utils.js.map +1 -0
- package/dist/utils/mcp-installer.d.ts +20 -0
- package/dist/utils/mcp-installer.js +199 -0
- package/dist/utils/mcp-installer.js.map +1 -0
- package/dist/utils/mention-parser.d.ts +18 -0
- package/dist/utils/mention-parser.js +136 -0
- package/dist/utils/mention-parser.js.map +1 -0
- package/dist/utils/simple-security.d.ts +3 -0
- package/dist/utils/simple-security.js +20 -0
- package/dist/utils/simple-security.js.map +1 -0
- package/dist/utils/stdin-utils.d.ts +27 -0
- package/dist/utils/stdin-utils.js +130 -0
- package/dist/utils/stdin-utils.js.map +1 -0
- package/dist/utils/template-processor.d.ts +32 -0
- package/dist/utils/template-processor.js +202 -0
- package/dist/utils/template-processor.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +17 -0
- package/dist/version.js.map +1 -0
- package/package.json +122 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseAIProvider } from './base-ai.provider';
|
|
2
|
+
import { AIQueryOptions, AIResponse } from '@sowonai/crewx-sdk';
|
|
3
|
+
import { ToolCallService } from '../services/tool-call.service';
|
|
4
|
+
export declare class ClaudeProvider extends BaseAIProvider {
|
|
5
|
+
readonly name: "cli/claude";
|
|
6
|
+
constructor(toolCallService?: ToolCallService);
|
|
7
|
+
protected getCliCommand(): string;
|
|
8
|
+
protected getDefaultArgs(): string[];
|
|
9
|
+
protected getExecuteArgs(): string[];
|
|
10
|
+
protected getNotInstalledMessage(): string;
|
|
11
|
+
execute(prompt: string, options?: AIQueryOptions): Promise<AIResponse>;
|
|
12
|
+
parseProviderError(stderr: string, stdout: string): {
|
|
13
|
+
error: boolean;
|
|
14
|
+
message: string;
|
|
15
|
+
};
|
|
16
|
+
private buildPromptWithTools;
|
|
17
|
+
private buildFollowUpPrompt;
|
|
18
|
+
private parseJsonlResponse;
|
|
19
|
+
protected parseToolUse(content: string): {
|
|
20
|
+
isToolUse: boolean;
|
|
21
|
+
toolName?: string;
|
|
22
|
+
toolInput?: any;
|
|
23
|
+
};
|
|
24
|
+
queryWithTools(prompt: string, options?: AIQueryOptions, maxTurns?: number): Promise<AIResponse>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ClaudeProvider = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const base_ai_provider_1 = require("./base-ai.provider");
|
|
15
|
+
const crewx_sdk_1 = require("@sowonai/crewx-sdk");
|
|
16
|
+
const tool_call_service_1 = require("../services/tool-call.service");
|
|
17
|
+
let ClaudeProvider = class ClaudeProvider extends base_ai_provider_1.BaseAIProvider {
|
|
18
|
+
constructor(toolCallService) {
|
|
19
|
+
super('ClaudeProvider');
|
|
20
|
+
this.name = crewx_sdk_1.BuiltInProviders.CLAUDE;
|
|
21
|
+
if (toolCallService) {
|
|
22
|
+
this.setToolCallService(toolCallService);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
getCliCommand() {
|
|
26
|
+
return 'claude';
|
|
27
|
+
}
|
|
28
|
+
getDefaultArgs() {
|
|
29
|
+
return ['--verbose', '-p'];
|
|
30
|
+
}
|
|
31
|
+
getExecuteArgs() {
|
|
32
|
+
return ['--verbose', '-p'];
|
|
33
|
+
}
|
|
34
|
+
getNotInstalledMessage() {
|
|
35
|
+
return 'Claude CLI is not installed. Please install it from https://claude.ai/download.';
|
|
36
|
+
}
|
|
37
|
+
async execute(prompt, options = {}) {
|
|
38
|
+
if (this.toolCallService) {
|
|
39
|
+
this.logger.log('🔧 ClaudeProvider: Using queryWithTools in execute mode');
|
|
40
|
+
return this.queryWithTools(prompt, options);
|
|
41
|
+
}
|
|
42
|
+
this.logger.warn('⚠️ ClaudeProvider: ToolCallService not available, falling back to base execute');
|
|
43
|
+
return super.execute(prompt, options);
|
|
44
|
+
}
|
|
45
|
+
parseProviderError(stderr, stdout) {
|
|
46
|
+
const combinedOutput = stderr || stdout;
|
|
47
|
+
if (combinedOutput.includes('Session limit reached')) {
|
|
48
|
+
const resetMatch = combinedOutput.match(/resets (\d+(?::\d+)?(?:am|pm))/i);
|
|
49
|
+
const resetTime = resetMatch ? resetMatch[1] : 'later today';
|
|
50
|
+
return {
|
|
51
|
+
error: true,
|
|
52
|
+
message: `Claude Pro session limit reached. Your limit will reset at ${resetTime}. Please try again after the reset or use another AI agent (Gemini or Copilot) in the meantime.`,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (stderr && (stderr.includes('authentication required') || stderr.includes('Please run `claude login`'))) {
|
|
56
|
+
return {
|
|
57
|
+
error: true,
|
|
58
|
+
message: 'Claude CLI authentication required. Please run `claude login` to authenticate.',
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (stdout && stdout.trim().length > 0) {
|
|
62
|
+
return { error: false, message: '' };
|
|
63
|
+
}
|
|
64
|
+
if (stderr && stderr.trim().length > 0) {
|
|
65
|
+
const errorIndicators = [
|
|
66
|
+
/^Error:/im,
|
|
67
|
+
/^error:/im,
|
|
68
|
+
/^Failed:/im,
|
|
69
|
+
/^Unable to/im,
|
|
70
|
+
/unknown option/i,
|
|
71
|
+
/invalid option/i,
|
|
72
|
+
/command not found/i,
|
|
73
|
+
/no such file/i,
|
|
74
|
+
/permission denied/i,
|
|
75
|
+
/ECONNREFUSED/,
|
|
76
|
+
/ETIMEDOUT/,
|
|
77
|
+
/ENOTFOUND/,
|
|
78
|
+
/EHOSTUNREACH/,
|
|
79
|
+
/\bconnection refused\b/i,
|
|
80
|
+
/\bnetwork error\b/i,
|
|
81
|
+
/\brequest failed\b/i,
|
|
82
|
+
];
|
|
83
|
+
const debugLogPatterns = [
|
|
84
|
+
/follow-redirects options/,
|
|
85
|
+
/spawn-rx/,
|
|
86
|
+
/\[Function:/,
|
|
87
|
+
/connectionListener/,
|
|
88
|
+
/maxRedirects:/,
|
|
89
|
+
/\{[\s\S]*protocol:.*\}/,
|
|
90
|
+
];
|
|
91
|
+
const isDebugLog = debugLogPatterns.some(pattern => pattern.test(stderr));
|
|
92
|
+
if (isDebugLog) {
|
|
93
|
+
return { error: false, message: '' };
|
|
94
|
+
}
|
|
95
|
+
const hasError = errorIndicators.some(pattern => pattern.test(stderr));
|
|
96
|
+
if (hasError) {
|
|
97
|
+
const lines = stderr.split('\n');
|
|
98
|
+
const firstLine = lines[0]?.trim() || stderr.trim();
|
|
99
|
+
return { error: true, message: firstLine };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return { error: false, message: '' };
|
|
103
|
+
}
|
|
104
|
+
buildPromptWithTools(prompt, tools) {
|
|
105
|
+
if (!tools || tools.length === 0) {
|
|
106
|
+
return prompt;
|
|
107
|
+
}
|
|
108
|
+
return prompt;
|
|
109
|
+
}
|
|
110
|
+
buildFollowUpPrompt(toolName, toolInput, toolResult) {
|
|
111
|
+
const resultData = toolResult.success && toolResult.data ? toolResult.data : toolResult;
|
|
112
|
+
return `The ${toolName} tool has been executed successfully.
|
|
113
|
+
|
|
114
|
+
<tool_result>
|
|
115
|
+
${JSON.stringify(resultData, null, 2)}
|
|
116
|
+
</tool_result>
|
|
117
|
+
|
|
118
|
+
Based on the tool execution result above, please provide a clear, detailed, and user-friendly response to the user's original request. Present the information in an organized and easy-to-read format.`;
|
|
119
|
+
}
|
|
120
|
+
parseJsonlResponse(content) {
|
|
121
|
+
const lines = content.split('\n').filter(line => line.trim());
|
|
122
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
123
|
+
try {
|
|
124
|
+
const line = lines[i];
|
|
125
|
+
if (!line)
|
|
126
|
+
continue;
|
|
127
|
+
const parsed = JSON.parse(line);
|
|
128
|
+
if (parsed.type === 'result' && parsed.result) {
|
|
129
|
+
this.logger.log('✅ Extracted final result from JSONL');
|
|
130
|
+
return parsed.result;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
catch (e) {
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
this.logger.warn('⚠️ Could not parse JSONL, returning original content');
|
|
137
|
+
return content;
|
|
138
|
+
}
|
|
139
|
+
parseToolUse(content) {
|
|
140
|
+
const xmlMatch = content.match(/<crew(?:code|x)_tool_call>\s*([\s\S]*?)\s*<\/crew(?:code|x)_tool_call>/);
|
|
141
|
+
if (xmlMatch && xmlMatch[1]) {
|
|
142
|
+
try {
|
|
143
|
+
const jsonContent = xmlMatch[1].trim();
|
|
144
|
+
const parsed = JSON.parse(jsonContent);
|
|
145
|
+
if (parsed.type === 'tool_use' && parsed.name && parsed.input) {
|
|
146
|
+
this.logger.log(`Tool use detected from XML: ${parsed.name} with input ${JSON.stringify(parsed.input)}`);
|
|
147
|
+
return {
|
|
148
|
+
isToolUse: true,
|
|
149
|
+
toolName: parsed.name,
|
|
150
|
+
toolInput: parsed.input,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch (e) {
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const lines = content.split('\n').filter(line => line.trim());
|
|
158
|
+
for (const line of lines) {
|
|
159
|
+
try {
|
|
160
|
+
const parsed = JSON.parse(line);
|
|
161
|
+
if (parsed.type === 'result' && parsed.result) {
|
|
162
|
+
const xmlMatch = parsed.result.match(/<crew(?:code|x)_tool_call>\s*([\s\S]*?)\s*<\/crew(?:code|x)_tool_call>/);
|
|
163
|
+
if (xmlMatch && xmlMatch[1]) {
|
|
164
|
+
const toolCallJson = JSON.parse(xmlMatch[1].trim());
|
|
165
|
+
if (toolCallJson.type === 'tool_use' && toolCallJson.name && toolCallJson.input) {
|
|
166
|
+
this.logger.log(`Tool use detected from result XML: ${toolCallJson.name}`);
|
|
167
|
+
return {
|
|
168
|
+
isToolUse: true,
|
|
169
|
+
toolName: toolCallJson.name,
|
|
170
|
+
toolInput: toolCallJson.input,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (parsed.type === 'assistant' && parsed.message?.content) {
|
|
176
|
+
const content = parsed.message.content;
|
|
177
|
+
if (Array.isArray(content)) {
|
|
178
|
+
for (const item of content) {
|
|
179
|
+
if (item.type === 'text' && item.text) {
|
|
180
|
+
const xmlMatch = item.text.match(/<crew(?:code|x)_tool_call>\s*([\s\S]*?)\s*<\/crew(?:code|x)_tool_call>/);
|
|
181
|
+
if (xmlMatch && xmlMatch[1]) {
|
|
182
|
+
const toolCallJson = JSON.parse(xmlMatch[1].trim());
|
|
183
|
+
if (toolCallJson.type === 'tool_use' && toolCallJson.name && toolCallJson.input) {
|
|
184
|
+
this.logger.log(`Tool use detected from assistant message: ${toolCallJson.name}`);
|
|
185
|
+
return {
|
|
186
|
+
isToolUse: true,
|
|
187
|
+
toolName: toolCallJson.name,
|
|
188
|
+
toolInput: toolCallJson.input,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
const jsonBlockMatch = item.text.match(/```json\s*([\s\S]*?)\s*```/);
|
|
193
|
+
if (jsonBlockMatch && jsonBlockMatch[1]) {
|
|
194
|
+
try {
|
|
195
|
+
const toolCallJson = JSON.parse(jsonBlockMatch[1].trim());
|
|
196
|
+
if (toolCallJson.type === 'tool_use' && toolCallJson.name && toolCallJson.input) {
|
|
197
|
+
this.logger.log(`Tool use detected from JSON code block: ${toolCallJson.name}`);
|
|
198
|
+
return {
|
|
199
|
+
isToolUse: true,
|
|
200
|
+
toolName: toolCallJson.name,
|
|
201
|
+
toolInput: toolCallJson.input,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
catch (e) {
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (parsed.type === 'result' && parsed.result) {
|
|
213
|
+
const jsonBlockMatch = parsed.result.match(/```json\s*([\s\S]*?)\s*```/);
|
|
214
|
+
if (jsonBlockMatch && jsonBlockMatch[1]) {
|
|
215
|
+
try {
|
|
216
|
+
const toolCallJson = JSON.parse(jsonBlockMatch[1].trim());
|
|
217
|
+
if (toolCallJson.type === 'tool_use' && toolCallJson.name && toolCallJson.input) {
|
|
218
|
+
this.logger.log(`Tool use detected from result JSON block: ${toolCallJson.name}`);
|
|
219
|
+
return {
|
|
220
|
+
isToolUse: true,
|
|
221
|
+
toolName: toolCallJson.name,
|
|
222
|
+
toolInput: toolCallJson.input,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
catch (e) {
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
catch (e) {
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
const jsonObjectPattern = /\{[\s\S]*?"type"\s*:\s*"tool_use"[\s\S]*?\}/g;
|
|
235
|
+
const jsonMatches = content.match(jsonObjectPattern);
|
|
236
|
+
if (jsonMatches) {
|
|
237
|
+
for (const jsonMatch of jsonMatches) {
|
|
238
|
+
try {
|
|
239
|
+
const parsed = JSON.parse(jsonMatch);
|
|
240
|
+
if (parsed.type === 'tool_use' && parsed.name && parsed.input !== undefined) {
|
|
241
|
+
this.logger.log(`Tool use detected from plain text JSON: ${parsed.name}`);
|
|
242
|
+
return {
|
|
243
|
+
isToolUse: true,
|
|
244
|
+
toolName: parsed.name,
|
|
245
|
+
toolInput: parsed.input,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
catch (e) {
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
try {
|
|
254
|
+
const parsed = JSON.parse(content);
|
|
255
|
+
if (parsed.type === 'tool_use' && parsed.name && parsed.input) {
|
|
256
|
+
return {
|
|
257
|
+
isToolUse: true,
|
|
258
|
+
toolName: parsed.name,
|
|
259
|
+
toolInput: parsed.input,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
if (parsed.content && Array.isArray(parsed.content)) {
|
|
263
|
+
const toolUse = parsed.content.find((c) => c.type === 'tool_use');
|
|
264
|
+
if (toolUse) {
|
|
265
|
+
return {
|
|
266
|
+
isToolUse: true,
|
|
267
|
+
toolName: toolUse.name,
|
|
268
|
+
toolInput: toolUse.input,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (parsed.stop_reason === 'tool_use' && parsed.content) {
|
|
273
|
+
const content = Array.isArray(parsed.content) ? parsed.content : [parsed.content];
|
|
274
|
+
const toolUse = content.find((c) => c.type === 'tool_use');
|
|
275
|
+
if (toolUse) {
|
|
276
|
+
return {
|
|
277
|
+
isToolUse: true,
|
|
278
|
+
toolName: toolUse.name,
|
|
279
|
+
toolInput: toolUse.input,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
catch (error) {
|
|
285
|
+
}
|
|
286
|
+
return { isToolUse: false };
|
|
287
|
+
}
|
|
288
|
+
async queryWithTools(prompt, options = {}, maxTurns = 5) {
|
|
289
|
+
if (!this.toolCallService) {
|
|
290
|
+
this.logger.warn('ToolCallService not available, falling back to regular query');
|
|
291
|
+
return this.query(prompt, options);
|
|
292
|
+
}
|
|
293
|
+
let turn = 0;
|
|
294
|
+
let currentPrompt = prompt;
|
|
295
|
+
const tools = this.toolCallService.list();
|
|
296
|
+
currentPrompt = this.buildPromptWithTools(currentPrompt, tools);
|
|
297
|
+
while (turn < maxTurns) {
|
|
298
|
+
this.logger.log(`Tool call turn ${turn + 1}/${maxTurns}`);
|
|
299
|
+
if (options.taskId) {
|
|
300
|
+
this['appendTaskLog'](options.taskId, 'INFO', `--- Tool Call Turn ${turn + 1}/${maxTurns} ---`);
|
|
301
|
+
}
|
|
302
|
+
const response = await this.query(currentPrompt, options);
|
|
303
|
+
if (!response.success) {
|
|
304
|
+
return response;
|
|
305
|
+
}
|
|
306
|
+
const toolUse = this.parseToolUse(response.content);
|
|
307
|
+
this.logger.log(`Tool use check result: ${JSON.stringify(toolUse)}`);
|
|
308
|
+
if (!toolUse.isToolUse) {
|
|
309
|
+
this.logger.log('No tool use detected, returning response');
|
|
310
|
+
if (options.taskId) {
|
|
311
|
+
this['appendTaskLog'](options.taskId, 'INFO', `No tool use detected, returning final response`);
|
|
312
|
+
}
|
|
313
|
+
const parsedContent = this.parseJsonlResponse(response.content);
|
|
314
|
+
return {
|
|
315
|
+
...response,
|
|
316
|
+
content: parsedContent,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
this.logger.log(`Executing tool: ${toolUse.toolName}`);
|
|
320
|
+
if (options.taskId) {
|
|
321
|
+
this['appendTaskLog'](options.taskId, 'INFO', `🔧 Claude requested tool: ${toolUse.toolName}`);
|
|
322
|
+
this['appendTaskLog'](options.taskId, 'INFO', `Tool input: ${JSON.stringify(toolUse.toolInput, null, 2)}`);
|
|
323
|
+
}
|
|
324
|
+
try {
|
|
325
|
+
const toolResult = await this.toolCallService.execute(toolUse.toolName, toolUse.toolInput);
|
|
326
|
+
this.logger.log(`Tool executed successfully: ${toolUse.toolName}`);
|
|
327
|
+
if (options.taskId) {
|
|
328
|
+
this['appendTaskLog'](options.taskId, 'INFO', `✅ Tool executed successfully`);
|
|
329
|
+
this['appendTaskLog'](options.taskId, 'INFO', `Tool result preview: ${JSON.stringify(toolResult).substring(0, 500)}...`);
|
|
330
|
+
}
|
|
331
|
+
currentPrompt = this.buildFollowUpPrompt(toolUse.toolName, toolUse.toolInput, toolResult);
|
|
332
|
+
turn++;
|
|
333
|
+
}
|
|
334
|
+
catch (error) {
|
|
335
|
+
this.logger.error(`Tool execution failed: ${error.message}`);
|
|
336
|
+
return {
|
|
337
|
+
content: '',
|
|
338
|
+
provider: this.name,
|
|
339
|
+
command: response.command,
|
|
340
|
+
success: false,
|
|
341
|
+
error: `Tool execution failed: ${error.message}`,
|
|
342
|
+
taskId: response.taskId,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
this.logger.error(`Max tool call turns (${maxTurns}) exceeded`);
|
|
347
|
+
return {
|
|
348
|
+
content: '',
|
|
349
|
+
provider: this.name,
|
|
350
|
+
command: `${this.getCliCommand()} (max turns exceeded)`,
|
|
351
|
+
success: false,
|
|
352
|
+
error: `Maximum tool call iterations (${maxTurns}) exceeded`,
|
|
353
|
+
taskId: options.taskId,
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
exports.ClaudeProvider = ClaudeProvider;
|
|
358
|
+
exports.ClaudeProvider = ClaudeProvider = __decorate([
|
|
359
|
+
(0, common_1.Injectable)(),
|
|
360
|
+
__metadata("design:paramtypes", [tool_call_service_1.ToolCallService])
|
|
361
|
+
], ClaudeProvider);
|
|
362
|
+
//# sourceMappingURL=claude.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude.provider.js","sourceRoot":"","sources":["../../src/providers/claude.provider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,yDAAoD;AACpD,kDAAkF;AAClF,qEAAsE;AAG/D,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,iCAAc;IAGhD,YAAY,eAAiC;QAC3C,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAHjB,SAAI,GAAG,4BAAgB,CAAC,MAAM,CAAC;QAItC,IAAI,eAAe,EAAE,CAAC;YACpB,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IAES,aAAa;QACrB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAES,cAAc;QACtB,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;IAES,cAAc;QAEtB,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;IAES,sBAAsB;QAC9B,OAAO,iFAAiF,CAAC;IAC3F,CAAC;IAKD,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,UAA0B,EAAE;QACxD,IAAI,IAAI,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ider';
|
|
2
|
+
export declare class CodexProvider extends BaseAIProvider {
|
|
3
|
+
readonly name = "cli/codex";
|
|
4
|
+
constructor();
|
|
5
|
+
protected getCliCommand(): string;
|
|
6
|
+
protected getDefaultArgs(): string[];
|
|
7
|
+
protected getExecuteArgs(): string[];
|
|
8
|
+
protected getNotInstalledMessage(): string;
|
|
9
|
+
protected getPromptInArgs(): boolean;
|
|
10
|
+
protected shouldPipeContext(): boolean;
|
|
11
|
+
parseProviderError(stderr: string, stdout: string): {
|
|
12
|
+
error: boolean;
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
private extractAssistantMessage;
|
|
16
|
+
protected filterToolUseFromResponse(content: string): string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CodexProvider = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const base_ai_provider_1 = require("./base-ai.provider");
|
|
15
|
+
let CodexProvider = class CodexProvider extends base_ai_provider_1.BaseAIProvider {
|
|
16
|
+
constructor() {
|
|
17
|
+
super('CodexProvider');
|
|
18
|
+
this.name = 'cli/codex';
|
|
19
|
+
}
|
|
20
|
+
getCliCommand() {
|
|
21
|
+
return 'codex';
|
|
22
|
+
}
|
|
23
|
+
getDefaultArgs() {
|
|
24
|
+
return ['exec', '--experimental-json'];
|
|
25
|
+
}
|
|
26
|
+
getExecuteArgs() {
|
|
27
|
+
return ['exec', '-s', 'workspace-write', '--experimental-json'];
|
|
28
|
+
}
|
|
29
|
+
getNotInstalledMessage() {
|
|
30
|
+
return 'Codex CLI is not installed. Please install it first.';
|
|
31
|
+
}
|
|
32
|
+
getPromptInArgs() {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
shouldPipeContext() {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
parseProviderError(stderr, stdout) {
|
|
39
|
+
if (stderr && (stderr.includes('not logged in') || stderr.includes('authentication required'))) {
|
|
40
|
+
return {
|
|
41
|
+
error: true,
|
|
42
|
+
message: 'Codex CLI authentication required. Please run `codex login` to authenticate.',
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (stderr && stderr.includes('rate limit')) {
|
|
46
|
+
return {
|
|
47
|
+
error: true,
|
|
48
|
+
message: 'Codex API rate limit reached. Please try again later.',
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (stdout && stdout.trim().length > 0) {
|
|
52
|
+
return { error: false, message: '' };
|
|
53
|
+
}
|
|
54
|
+
if (stderr && stderr.trim().length > 0) {
|
|
55
|
+
return { error: true, message: stderr.split('\n')[0]?.trim() || 'Unknown error' };
|
|
56
|
+
}
|
|
57
|
+
return super.parseProviderError(stderr, stdout);
|
|
58
|
+
}
|
|
59
|
+
extractAssistantMessage(content) {
|
|
60
|
+
const lines = content.split('\n').map(line => line.trim()).filter(Boolean);
|
|
61
|
+
let assistantMessage = null;
|
|
62
|
+
for (const line of lines) {
|
|
63
|
+
try {
|
|
64
|
+
const parsed = JSON.parse(line);
|
|
65
|
+
if (parsed?.item?.item_type === 'assistant_message' &&
|
|
66
|
+
typeof parsed.item.text === 'string') {
|
|
67
|
+
assistantMessage = parsed.item.text.trim();
|
|
68
|
+
}
|
|
69
|
+
else if (parsed?.response?.output &&
|
|
70
|
+
Array.isArray(parsed.response.output)) {
|
|
71
|
+
const assistantEntries = parsed.response.output.filter((entry) => entry?.item_type === 'assistant_message');
|
|
72
|
+
if (assistantEntries.length > 0) {
|
|
73
|
+
const lastMessage = assistantEntries[assistantEntries.length - 1];
|
|
74
|
+
if (lastMessage?.text) {
|
|
75
|
+
assistantMessage = String(lastMessage.text).trim();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return assistantMessage;
|
|
85
|
+
}
|
|
86
|
+
filterToolUseFromResponse(content) {
|
|
87
|
+
const assistantMessage = this.extractAssistantMessage(content);
|
|
88
|
+
if (assistantMessage) {
|
|
89
|
+
return assistantMessage;
|
|
90
|
+
}
|
|
91
|
+
return super.filterToolUseFromResponse(content);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
exports.CodexProvider = CodexProvider;
|
|
95
|
+
exports.CodexProvider = CodexProvider = __decorate([
|
|
96
|
+
(0, common_1.Injectable)(),
|
|
97
|
+
__metadata("design:paramtypes", [])
|
|
98
|
+
], CodexProvider);
|
|
99
|
+
//# sourceMappingURL=codex.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex.provider.js","sourceRoot":"","sources":["../../src/providers/codex.provider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,yDAAoD;AAG7C,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,iCAAc;IAG/C;QACE,KAAK,CAAC,eAAe,CAAC,CAAC;QAHhB,SAAI,GAAG,WAAW,CAAC;IAI5B,CAAC;IAES,aAAa;QACrB,OAAO,OAAO,CAAC;IACjB,CAAC;IAES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,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAKS,yBAAyB,CAAC,OAAe;QACjD,MAAM,gBAAgB,GAAG,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;QAC/D,IAAI,gBAAgB,EAAE,CAAC;YACrB,OAAO,gBAAgB,CAAC;QAC1B,CAAC;QACD,OAAO,KAAK,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;CAEF,CAAA;AA5HY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;;GACA,aAAa,CA4HzB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseAIProvider } from './base-ai.provider';
|
|
2
|
+
import { AIQueryOptions, AIResponse } from '@sowonai/crewx-sdk';
|
|
3
|
+
import { ToolCallService } from '../services/tool-call.service';
|
|
4
|
+
export declare class CopilotProvider extends BaseAIProvider {
|
|
5
|
+
readonly name: "cli/copilot";
|
|
6
|
+
constructor(toolCallService?: ToolCallService);
|
|
7
|
+
protected getCliCommand(): string;
|
|
8
|
+
protected getDefaultArgs(): string[];
|
|
9
|
+
protected getExecuteArgs(): string[];
|
|
10
|
+
protected getPromptInArgs(): boolean;
|
|
11
|
+
protected getNotInstalledMessage(): string;
|
|
12
|
+
execute(prompt: string, options?: AIQueryOptions): Promise<AIResponse>;
|
|
13
|
+
parseProviderError(stderr: string, stdout: string): {
|
|
14
|
+
error: boolean;
|
|
15
|
+
message: string;
|
|
16
|
+
};
|
|
17
|
+
private buildPromptWithTools;
|
|
18
|
+
private buildFollowUpPrompt;
|
|
19
|
+
protected parseToolUse(content: string): {
|
|
20
|
+
isToolUse: boolean;
|
|
21
|
+
toolName?: string;
|
|
22
|
+
toolInput?: any;
|
|
23
|
+
};
|
|
24
|
+
queryWithTools(prompt: string, options?: AIQueryOptions, maxTurns?: number): Promise<AIResponse>;
|
|
25
|
+
}
|