lua-cli 2.5.2 → 2.5.4
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/CLI_REFERENCE.md +90 -0
- package/INSTANCE_TYPES.md +1158 -0
- package/README.md +6 -0
- package/dist/api/agent.api.service.d.ts +52 -0
- package/dist/api/agent.api.service.js +63 -0
- package/dist/api/logs.api.service.d.ts +35 -0
- package/dist/api/logs.api.service.js +43 -0
- package/dist/cli/command-definitions.js +17 -1
- package/dist/commands/admin.d.ts +23 -0
- package/dist/commands/admin.js +62 -0
- package/dist/commands/channels.d.ts +17 -0
- package/dist/commands/channels.js +676 -0
- package/dist/commands/docs.d.ts +19 -0
- package/dist/commands/docs.js +30 -0
- package/dist/commands/index.d.ts +4 -0
- package/dist/commands/index.js +4 -0
- package/dist/commands/logs.d.ts +17 -0
- package/dist/commands/logs.js +271 -0
- package/dist/common/http.client.js +11 -1
- package/dist/common/user.instance.d.ts +4 -12
- package/dist/common/user.instance.js +5 -24
- package/dist/index.js +3 -0
- package/dist/interfaces/agent.d.ts +218 -0
- package/dist/interfaces/logs.d.ts +40 -0
- package/dist/interfaces/logs.js +5 -0
- package/package.json +3 -1
- package/template/package.json +1 -1
package/README.md
CHANGED
|
@@ -313,6 +313,12 @@ lua deploy # Deploy version to production
|
|
|
313
313
|
lua dev # Development mode with live reload
|
|
314
314
|
```
|
|
315
315
|
|
|
316
|
+
### Utilities
|
|
317
|
+
```bash
|
|
318
|
+
lua admin # Open Lua Admin Dashboard in browser
|
|
319
|
+
lua docs # Open documentation in browser
|
|
320
|
+
```
|
|
321
|
+
|
|
316
322
|
**See [CLI_REFERENCE.md](CLI_REFERENCE.md) for complete command documentation.**
|
|
317
323
|
|
|
318
324
|
---
|
|
@@ -5,6 +5,15 @@ import { AgentType } from "../interfaces/agent.js";
|
|
|
5
5
|
import { CreateAgentRequest } from "../interfaces/agent.js";
|
|
6
6
|
import { CreateAgentResponse } from "../interfaces/agent.js";
|
|
7
7
|
import { Agent } from "../interfaces/agent.js";
|
|
8
|
+
import { AgentChannelsResponse } from "../interfaces/agent.js";
|
|
9
|
+
import { CreateWhatsAppChannelRequest } from "../interfaces/agent.js";
|
|
10
|
+
import { CreateWhatsAppChannelResponse } from "../interfaces/agent.js";
|
|
11
|
+
import { CreateFacebookChannelRequest } from "../interfaces/agent.js";
|
|
12
|
+
import { CreateFacebookChannelResponse } from "../interfaces/agent.js";
|
|
13
|
+
import { CreateSlackChannelRequest } from "../interfaces/agent.js";
|
|
14
|
+
import { CreateSlackChannelResponse } from "../interfaces/agent.js";
|
|
15
|
+
import { CreateEmailChannelRequest } from "../interfaces/agent.js";
|
|
16
|
+
import { CreateEmailChannelResponse } from "../interfaces/agent.js";
|
|
8
17
|
/**
|
|
9
18
|
* Agent API calls
|
|
10
19
|
*/
|
|
@@ -42,4 +51,47 @@ export default class AgentApi extends HttpClient {
|
|
|
42
51
|
* @throws Error if the API request fails or the agent is not found
|
|
43
52
|
*/
|
|
44
53
|
getAgent(agentId: string): Promise<ApiResponse<Agent>>;
|
|
54
|
+
/**
|
|
55
|
+
* Retrieves all communication channels connected to a specific agent
|
|
56
|
+
* @param agentId - The unique identifier of the agent
|
|
57
|
+
* @returns Promise resolving to an ApiResponse containing channels and available channel links
|
|
58
|
+
* @throws Error if the API request fails or the agent is not found
|
|
59
|
+
*/
|
|
60
|
+
getAgentChannels(agentId: string): Promise<ApiResponse<AgentChannelsResponse>>;
|
|
61
|
+
/**
|
|
62
|
+
* Creates a new WhatsApp channel for a specific agent
|
|
63
|
+
* @param agentId - The unique identifier of the agent
|
|
64
|
+
* @param channelData - The WhatsApp channel configuration including phoneNumberId, wabaId, and accessToken
|
|
65
|
+
* @returns Promise resolving to an ApiResponse containing the created WhatsApp channel details
|
|
66
|
+
* @throws Error if the API request fails or the channel creation is unsuccessful
|
|
67
|
+
*/
|
|
68
|
+
createWhatsAppChannel(agentId: string, channelData: CreateWhatsAppChannelRequest): Promise<ApiResponse<CreateWhatsAppChannelResponse>>;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new Facebook Messenger channel for a specific agent
|
|
71
|
+
* @param agentId - The unique identifier of the agent
|
|
72
|
+
* @param channelData - The Facebook channel configuration including accessToken and pageId
|
|
73
|
+
* @returns Promise resolving to an ApiResponse containing the created Facebook channel details
|
|
74
|
+
* @throws Error if the API request fails or the channel creation is unsuccessful
|
|
75
|
+
*/
|
|
76
|
+
createFacebookChannel(agentId: string, channelData: CreateFacebookChannelRequest): Promise<ApiResponse<CreateFacebookChannelResponse>>;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a new Slack channel for a specific agent (supports both private and public channels)
|
|
79
|
+
* @param agentId - The unique identifier of the agent
|
|
80
|
+
* @param channelData - The Slack channel configuration
|
|
81
|
+
* - For private: requires accessToken
|
|
82
|
+
* - For public: requires appId, clientId, and clientSecret
|
|
83
|
+
* @returns Promise resolving to an ApiResponse containing the created Slack channel details
|
|
84
|
+
* - Private channels return bot configuration and workspace details
|
|
85
|
+
* - Public channels return OAuth configuration and redirect URI
|
|
86
|
+
* @throws Error if the API request fails or the channel creation is unsuccessful
|
|
87
|
+
*/
|
|
88
|
+
createSlackChannel(agentId: string, channelData: CreateSlackChannelRequest): Promise<ApiResponse<CreateSlackChannelResponse>>;
|
|
89
|
+
/**
|
|
90
|
+
* Creates a new Email channel for a specific agent
|
|
91
|
+
* @param agentId - The unique identifier of the agent
|
|
92
|
+
* @param channelData - The Email channel configuration including sender name and email address
|
|
93
|
+
* @returns Promise resolving to an ApiResponse containing the forward-to email address
|
|
94
|
+
* @throws Error if the API request fails or the channel creation is unsuccessful
|
|
95
|
+
*/
|
|
96
|
+
createEmailChannel(agentId: string, channelData: CreateEmailChannelRequest): Promise<ApiResponse<CreateEmailChannelResponse>>;
|
|
45
97
|
}
|
|
@@ -54,4 +54,67 @@ export default class AgentApi extends HttpClient {
|
|
|
54
54
|
Authorization: `Bearer ${this.apiKey}`,
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Retrieves all communication channels connected to a specific agent
|
|
59
|
+
* @param agentId - The unique identifier of the agent
|
|
60
|
+
* @returns Promise resolving to an ApiResponse containing channels and available channel links
|
|
61
|
+
* @throws Error if the API request fails or the agent is not found
|
|
62
|
+
*/
|
|
63
|
+
async getAgentChannels(agentId) {
|
|
64
|
+
return this.httpGet(`/admin/agents/${agentId}/channels`, {
|
|
65
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Creates a new WhatsApp channel for a specific agent
|
|
70
|
+
* @param agentId - The unique identifier of the agent
|
|
71
|
+
* @param channelData - The WhatsApp channel configuration including phoneNumberId, wabaId, and accessToken
|
|
72
|
+
* @returns Promise resolving to an ApiResponse containing the created WhatsApp channel details
|
|
73
|
+
* @throws Error if the API request fails or the channel creation is unsuccessful
|
|
74
|
+
*/
|
|
75
|
+
async createWhatsAppChannel(agentId, channelData) {
|
|
76
|
+
return this.httpPost(`/admin/agents/${agentId}/channels`, channelData, {
|
|
77
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Creates a new Facebook Messenger channel for a specific agent
|
|
82
|
+
* @param agentId - The unique identifier of the agent
|
|
83
|
+
* @param channelData - The Facebook channel configuration including accessToken and pageId
|
|
84
|
+
* @returns Promise resolving to an ApiResponse containing the created Facebook channel details
|
|
85
|
+
* @throws Error if the API request fails or the channel creation is unsuccessful
|
|
86
|
+
*/
|
|
87
|
+
async createFacebookChannel(agentId, channelData) {
|
|
88
|
+
return this.httpPost(`/admin/agents/${agentId}/channels`, channelData, {
|
|
89
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Creates a new Slack channel for a specific agent (supports both private and public channels)
|
|
94
|
+
* @param agentId - The unique identifier of the agent
|
|
95
|
+
* @param channelData - The Slack channel configuration
|
|
96
|
+
* - For private: requires accessToken
|
|
97
|
+
* - For public: requires appId, clientId, and clientSecret
|
|
98
|
+
* @returns Promise resolving to an ApiResponse containing the created Slack channel details
|
|
99
|
+
* - Private channels return bot configuration and workspace details
|
|
100
|
+
* - Public channels return OAuth configuration and redirect URI
|
|
101
|
+
* @throws Error if the API request fails or the channel creation is unsuccessful
|
|
102
|
+
*/
|
|
103
|
+
async createSlackChannel(agentId, channelData) {
|
|
104
|
+
return this.httpPost(`/admin/agents/${agentId}/channels`, channelData, {
|
|
105
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Creates a new Email channel for a specific agent
|
|
110
|
+
* @param agentId - The unique identifier of the agent
|
|
111
|
+
* @param channelData - The Email channel configuration including sender name and email address
|
|
112
|
+
* @returns Promise resolving to an ApiResponse containing the forward-to email address
|
|
113
|
+
* @throws Error if the API request fails or the channel creation is unsuccessful
|
|
114
|
+
*/
|
|
115
|
+
async createEmailChannel(agentId, channelData) {
|
|
116
|
+
return this.httpPost(`/admin/agents/${agentId}/channels`, channelData, {
|
|
117
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
57
120
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logs API Service
|
|
3
|
+
* Handles log retrieval for agents and skills
|
|
4
|
+
*/
|
|
5
|
+
import { HttpClient } from "../common/http.client.js";
|
|
6
|
+
import { ApiResponse } from "../interfaces/common.js";
|
|
7
|
+
import { LogsResponse } from "../interfaces/logs.js";
|
|
8
|
+
export default class LogsApi extends HttpClient {
|
|
9
|
+
private apiKey;
|
|
10
|
+
/**
|
|
11
|
+
* Creates an instance of LogsApi
|
|
12
|
+
* @param baseUrl - The base URL for the API
|
|
13
|
+
* @param apiKey - The API key for authentication
|
|
14
|
+
*/
|
|
15
|
+
constructor(baseUrl: string, apiKey: string);
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves logs for an agent
|
|
18
|
+
* @param agentId - The unique identifier of the agent
|
|
19
|
+
* @param limit - Number of logs per page (default: 20)
|
|
20
|
+
* @param page - Page number (default: 1)
|
|
21
|
+
* @returns Promise resolving to an ApiResponse containing logs and pagination
|
|
22
|
+
* @throws Error if the API request fails
|
|
23
|
+
*/
|
|
24
|
+
getAgentLogs(agentId: string, limit?: number, page?: number): Promise<ApiResponse<LogsResponse>>;
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves logs for a specific skill
|
|
27
|
+
* @param agentId - The unique identifier of the agent
|
|
28
|
+
* @param skillId - The unique identifier of the skill
|
|
29
|
+
* @param limit - Number of logs per page (default: 20)
|
|
30
|
+
* @param page - Page number (default: 1)
|
|
31
|
+
* @returns Promise resolving to an ApiResponse containing logs and pagination
|
|
32
|
+
* @throws Error if the API request fails
|
|
33
|
+
*/
|
|
34
|
+
getSkillLogs(agentId: string, skillId: string, limit?: number, page?: number): Promise<ApiResponse<LogsResponse>>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logs API Service
|
|
3
|
+
* Handles log retrieval for agents and skills
|
|
4
|
+
*/
|
|
5
|
+
import { HttpClient } from "../common/http.client.js";
|
|
6
|
+
export default class LogsApi extends HttpClient {
|
|
7
|
+
/**
|
|
8
|
+
* Creates an instance of LogsApi
|
|
9
|
+
* @param baseUrl - The base URL for the API
|
|
10
|
+
* @param apiKey - The API key for authentication
|
|
11
|
+
*/
|
|
12
|
+
constructor(baseUrl, apiKey) {
|
|
13
|
+
super(baseUrl);
|
|
14
|
+
this.apiKey = apiKey;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves logs for an agent
|
|
18
|
+
* @param agentId - The unique identifier of the agent
|
|
19
|
+
* @param limit - Number of logs per page (default: 20)
|
|
20
|
+
* @param page - Page number (default: 1)
|
|
21
|
+
* @returns Promise resolving to an ApiResponse containing logs and pagination
|
|
22
|
+
* @throws Error if the API request fails
|
|
23
|
+
*/
|
|
24
|
+
async getAgentLogs(agentId, limit = 20, page = 1) {
|
|
25
|
+
return this.httpGet(`/developer/agents/${agentId}/logs?limit=${limit}&page=${page}`, {
|
|
26
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves logs for a specific skill
|
|
31
|
+
* @param agentId - The unique identifier of the agent
|
|
32
|
+
* @param skillId - The unique identifier of the skill
|
|
33
|
+
* @param limit - Number of logs per page (default: 20)
|
|
34
|
+
* @param page - Page number (default: 1)
|
|
35
|
+
* @returns Promise resolving to an ApiResponse containing logs and pagination
|
|
36
|
+
* @throws Error if the API request fails
|
|
37
|
+
*/
|
|
38
|
+
async getSkillLogs(agentId, skillId, limit = 20, page = 1) {
|
|
39
|
+
return this.httpGet(`/developer/skills/${agentId}/${skillId}/logs?limit=${limit}&page=${page}`, {
|
|
40
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Command Definitions
|
|
3
3
|
* Centralized command structure for the CLI
|
|
4
4
|
*/
|
|
5
|
-
import { configureCommand, initCommand, destroyCommand, apiKeyCommand, compileCommand, testCommand, pushCommand, deployCommand, chatCommand, chatClearCommand, envCommand, personaCommand, productionCommand, resourcesCommand } from "../commands/index.js";
|
|
5
|
+
import { configureCommand, initCommand, destroyCommand, apiKeyCommand, compileCommand, testCommand, pushCommand, deployCommand, chatCommand, chatClearCommand, envCommand, personaCommand, productionCommand, resourcesCommand, adminCommand, docsCommand, channelsCommand, logsCommand } from "../commands/index.js";
|
|
6
6
|
/**
|
|
7
7
|
* Sets up authentication-related commands.
|
|
8
8
|
*
|
|
@@ -101,4 +101,20 @@ Examples:
|
|
|
101
101
|
.command("resources")
|
|
102
102
|
.description("📚 Manage agent resources and knowledge base")
|
|
103
103
|
.action(resourcesCommand);
|
|
104
|
+
program
|
|
105
|
+
.command("admin")
|
|
106
|
+
.description("🔧 Open Lua Admin Dashboard in browser")
|
|
107
|
+
.action(adminCommand);
|
|
108
|
+
program
|
|
109
|
+
.command("docs")
|
|
110
|
+
.description("📖 Open Lua documentation in browser")
|
|
111
|
+
.action(docsCommand);
|
|
112
|
+
program
|
|
113
|
+
.command("channels")
|
|
114
|
+
.description("📡 Manage agent communication channels")
|
|
115
|
+
.action(channelsCommand);
|
|
116
|
+
program
|
|
117
|
+
.command("logs")
|
|
118
|
+
.description("📊 View agent and skill logs")
|
|
119
|
+
.action(logsCommand);
|
|
104
120
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin Command
|
|
3
|
+
* Opens the Lua Admin Dashboard in the user's default browser
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Admin command - opens the Lua admin dashboard in the browser.
|
|
7
|
+
*
|
|
8
|
+
* This command:
|
|
9
|
+
* 1. Loads the API key from secure storage
|
|
10
|
+
* 2. Reads the agent configuration (agentId and orgId)
|
|
11
|
+
* 3. Constructs the admin dashboard URL with authentication
|
|
12
|
+
* 4. Opens the URL in the user's default browser
|
|
13
|
+
*
|
|
14
|
+
* The admin dashboard provides access to:
|
|
15
|
+
* - Usage analytics and metrics
|
|
16
|
+
* - Agent configuration
|
|
17
|
+
* - Billing and subscription management
|
|
18
|
+
* - Team management
|
|
19
|
+
* - API key management
|
|
20
|
+
*
|
|
21
|
+
* @returns Promise that resolves when browser is launched
|
|
22
|
+
*/
|
|
23
|
+
export declare function adminCommand(): Promise<void>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin Command
|
|
3
|
+
* Opens the Lua Admin Dashboard in the user's default browser
|
|
4
|
+
*/
|
|
5
|
+
import open from 'open';
|
|
6
|
+
import { loadApiKey } from '../services/auth.js';
|
|
7
|
+
import { readSkillConfig } from '../utils/files.js';
|
|
8
|
+
import { withErrorHandling, writeSuccess, writeProgress } from '../utils/cli.js';
|
|
9
|
+
/**
|
|
10
|
+
* Admin command - opens the Lua admin dashboard in the browser.
|
|
11
|
+
*
|
|
12
|
+
* This command:
|
|
13
|
+
* 1. Loads the API key from secure storage
|
|
14
|
+
* 2. Reads the agent configuration (agentId and orgId)
|
|
15
|
+
* 3. Constructs the admin dashboard URL with authentication
|
|
16
|
+
* 4. Opens the URL in the user's default browser
|
|
17
|
+
*
|
|
18
|
+
* The admin dashboard provides access to:
|
|
19
|
+
* - Usage analytics and metrics
|
|
20
|
+
* - Agent configuration
|
|
21
|
+
* - Billing and subscription management
|
|
22
|
+
* - Team management
|
|
23
|
+
* - API key management
|
|
24
|
+
*
|
|
25
|
+
* @returns Promise that resolves when browser is launched
|
|
26
|
+
*/
|
|
27
|
+
export async function adminCommand() {
|
|
28
|
+
return withErrorHandling(async () => {
|
|
29
|
+
writeProgress('Opening Lua Admin Dashboard...');
|
|
30
|
+
// Load API key from secure storage
|
|
31
|
+
const apiKey = await loadApiKey();
|
|
32
|
+
if (!apiKey) {
|
|
33
|
+
throw new Error('No API key found. Please run "lua configure" first.');
|
|
34
|
+
}
|
|
35
|
+
// Read skill configuration
|
|
36
|
+
let config;
|
|
37
|
+
try {
|
|
38
|
+
config = readSkillConfig();
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
throw new Error('Could not read lua.skill.yaml. Please ensure you are in a Lua skill directory, or run "lua init" to create a new skill.');
|
|
42
|
+
}
|
|
43
|
+
// Extract agentId and orgId from config
|
|
44
|
+
const agentId = config?.agent?.agentId;
|
|
45
|
+
const orgId = config?.agent?.orgId;
|
|
46
|
+
if (!agentId) {
|
|
47
|
+
throw new Error('No agentId found in lua.skill.yaml. Please ensure your configuration is valid.');
|
|
48
|
+
}
|
|
49
|
+
if (!orgId) {
|
|
50
|
+
throw new Error('No orgId found in lua.skill.yaml. Please ensure your configuration is valid.');
|
|
51
|
+
}
|
|
52
|
+
// Construct the admin dashboard URL
|
|
53
|
+
// This URL authenticates with the API key and redirects to the usage page
|
|
54
|
+
const adminUrl = `https://admin.heylua.ai/validate-token/${apiKey}?redirect=/admin/usage?&agentId=${agentId}&orgId=${orgId}&hideToolBar=true`;
|
|
55
|
+
// Open the URL in the default browser
|
|
56
|
+
await open(adminUrl);
|
|
57
|
+
writeSuccess('Lua Admin Dashboard opened in your browser');
|
|
58
|
+
console.log(`\n Dashboard URL: https://admin.heylua.ai`);
|
|
59
|
+
console.log(` Agent ID: ${agentId}`);
|
|
60
|
+
console.log(` Organization ID: ${orgId}\n`);
|
|
61
|
+
}, 'admin');
|
|
62
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Channels Command
|
|
3
|
+
* Manages agent communication channels (list, create)
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Main channels command - manages agent communication channels.
|
|
7
|
+
*
|
|
8
|
+
* This command provides:
|
|
9
|
+
* 1. List all channels for an agent
|
|
10
|
+
* 2. Create new channels (WhatsApp, Facebook, Slack)
|
|
11
|
+
*
|
|
12
|
+
* The agent ID is automatically loaded from lua.skill.yaml
|
|
13
|
+
*
|
|
14
|
+
* @returns Promise that resolves when the operation is complete
|
|
15
|
+
* @throws Error if API key is not found or API call fails
|
|
16
|
+
*/
|
|
17
|
+
export declare function channelsCommand(): Promise<void>;
|