@xagent-ai/cli 1.3.5 ā 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +0 -4
- package/dist/agents.js.map +1 -1
- package/dist/ai-client/providers/anthropic.d.ts +4 -0
- package/dist/ai-client/providers/anthropic.d.ts.map +1 -1
- package/dist/ai-client/providers/anthropic.js +55 -2
- package/dist/ai-client/providers/anthropic.js.map +1 -1
- package/dist/ai-client/providers/openai.d.ts +4 -0
- package/dist/ai-client/providers/openai.d.ts.map +1 -1
- package/dist/ai-client/providers/openai.js +47 -0
- package/dist/ai-client/providers/openai.js.map +1 -1
- package/dist/ai-client/providers/remote.d.ts.map +1 -1
- package/dist/ai-client/providers/remote.js +34 -4
- package/dist/ai-client/providers/remote.js.map +1 -1
- package/dist/ai-client-factory.d.ts.map +1 -1
- package/dist/ai-client-factory.js +3 -0
- package/dist/ai-client-factory.js.map +1 -1
- package/dist/smart-approval.d.ts.map +1 -1
- package/dist/smart-approval.js +2 -1
- package/dist/smart-approval.js.map +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +7 -27
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
- package/src/agents.ts +0 -4
- package/src/ai-client/providers/anthropic.ts +62 -1
- package/src/ai-client/providers/openai.ts +56 -0
- package/src/ai-client/providers/remote.ts +43 -4
- package/src/ai-client-factory.ts +3 -0
- package/src/smart-approval.ts +2 -1
- package/src/tools.ts +8 -38
|
@@ -103,6 +103,10 @@ export class OpenAIProvider implements AIProvider {
|
|
|
103
103
|
return this.convertResponse(response.data, model);
|
|
104
104
|
}, retryConfig);
|
|
105
105
|
|
|
106
|
+
if (showDebug && result.data) {
|
|
107
|
+
this.debugResponse(result.data);
|
|
108
|
+
}
|
|
109
|
+
|
|
106
110
|
if (result.success) {
|
|
107
111
|
return result.data!;
|
|
108
112
|
}
|
|
@@ -304,9 +308,61 @@ export class OpenAIProvider implements AIProvider {
|
|
|
304
308
|
console.log(`š¦ Model: ${model}`);
|
|
305
309
|
console.log(`š¬ Messages: ${messages.length}`);
|
|
306
310
|
console.log('ā'.repeat(60));
|
|
311
|
+
|
|
312
|
+
// Print each message content
|
|
313
|
+
messages.forEach((msg, idx) => {
|
|
314
|
+
const role = msg.role || 'unknown';
|
|
315
|
+
const content = msg.content || '';
|
|
316
|
+
const reasoning = msg.reasoning_content ? `\n [Reasoning] ${msg.reasoning_content}` : '';
|
|
317
|
+
const toolCalls = msg.tool_calls ? `\n [Tool Calls] ${JSON.stringify(msg.tool_calls, null, 2)}` : '';
|
|
318
|
+
const toolCallId = msg.tool_call_id ? `\n [Tool Call ID] ${msg.tool_call_id}` : '';
|
|
319
|
+
|
|
320
|
+
console.log(`\n[${idx + 1}] Role: ${role}${reasoning}${toolCalls}${toolCallId}`);
|
|
321
|
+
if (content) {
|
|
322
|
+
// No truncation for system messages or any content
|
|
323
|
+
console.log(` Content: ${content}`);
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
|
|
307
327
|
console.log('\nš¤ Sending request...\n');
|
|
308
328
|
}
|
|
309
329
|
|
|
330
|
+
/**
|
|
331
|
+
* Debug response output
|
|
332
|
+
*/
|
|
333
|
+
private debugResponse(response: CompletionResponse): void {
|
|
334
|
+
console.log(`\nāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā`);
|
|
335
|
+
console.log(`ā AI RESPONSE DEBUG (OpenAI) ā`);
|
|
336
|
+
console.log(`āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā`);
|
|
337
|
+
console.log(`š ID: ${response.id}`);
|
|
338
|
+
console.log(`š¦ Model: ${response.model}`);
|
|
339
|
+
console.log(`ā±ļø Created: ${response.created}`);
|
|
340
|
+
console.log('ā'.repeat(60));
|
|
341
|
+
|
|
342
|
+
// Print each choice
|
|
343
|
+
response.choices?.forEach((choice, idx) => {
|
|
344
|
+
const msg = choice.message;
|
|
345
|
+
const content = msg?.content || '';
|
|
346
|
+
const reasoning = msg?.reasoning_content ? `\n [Reasoning] ${msg.reasoning_content}` : '';
|
|
347
|
+
const toolCalls = msg?.tool_calls ? `\n [Tool Calls] ${JSON.stringify(msg.tool_calls, null, 2)}` : '';
|
|
348
|
+
|
|
349
|
+
console.log(`\n[Choice ${idx}] Finish Reason: ${choice.finish_reason}${reasoning}${toolCalls}`);
|
|
350
|
+
if (content) {
|
|
351
|
+
// No truncation
|
|
352
|
+
console.log(` Content: ${content}`);
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
if (response.usage) {
|
|
357
|
+
console.log('\nš Usage:');
|
|
358
|
+
console.log(` Prompt tokens: ${response.usage.prompt_tokens}`);
|
|
359
|
+
console.log(` Completion tokens: ${response.usage.completion_tokens}`);
|
|
360
|
+
console.log(` Total tokens: ${response.usage.total_tokens}`);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
console.log('\nš„ Response received.\n');
|
|
364
|
+
}
|
|
365
|
+
|
|
310
366
|
/**
|
|
311
367
|
* Handle errors
|
|
312
368
|
*/
|
|
@@ -275,6 +275,22 @@ export class RemoteProvider implements AIProvider {
|
|
|
275
275
|
console.log(`š Base URL: ${this.webBaseUrl}`);
|
|
276
276
|
console.log(`š¬ Messages: ${messages.length}`);
|
|
277
277
|
console.log('ā'.repeat(60));
|
|
278
|
+
|
|
279
|
+
// Print each message content
|
|
280
|
+
messages.forEach((msg, idx) => {
|
|
281
|
+
const role = msg.role || 'unknown';
|
|
282
|
+
const content = msg.content || '';
|
|
283
|
+
const reasoning = msg.reasoning_content ? `\n [Reasoning] ${msg.reasoning_content}` : '';
|
|
284
|
+
const toolCalls = msg.tool_calls ? `\n [Tool Calls] ${JSON.stringify(msg.tool_calls, null, 2)}` : '';
|
|
285
|
+
const toolCallId = msg.tool_call_id ? `\n [Tool Call ID] ${msg.tool_call_id}` : '';
|
|
286
|
+
|
|
287
|
+
console.log(`\n[${idx + 1}] Role: ${role}${reasoning}${toolCalls}${toolCallId}`);
|
|
288
|
+
if (content) {
|
|
289
|
+
// No truncation
|
|
290
|
+
console.log(` Content: ${content}`);
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
|
|
278
294
|
console.log('\nš¤ Sending request to Remote API...\n');
|
|
279
295
|
}
|
|
280
296
|
|
|
@@ -285,11 +301,34 @@ export class RemoteProvider implements AIProvider {
|
|
|
285
301
|
console.log('\nāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā');
|
|
286
302
|
console.log('ā AI RESPONSE DEBUG (REMOTE) ā');
|
|
287
303
|
console.log('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā');
|
|
288
|
-
console.log(`š ID: remote-${Date.now()}`);
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
304
|
+
console.log(`š ID: ${data.id || `remote-${Date.now()}`}`);
|
|
305
|
+
|
|
306
|
+
const content = data?.message || data?.content || '';
|
|
307
|
+
const reasoning = data?.reasoning_content || data?.reasoningContent || '';
|
|
308
|
+
const toolCalls = data?.tool_calls || data?.toolCalls || [];
|
|
309
|
+
|
|
310
|
+
if (reasoning) {
|
|
311
|
+
console.log(`\nš Reasoning: ${reasoning}`);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (content) {
|
|
315
|
+
console.log(`\nš Content: ${content}`);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (toolCalls?.length) {
|
|
319
|
+
console.log(`\nš§ Tool calls: ${toolCalls.length}`);
|
|
320
|
+
toolCalls.forEach((tc: any, idx: number) => {
|
|
321
|
+
console.log(` [${idx + 1}] ${tc.function?.name || tc.name}: ${tc.function?.arguments || tc.arguments}`);
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (data?.usage) {
|
|
326
|
+
console.log('\nš Usage:');
|
|
327
|
+
console.log(` Prompt tokens: ${data.usage.prompt_tokens}`);
|
|
328
|
+
console.log(` Completion tokens: ${data.usage.completion_tokens}`);
|
|
329
|
+
console.log(` Total tokens: ${data.usage.total_tokens}`);
|
|
292
330
|
}
|
|
331
|
+
|
|
293
332
|
console.log('\nš„ Response received.\n');
|
|
294
333
|
}
|
|
295
334
|
|
package/src/ai-client-factory.ts
CHANGED
|
@@ -150,6 +150,7 @@ export function createAIClient(authConfig: AuthConfig): AIClientInterface {
|
|
|
150
150
|
type: 'remote',
|
|
151
151
|
authToken: authConfig.apiKey || '',
|
|
152
152
|
baseUrl: authConfig.xagentApiBaseUrl || 'https://app.xagent.cn',
|
|
153
|
+
showDebugInfo: authConfig.showAIDebugInfo,
|
|
153
154
|
};
|
|
154
155
|
} else if (authConfig.baseUrl?.includes('anthropic') ||
|
|
155
156
|
authConfig.baseUrl?.includes('minimax') ||
|
|
@@ -160,6 +161,7 @@ export function createAIClient(authConfig: AuthConfig): AIClientInterface {
|
|
|
160
161
|
apiKey: authConfig.apiKey || '',
|
|
161
162
|
baseUrl: authConfig.baseUrl || 'https://api.anthropic.com',
|
|
162
163
|
model: authConfig.modelName || 'claude-sonnet-4-20250514',
|
|
164
|
+
showDebugInfo: authConfig.showAIDebugInfo,
|
|
163
165
|
};
|
|
164
166
|
} else {
|
|
165
167
|
// Default to OpenAI compatible mode
|
|
@@ -168,6 +170,7 @@ export function createAIClient(authConfig: AuthConfig): AIClientInterface {
|
|
|
168
170
|
apiKey: authConfig.apiKey || '',
|
|
169
171
|
baseUrl: authConfig.baseUrl || 'https://api.openai.com/v1',
|
|
170
172
|
model: authConfig.modelName || 'gpt-4o',
|
|
173
|
+
showDebugInfo: authConfig.showAIDebugInfo,
|
|
171
174
|
};
|
|
172
175
|
}
|
|
173
176
|
|
package/src/smart-approval.ts
CHANGED
package/src/tools.ts
CHANGED
|
@@ -3525,6 +3525,14 @@ export class InvokeSkillTool implements Tool {
|
|
|
3525
3525
|
}> {
|
|
3526
3526
|
const { skillId, taskDescription, inputFile, outputFile, options } = params;
|
|
3527
3527
|
|
|
3528
|
+
// Validate required parameters
|
|
3529
|
+
if (!skillId || skillId.trim() === '') {
|
|
3530
|
+
throw new Error('Missing required parameter: skillId is required to invoke a skill');
|
|
3531
|
+
}
|
|
3532
|
+
if (!taskDescription || taskDescription.trim() === '') {
|
|
3533
|
+
throw new Error('Missing required parameter: taskDescription is required to invoke a skill');
|
|
3534
|
+
}
|
|
3535
|
+
|
|
3528
3536
|
try {
|
|
3529
3537
|
const { getSkillInvoker } = await import('./skill-invoker.js');
|
|
3530
3538
|
const skillInvoker = getSkillInvoker();
|
|
@@ -4470,44 +4478,6 @@ export class ToolRegistry {
|
|
|
4470
4478
|
if (executionMode === ExecutionMode.SMART) {
|
|
4471
4479
|
const debugMode = process.env.DEBUG === 'smart-approval';
|
|
4472
4480
|
|
|
4473
|
-
// task tool bypasses smart approval entirely
|
|
4474
|
-
if (toolName === 'task') {
|
|
4475
|
-
if (debugMode) {
|
|
4476
|
-
const { getLogger } = await import('./logger.js');
|
|
4477
|
-
const logger = getLogger();
|
|
4478
|
-
logger.debug(
|
|
4479
|
-
`[SmartApprovalEngine] Tool '${toolName}' bypassed smart approval completely`
|
|
4480
|
-
);
|
|
4481
|
-
}
|
|
4482
|
-
return await cancellationManager.withCancellation(
|
|
4483
|
-
tool.execute(params, executionMode),
|
|
4484
|
-
`tool-${toolName}`
|
|
4485
|
-
);
|
|
4486
|
-
}
|
|
4487
|
-
|
|
4488
|
-
// Remote mode (OAuth XAGENT): remote LLM has already approved the tool
|
|
4489
|
-
// Auto-approve InvokeSkill tools without local AI review
|
|
4490
|
-
const { getConfigManager } = await import('./config.js');
|
|
4491
|
-
const configManager = getConfigManager();
|
|
4492
|
-
const authConfig = configManager.getAuthConfig();
|
|
4493
|
-
const isRemoteMode = authConfig.type === AuthType.OAUTH_XAGENT;
|
|
4494
|
-
if (isRemoteMode && toolName === 'InvokeSkill') {
|
|
4495
|
-
console.log('');
|
|
4496
|
-
if (isSdkMode && sdkOutputAdapter) {
|
|
4497
|
-
sdkOutputAdapter.outputInfo(`[Smart Mode] Remote mode: tool '${toolName}' auto-approved (remote LLM already approved)`);
|
|
4498
|
-
} else {
|
|
4499
|
-
console.log('');
|
|
4500
|
-
console.log(
|
|
4501
|
-
`${indent}${colors.success(`ā
[Smart Mode] Remote mode: tool '${toolName}' auto-approved (remote LLM already approved)`)}`
|
|
4502
|
-
);
|
|
4503
|
-
console.log('');
|
|
4504
|
-
}
|
|
4505
|
-
return await cancellationManager.withCancellation(
|
|
4506
|
-
tool.execute(params, executionMode),
|
|
4507
|
-
`tool-${toolName}`
|
|
4508
|
-
);
|
|
4509
|
-
}
|
|
4510
|
-
|
|
4511
4481
|
const { getSmartApprovalEngine } = await import('./smart-approval.js');
|
|
4512
4482
|
|
|
4513
4483
|
const approvalEngine = getSmartApprovalEngine(debugMode);
|