dexto 1.1.10 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +222 -84
- package/dist/agents/agent-registry.json +39 -1
- package/dist/agents/agent-template.yml +1 -1
- package/dist/agents/coding-agent/README.md +188 -0
- package/dist/agents/coding-agent/coding-agent.yml +203 -0
- package/dist/agents/database-agent/database-agent.yml +44 -2
- package/dist/agents/default-agent.yml +137 -13
- package/dist/agents/github-agent/github-agent.yml +42 -0
- package/dist/agents/image-editor-agent/image-editor-agent.yml +9 -2
- package/dist/agents/music-agent/README.md +1 -1
- package/dist/agents/music-agent/music-agent.yml +36 -2
- package/dist/agents/nano-banana-agent/nano-banana-agent.yml +35 -1
- package/dist/agents/podcast-agent/README.md +1 -1
- package/dist/agents/podcast-agent/podcast-agent.yml +37 -3
- package/dist/agents/product-name-researcher/product-name-researcher.yml +37 -1
- package/dist/agents/sora-video-agent/README.md +122 -0
- package/dist/agents/sora-video-agent/sora-video-agent.yml +98 -0
- package/dist/agents/talk2pdf-agent/talk2pdf-agent.yml +17 -2
- package/dist/agents/triage-demo/README.md +6 -6
- package/dist/agents/triage-demo/billing-agent.yml +1 -1
- package/dist/agents/triage-demo/escalation-agent.yml +1 -1
- package/dist/agents/triage-demo/product-info-agent.yml +1 -1
- package/dist/agents/triage-demo/technical-support-agent.yml +1 -1
- package/dist/agents/triage-demo/triage-agent.yml +16 -1
- package/dist/analytics/wrapper.d.ts.map +1 -1
- package/dist/analytics/wrapper.js +5 -3
- package/dist/api/a2a.d.ts +2 -2
- package/dist/api/a2a.d.ts.map +1 -1
- package/dist/api/a2a.js +3 -2
- package/dist/api/mcp/mcp_handler.d.ts +3 -3
- package/dist/api/mcp/mcp_handler.d.ts.map +1 -1
- package/dist/api/mcp/mcp_handler.js +7 -4
- package/dist/api/mcp/tool-aggregation-handler.d.ts.map +1 -1
- package/dist/api/mcp/tool-aggregation-handler.js +34 -42
- package/dist/api/memory/memory-handler.d.ts +18 -0
- package/dist/api/memory/memory-handler.d.ts.map +1 -0
- package/dist/api/memory/memory-handler.js +137 -0
- package/dist/api/middleware/errorHandler.d.ts.map +1 -1
- package/dist/api/middleware/errorHandler.js +2 -0
- package/dist/api/server.d.ts +2 -2
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +1129 -257
- package/dist/api/webhook-subscriber.d.ts.map +1 -1
- package/dist/api/webhook-subscriber.js +2 -1
- package/dist/api/websocket-subscriber.d.ts.map +1 -1
- package/dist/api/websocket-subscriber.js +67 -10
- package/dist/cli/cli-subscriber.d.ts +2 -1
- package/dist/cli/cli-subscriber.d.ts.map +1 -1
- package/dist/cli/cli-subscriber.js +11 -3
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +1 -0
- package/dist/cli/commands/install.d.ts +3 -3
- package/dist/cli/commands/install.d.ts.map +1 -1
- package/dist/cli/commands/install.js +223 -41
- package/dist/cli/commands/interactive-commands/model/model-commands.js +2 -2
- package/dist/cli/commands/interactive-commands/prompt-commands.d.ts +8 -1
- package/dist/cli/commands/interactive-commands/prompt-commands.d.ts.map +1 -1
- package/dist/cli/commands/interactive-commands/prompt-commands.js +252 -4
- package/dist/cli/commands/list-agents.d.ts.map +1 -1
- package/dist/cli/commands/list-agents.js +22 -3
- package/dist/cli/commands/setup.d.ts +4 -4
- package/dist/cli/commands/uninstall.d.ts +1 -1
- package/dist/cli/tool-confirmation/cli-confirmation-handler.d.ts +36 -7
- package/dist/cli/tool-confirmation/cli-confirmation-handler.d.ts.map +1 -1
- package/dist/cli/tool-confirmation/cli-confirmation-handler.js +314 -34
- package/dist/cli/utils/options.js +2 -2
- package/dist/index.js +117 -64
- package/dist/webui/.next/standalone/.next/static/chunks/419-6d449dcb2b056299.js +1 -0
- package/dist/webui/.next/standalone/.next/static/chunks/614-3519f8a6051e0088.js +1 -0
- package/dist/webui/.next/standalone/.next/static/chunks/656-5a9f6405badf66a8.js +25 -0
- package/dist/webui/.next/standalone/.next/static/chunks/765-755286dc586b1a51.js +1 -0
- package/dist/webui/.next/standalone/.next/static/chunks/804-f40df92a3adffcc0.js +1 -0
- package/dist/webui/.next/standalone/.next/static/chunks/854-232126f3c77e6c0b.js +1 -0
- package/dist/webui/.next/standalone/.next/static/chunks/app/chat/[sessionId]/page-a695b09e6bac5274.js +1 -0
- package/dist/webui/.next/standalone/.next/static/chunks/app/layout-f4a6ee5a028899d1.js +1 -0
- package/dist/webui/.next/standalone/.next/static/chunks/app/page-d1f127a0cac96246.js +1 -0
- package/dist/webui/.next/standalone/.next/static/chunks/app/playground/page-6f8d2abe76e51dfc.js +1 -0
- package/dist/webui/.next/standalone/.next/static/chunks/main-7decd42f62688419.js +1 -0
- package/dist/webui/.next/standalone/.next/static/chunks/{webpack-7c234e7e7e272295.js → webpack-7229fd0786f0483c.js} +1 -1
- package/dist/webui/.next/standalone/.next/static/css/c3c26ec984df1deb.css +1 -0
- package/dist/webui/.next/standalone/.next/static/css/de70bee13400563f.css +1 -0
- package/dist/webui/.next/standalone/.next/static/uqfH8SY_uhwdc0ZkpMwCO/_buildManifest.js +1 -0
- package/dist/webui/.next/standalone/package.json +7 -2
- package/dist/webui/.next/standalone/packages/webui/.next/BUILD_ID +1 -1
- package/dist/webui/.next/standalone/packages/webui/.next/app-build-manifest.json +30 -15
- package/dist/webui/.next/standalone/packages/webui/.next/app-path-routes-manifest.json +1 -0
- package/dist/webui/.next/standalone/packages/webui/.next/build-manifest.json +7 -7
- package/dist/webui/.next/standalone/packages/webui/.next/prerender-manifest.json +3 -3
- package/dist/webui/.next/standalone/packages/webui/.next/required-server-files.json +1 -11
- package/dist/webui/.next/standalone/packages/webui/.next/routes-manifest.json +11 -8
- package/dist/webui/.next/standalone/packages/webui/.next/server/app/_not-found/page.js +1 -1
- package/dist/webui/.next/standalone/packages/webui/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/dist/webui/.next/standalone/packages/webui/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/webui/.next/standalone/packages/webui/.next/server/app/chat/[sessionId]/page.js +2 -0
- package/dist/webui/.next/standalone/packages/webui/.next/server/app/chat/[sessionId]/page.js.nft.json +1 -0
- package/dist/webui/.next/standalone/packages/webui/.next/server/app/chat/[sessionId]/page_client-reference-manifest.js +1 -0
- package/dist/webui/.next/standalone/packages/webui/.next/server/app/page.js +2 -11
- package/dist/webui/.next/standalone/packages/webui/.next/server/app/page.js.nft.json +1 -1
- package/dist/webui/.next/standalone/packages/webui/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/webui/.next/standalone/packages/webui/.next/server/app/playground/page.js +4 -8
- package/dist/webui/.next/standalone/packages/webui/.next/server/app/playground/page.js.nft.json +1 -1
- package/dist/webui/.next/standalone/packages/webui/.next/server/app/playground/page_client-reference-manifest.js +1 -1
- package/dist/webui/.next/standalone/packages/webui/.next/server/app-paths-manifest.json +1 -0
- package/dist/webui/.next/standalone/packages/webui/.next/server/chunks/1.js +12 -0
- package/dist/webui/.next/standalone/packages/webui/.next/server/chunks/102.js +25 -0
- package/dist/webui/.next/standalone/packages/webui/.next/server/chunks/383.js +1 -0
- package/dist/webui/.next/standalone/packages/webui/.next/server/chunks/{619.js → 426.js} +2 -2
- package/dist/webui/.next/standalone/packages/webui/.next/server/chunks/43.js +1 -1
- package/dist/webui/.next/standalone/packages/webui/.next/server/chunks/985.js +5 -0
- package/dist/webui/.next/standalone/packages/webui/.next/server/middleware-build-manifest.js +1 -1
- package/dist/webui/.next/standalone/packages/webui/.next/server/pages/500.html +1 -1
- package/dist/webui/.next/standalone/packages/webui/.next/server/server-reference-manifest.json +1 -1
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/419-6d449dcb2b056299.js +1 -0
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/614-3519f8a6051e0088.js +1 -0
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/656-5a9f6405badf66a8.js +25 -0
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/765-755286dc586b1a51.js +1 -0
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/804-f40df92a3adffcc0.js +1 -0
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/854-232126f3c77e6c0b.js +1 -0
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/app/chat/[sessionId]/page-a695b09e6bac5274.js +1 -0
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/app/layout-f4a6ee5a028899d1.js +1 -0
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/app/page-d1f127a0cac96246.js +1 -0
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/app/playground/page-6f8d2abe76e51dfc.js +1 -0
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/main-7decd42f62688419.js +1 -0
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/{webpack-7c234e7e7e272295.js → webpack-7229fd0786f0483c.js} +1 -1
- package/dist/webui/.next/standalone/packages/webui/.next/static/css/c3c26ec984df1deb.css +1 -0
- package/dist/webui/.next/standalone/packages/webui/.next/static/css/de70bee13400563f.css +1 -0
- package/dist/webui/.next/standalone/packages/webui/.next/static/uqfH8SY_uhwdc0ZkpMwCO/_buildManifest.js +1 -0
- package/dist/webui/.next/standalone/packages/webui/package.json +11 -4
- package/dist/webui/.next/standalone/packages/webui/server.js +1 -1
- package/dist/webui/.next/static/chunks/419-6d449dcb2b056299.js +1 -0
- package/dist/webui/.next/static/chunks/614-3519f8a6051e0088.js +1 -0
- package/dist/webui/.next/static/chunks/656-5a9f6405badf66a8.js +25 -0
- package/dist/webui/.next/static/chunks/765-755286dc586b1a51.js +1 -0
- package/dist/webui/.next/static/chunks/804-f40df92a3adffcc0.js +1 -0
- package/dist/webui/.next/static/chunks/854-232126f3c77e6c0b.js +1 -0
- package/dist/webui/.next/static/chunks/app/chat/[sessionId]/page-a695b09e6bac5274.js +1 -0
- package/dist/webui/.next/static/chunks/app/layout-f4a6ee5a028899d1.js +1 -0
- package/dist/webui/.next/static/chunks/app/page-d1f127a0cac96246.js +1 -0
- package/dist/webui/.next/static/chunks/app/playground/page-6f8d2abe76e51dfc.js +1 -0
- package/dist/webui/.next/static/chunks/main-7decd42f62688419.js +1 -0
- package/dist/webui/.next/static/chunks/{webpack-7c234e7e7e272295.js → webpack-7229fd0786f0483c.js} +1 -1
- package/dist/webui/.next/static/css/c3c26ec984df1deb.css +1 -0
- package/dist/webui/.next/static/css/de70bee13400563f.css +1 -0
- package/dist/webui/.next/static/uqfH8SY_uhwdc0ZkpMwCO/_buildManifest.js +1 -0
- package/dist/webui/package.json +11 -4
- package/package.json +5 -4
- package/dist/webui/.next/standalone/.next/static/PvkEd_BO6ZXxX99T_gUvs/_buildManifest.js +0 -1
- package/dist/webui/.next/standalone/.next/static/chunks/179-78abc2eacbc41da9.js +0 -1
- package/dist/webui/.next/standalone/.next/static/chunks/442-b1916bec348454b3.js +0 -1
- package/dist/webui/.next/standalone/.next/static/chunks/544-c4a8f278ed1a25d7.js +0 -1
- package/dist/webui/.next/standalone/.next/static/chunks/854-2a6d5a5297a15d52.js +0 -1
- package/dist/webui/.next/standalone/.next/static/chunks/app/layout-dde711766eda096b.js +0 -1
- package/dist/webui/.next/standalone/.next/static/chunks/app/page-5e94d5a49dc718d0.js +0 -1
- package/dist/webui/.next/standalone/.next/static/chunks/app/playground/page-9ae40e0b219583e3.js +0 -1
- package/dist/webui/.next/standalone/.next/static/chunks/main-b65ece3506a2355c.js +0 -1
- package/dist/webui/.next/standalone/.next/static/css/045cc65741e38fbd.css +0 -3
- package/dist/webui/.next/standalone/packages/webui/.next/server/chunks/549.js +0 -1
- package/dist/webui/.next/standalone/packages/webui/.next/server/chunks/950.js +0 -5
- package/dist/webui/.next/standalone/packages/webui/.next/static/PvkEd_BO6ZXxX99T_gUvs/_buildManifest.js +0 -1
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/179-78abc2eacbc41da9.js +0 -1
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/442-b1916bec348454b3.js +0 -1
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/544-c4a8f278ed1a25d7.js +0 -1
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/854-2a6d5a5297a15d52.js +0 -1
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/app/layout-dde711766eda096b.js +0 -1
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/app/page-5e94d5a49dc718d0.js +0 -1
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/app/playground/page-9ae40e0b219583e3.js +0 -1
- package/dist/webui/.next/standalone/packages/webui/.next/static/chunks/main-b65ece3506a2355c.js +0 -1
- package/dist/webui/.next/standalone/packages/webui/.next/static/css/045cc65741e38fbd.css +0 -3
- package/dist/webui/.next/static/PvkEd_BO6ZXxX99T_gUvs/_buildManifest.js +0 -1
- package/dist/webui/.next/static/chunks/179-78abc2eacbc41da9.js +0 -1
- package/dist/webui/.next/static/chunks/442-b1916bec348454b3.js +0 -1
- package/dist/webui/.next/static/chunks/544-c4a8f278ed1a25d7.js +0 -1
- package/dist/webui/.next/static/chunks/854-2a6d5a5297a15d52.js +0 -1
- package/dist/webui/.next/static/chunks/app/layout-dde711766eda096b.js +0 -1
- package/dist/webui/.next/static/chunks/app/page-5e94d5a49dc718d0.js +0 -1
- package/dist/webui/.next/static/chunks/app/playground/page-9ae40e0b219583e3.js +0 -1
- package/dist/webui/.next/static/chunks/main-b65ece3506a2355c.js +0 -1
- package/dist/webui/.next/static/css/045cc65741e38fbd.css +0 -3
- /package/dist/webui/.next/standalone/.next/static/{PvkEd_BO6ZXxX99T_gUvs → uqfH8SY_uhwdc0ZkpMwCO}/_ssgManifest.js +0 -0
- /package/dist/webui/.next/standalone/packages/webui/.next/static/{PvkEd_BO6ZXxX99T_gUvs → uqfH8SY_uhwdc0ZkpMwCO}/_ssgManifest.js +0 -0
- /package/dist/webui/.next/static/{PvkEd_BO6ZXxX99T_gUvs → uqfH8SY_uhwdc0ZkpMwCO}/_ssgManifest.js +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { logger } from '@dexto/core';
|
|
1
|
+
import { logger, ApprovalType, ApprovalStatus } from '@dexto/core';
|
|
2
2
|
import * as readline from 'readline';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import boxen from 'boxen';
|
|
5
5
|
/**
|
|
6
|
-
* CLI-specific subscriber for
|
|
7
|
-
* Implements EventSubscriber pattern to listen to AgentEventBus for
|
|
6
|
+
* CLI-specific subscriber for approval events
|
|
7
|
+
* Implements EventSubscriber pattern to listen to AgentEventBus for approval requests
|
|
8
8
|
*/
|
|
9
9
|
export class CLIToolConfirmationSubscriber {
|
|
10
10
|
agentEventBus;
|
|
@@ -12,54 +12,334 @@ export class CLIToolConfirmationSubscriber {
|
|
|
12
12
|
// No configuration needed - CLI always shows interactive prompts
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Subscribe to
|
|
15
|
+
* Subscribe to approval events on the AgentEventBus
|
|
16
16
|
*/
|
|
17
17
|
subscribe(eventBus) {
|
|
18
18
|
this.agentEventBus = eventBus;
|
|
19
|
-
this.agentEventBus.on('dexto:
|
|
19
|
+
this.agentEventBus.on('dexto:approvalRequest', this.handleApprovalRequest.bind(this));
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* Handle
|
|
22
|
+
* Handle approval request events from the AgentEventBus
|
|
23
23
|
*/
|
|
24
|
-
async
|
|
24
|
+
async handleApprovalRequest(event) {
|
|
25
25
|
try {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
approved,
|
|
35
|
-
rememberChoice: false, // CLI won't persist choice
|
|
36
|
-
...(event.sessionId && { sessionId: event.sessionId }),
|
|
37
|
-
};
|
|
38
|
-
this.sendConfirmationResponse(response);
|
|
39
|
-
if (!approved) {
|
|
40
|
-
logger.warn(`Tool '${event.toolName}' execution denied`);
|
|
26
|
+
if (event.type === ApprovalType.TOOL_CONFIRMATION) {
|
|
27
|
+
await this.handleToolConfirmation(event);
|
|
28
|
+
}
|
|
29
|
+
else if (event.type === ApprovalType.ELICITATION) {
|
|
30
|
+
await this.handleElicitation(event);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
logger.debug(`[CLI] Ignoring unsupported approval type: ${event.type}`);
|
|
41
34
|
}
|
|
42
35
|
}
|
|
43
36
|
catch (error) {
|
|
44
|
-
|
|
37
|
+
// Use structured logging to preserve error stack and metadata
|
|
38
|
+
logger.error(`Error handling approval request: ${error instanceof Error ? error.message : String(error)}`, error instanceof Error ? { error } : undefined);
|
|
45
39
|
// Send denial response on error
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
const errorResponse = {
|
|
41
|
+
approvalId: event.approvalId,
|
|
42
|
+
status: ApprovalStatus.DENIED,
|
|
43
|
+
};
|
|
44
|
+
if (event.sessionId !== undefined) {
|
|
45
|
+
errorResponse.sessionId = event.sessionId;
|
|
46
|
+
}
|
|
47
|
+
this.sendApprovalResponse(errorResponse);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Handle tool confirmation approval
|
|
52
|
+
*/
|
|
53
|
+
async handleToolConfirmation(event) {
|
|
54
|
+
const toolMetadata = event.metadata;
|
|
55
|
+
logger.info(`Handling tool confirmation request for ${toolMetadata.toolName}, approvalId: ${event.approvalId}`);
|
|
56
|
+
// Display tool call using the logger's built-in method
|
|
57
|
+
logger.toolCall(toolMetadata.toolName, toolMetadata.args);
|
|
58
|
+
// Collect user input with arrow key navigation
|
|
59
|
+
const approved = await this.collectArrowKeyInput();
|
|
60
|
+
// Send response back via AgentEventBus
|
|
61
|
+
const response = {
|
|
62
|
+
approvalId: event.approvalId,
|
|
63
|
+
status: approved ? ApprovalStatus.APPROVED : ApprovalStatus.DENIED,
|
|
64
|
+
data: {
|
|
65
|
+
rememberChoice: false, // CLI won't persist choice
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
if (event.sessionId !== undefined) {
|
|
69
|
+
response.sessionId = event.sessionId;
|
|
70
|
+
}
|
|
71
|
+
this.sendApprovalResponse(response);
|
|
72
|
+
if (!approved) {
|
|
73
|
+
logger.warn(`Tool '${toolMetadata.toolName}' execution denied`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Handle elicitation approval (form-based input from MCP servers)
|
|
78
|
+
*/
|
|
79
|
+
async handleElicitation(event) {
|
|
80
|
+
const elicitationMetadata = event.metadata;
|
|
81
|
+
logger.info(`Handling elicitation request from MCP server '${elicitationMetadata.serverName}', approvalId: ${event.approvalId}`);
|
|
82
|
+
// Display the elicitation prompt
|
|
83
|
+
console.log('\n' +
|
|
84
|
+
boxen(chalk.cyan.bold('📝 Information Request from MCP Server'), {
|
|
85
|
+
padding: 1,
|
|
86
|
+
margin: 1,
|
|
87
|
+
borderStyle: 'round',
|
|
88
|
+
borderColor: 'cyan',
|
|
89
|
+
}));
|
|
90
|
+
console.log(chalk.white(`Server: ${chalk.yellow(elicitationMetadata.serverName)}`));
|
|
91
|
+
console.log(chalk.white(`Message: ${chalk.white(elicitationMetadata.prompt)}\n`));
|
|
92
|
+
// Collect form data based on schema
|
|
93
|
+
const formData = await this.collectFormData(elicitationMetadata.schema);
|
|
94
|
+
if (formData === null) {
|
|
95
|
+
// User cancelled
|
|
96
|
+
const cancelResponse = {
|
|
97
|
+
approvalId: event.approvalId,
|
|
98
|
+
status: ApprovalStatus.CANCELLED,
|
|
99
|
+
};
|
|
100
|
+
if (event.sessionId !== undefined) {
|
|
101
|
+
cancelResponse.sessionId = event.sessionId;
|
|
102
|
+
}
|
|
103
|
+
this.sendApprovalResponse(cancelResponse);
|
|
104
|
+
logger.info('Elicitation cancelled by user');
|
|
51
105
|
}
|
|
106
|
+
else {
|
|
107
|
+
// User provided data
|
|
108
|
+
const response = {
|
|
109
|
+
approvalId: event.approvalId,
|
|
110
|
+
status: ApprovalStatus.APPROVED,
|
|
111
|
+
data: { formData },
|
|
112
|
+
};
|
|
113
|
+
if (event.sessionId !== undefined) {
|
|
114
|
+
response.sessionId = event.sessionId;
|
|
115
|
+
}
|
|
116
|
+
this.sendApprovalResponse(response);
|
|
117
|
+
logger.info('Elicitation completed successfully');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Collect form data based on JSON Schema
|
|
122
|
+
* Returns null if user cancels
|
|
123
|
+
*/
|
|
124
|
+
async collectFormData(schema) {
|
|
125
|
+
const formData = {};
|
|
126
|
+
if (!schema.properties || typeof schema.properties !== 'object') {
|
|
127
|
+
logger.warn('Invalid schema: no properties found');
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
const properties = schema.properties;
|
|
131
|
+
const required = schema.required || [];
|
|
132
|
+
for (const [fieldName, fieldSchema] of Object.entries(properties)) {
|
|
133
|
+
const field = fieldSchema;
|
|
134
|
+
const isRequired = required.includes(fieldName);
|
|
135
|
+
const fieldType = field.type || 'string';
|
|
136
|
+
// Display field prompt
|
|
137
|
+
const requiredLabel = isRequired ? chalk.red('*') : '';
|
|
138
|
+
console.log(chalk.cyan(`${fieldName}${requiredLabel}`) +
|
|
139
|
+
(field.description ? chalk.gray(` - ${field.description}`) : ''));
|
|
140
|
+
// Collect input based on field type
|
|
141
|
+
let value;
|
|
142
|
+
if (fieldType === 'boolean') {
|
|
143
|
+
value = await this.collectBooleanInput(fieldName, isRequired);
|
|
144
|
+
}
|
|
145
|
+
else if (fieldType === 'number' || fieldType === 'integer') {
|
|
146
|
+
value = await this.collectNumberInput(fieldName, fieldType === 'integer', isRequired);
|
|
147
|
+
}
|
|
148
|
+
else if (field.enum && Array.isArray(field.enum)) {
|
|
149
|
+
value = await this.collectEnumInput(fieldName, field.enum, isRequired);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
// Default to string input
|
|
153
|
+
value = await this.collectStringInput(fieldName, isRequired);
|
|
154
|
+
}
|
|
155
|
+
if (value === null) {
|
|
156
|
+
// User cancelled
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
// Only assign if value is not undefined (allows skipping optional fields)
|
|
160
|
+
if (value !== undefined) {
|
|
161
|
+
formData[fieldName] = value;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return formData;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Collect string input from user
|
|
168
|
+
*/
|
|
169
|
+
collectStringInput(fieldName, required) {
|
|
170
|
+
return new Promise((resolve) => {
|
|
171
|
+
const rl = readline.createInterface({
|
|
172
|
+
input: process.stdin,
|
|
173
|
+
output: process.stdout,
|
|
174
|
+
});
|
|
175
|
+
const prompt = required
|
|
176
|
+
? `${fieldName}: `
|
|
177
|
+
: `${fieldName} (optional, press Enter to skip): `;
|
|
178
|
+
rl.question(prompt, (answer) => {
|
|
179
|
+
rl.close();
|
|
180
|
+
if (answer.toLowerCase() === 'cancel') {
|
|
181
|
+
resolve(null);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (!answer && required) {
|
|
185
|
+
console.log(chalk.red('This field is required'));
|
|
186
|
+
resolve(this.collectStringInput(fieldName, required));
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
// Return undefined for optional skipped fields, empty string for provided empty input
|
|
190
|
+
if (!answer && !required) {
|
|
191
|
+
resolve(undefined);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
resolve(answer);
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Collect boolean input from user (yes/no)
|
|
200
|
+
*/
|
|
201
|
+
collectBooleanInput(fieldName, required) {
|
|
202
|
+
return new Promise((resolve) => {
|
|
203
|
+
const rl = readline.createInterface({
|
|
204
|
+
input: process.stdin,
|
|
205
|
+
output: process.stdout,
|
|
206
|
+
});
|
|
207
|
+
const prompt = required
|
|
208
|
+
? `${fieldName} (yes/no): `
|
|
209
|
+
: `${fieldName} (yes/no, press Enter to skip): `;
|
|
210
|
+
rl.question(prompt, (answer) => {
|
|
211
|
+
rl.close();
|
|
212
|
+
if (answer.toLowerCase() === 'cancel') {
|
|
213
|
+
resolve(null);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const normalized = answer.toLowerCase().trim();
|
|
217
|
+
// Allow skipping optional fields
|
|
218
|
+
if (!normalized && !required) {
|
|
219
|
+
resolve(undefined);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (!normalized && required) {
|
|
223
|
+
console.log(chalk.red('This field is required'));
|
|
224
|
+
resolve(this.collectBooleanInput(fieldName, required));
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (normalized === 'yes' || normalized === 'y' || normalized === 'true') {
|
|
228
|
+
resolve(true);
|
|
229
|
+
}
|
|
230
|
+
else if (normalized === 'no' || normalized === 'n' || normalized === 'false') {
|
|
231
|
+
resolve(false);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
console.log(chalk.red('Please answer yes or no'));
|
|
235
|
+
resolve(this.collectBooleanInput(fieldName, required));
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Collect number input from user
|
|
242
|
+
*/
|
|
243
|
+
collectNumberInput(fieldName, integer, required) {
|
|
244
|
+
return new Promise((resolve) => {
|
|
245
|
+
const rl = readline.createInterface({
|
|
246
|
+
input: process.stdin,
|
|
247
|
+
output: process.stdout,
|
|
248
|
+
});
|
|
249
|
+
const type = integer ? 'integer' : 'number';
|
|
250
|
+
const prompt = required
|
|
251
|
+
? `${fieldName} (${type}): `
|
|
252
|
+
: `${fieldName} (${type}, press Enter to skip): `;
|
|
253
|
+
rl.question(prompt, (answer) => {
|
|
254
|
+
rl.close();
|
|
255
|
+
if (answer.toLowerCase() === 'cancel') {
|
|
256
|
+
resolve(null);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
// Allow skipping optional fields
|
|
260
|
+
if (!answer.trim() && !required) {
|
|
261
|
+
resolve(undefined);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (!answer.trim() && required) {
|
|
265
|
+
console.log(chalk.red('This field is required'));
|
|
266
|
+
resolve(this.collectNumberInput(fieldName, integer, required));
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const num = Number(answer);
|
|
270
|
+
if (isNaN(num)) {
|
|
271
|
+
console.log(chalk.red(`Please enter a valid ${type}`));
|
|
272
|
+
resolve(this.collectNumberInput(fieldName, integer, required));
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (integer && !Number.isInteger(num)) {
|
|
276
|
+
console.log(chalk.red('Please enter an integer'));
|
|
277
|
+
resolve(this.collectNumberInput(fieldName, integer, required));
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
resolve(num);
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Collect enum input from user (select from list)
|
|
286
|
+
*/
|
|
287
|
+
collectEnumInput(fieldName, options, required) {
|
|
288
|
+
return new Promise((resolve) => {
|
|
289
|
+
console.log(chalk.gray('Available options:'));
|
|
290
|
+
options.forEach((option, index) => {
|
|
291
|
+
console.log(chalk.gray(` ${index + 1}. ${option}`));
|
|
292
|
+
});
|
|
293
|
+
const rl = readline.createInterface({
|
|
294
|
+
input: process.stdin,
|
|
295
|
+
output: process.stdout,
|
|
296
|
+
});
|
|
297
|
+
const prompt = required
|
|
298
|
+
? `${fieldName} (enter number or value): `
|
|
299
|
+
: `${fieldName} (enter number or value, press Enter to skip): `;
|
|
300
|
+
rl.question(prompt, (answer) => {
|
|
301
|
+
rl.close();
|
|
302
|
+
if (answer.toLowerCase() === 'cancel') {
|
|
303
|
+
resolve(null);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
// Allow skipping optional fields
|
|
307
|
+
if (!answer.trim() && !required) {
|
|
308
|
+
resolve(undefined);
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
if (!answer.trim() && required) {
|
|
312
|
+
console.log(chalk.red('This field is required'));
|
|
313
|
+
resolve(this.collectEnumInput(fieldName, options, required));
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
// Try as index first
|
|
317
|
+
const index = parseInt(answer) - 1;
|
|
318
|
+
if (!isNaN(index) && index >= 0 && index < options.length) {
|
|
319
|
+
resolve(options[index]);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
// Try as direct value
|
|
323
|
+
const directMatch = options.find((opt) => String(opt) === answer);
|
|
324
|
+
if (directMatch !== undefined) {
|
|
325
|
+
resolve(directMatch);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
console.log(chalk.red('Invalid selection'));
|
|
329
|
+
resolve(this.collectEnumInput(fieldName, options, required));
|
|
330
|
+
});
|
|
331
|
+
});
|
|
52
332
|
}
|
|
53
333
|
/**
|
|
54
|
-
* Send
|
|
334
|
+
* Send approval response via AgentEventBus
|
|
55
335
|
*/
|
|
56
|
-
|
|
336
|
+
sendApprovalResponse(response) {
|
|
57
337
|
if (!this.agentEventBus) {
|
|
58
|
-
logger.error('AgentEventBus not available for sending
|
|
338
|
+
logger.error('AgentEventBus not available for sending approval response');
|
|
59
339
|
return;
|
|
60
340
|
}
|
|
61
|
-
logger.debug(`CLI sending
|
|
62
|
-
this.agentEventBus.emit('dexto:
|
|
341
|
+
logger.debug(`CLI sending approvalResponse for approvalId ${response.approvalId}, status=${response.status}, sessionId=${response.sessionId ?? 'global'}`);
|
|
342
|
+
this.agentEventBus.emit('dexto:approvalResponse', response);
|
|
63
343
|
}
|
|
64
344
|
/**
|
|
65
345
|
* Collect user input with arrow key navigation
|
|
@@ -155,7 +435,7 @@ export class CLIToolConfirmationSubscriber {
|
|
|
155
435
|
*/
|
|
156
436
|
cleanup() {
|
|
157
437
|
if (this.agentEventBus) {
|
|
158
|
-
this.agentEventBus.removeAllListeners('dexto:
|
|
438
|
+
this.agentEventBus.removeAllListeners('dexto:approvalRequest');
|
|
159
439
|
}
|
|
160
440
|
}
|
|
161
441
|
}
|
|
@@ -13,9 +13,9 @@ export function validateCliOptions(opts) {
|
|
|
13
13
|
agent: z.string().min(1, 'Agent name or path must not be empty').optional(),
|
|
14
14
|
strict: z.boolean().optional().default(false),
|
|
15
15
|
verbose: z.boolean().optional().default(true),
|
|
16
|
-
mode: z.enum(['
|
|
16
|
+
mode: z.enum(['web', 'cli', 'server', 'discord', 'telegram', 'mcp'], {
|
|
17
17
|
errorMap: () => ({
|
|
18
|
-
message: 'Mode must be one of "
|
|
18
|
+
message: 'Mode must be one of "web", "cli", "server", "discord", "telegram", or "mcp"',
|
|
19
19
|
}),
|
|
20
20
|
}),
|
|
21
21
|
webPort: z.string().refine((val) => {
|