lua-cli 2.5.8 → 3.0.0-alpha.10

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.
Files changed (121) hide show
  1. package/dist/api/chat.api.service.d.ts +8 -0
  2. package/dist/api/chat.api.service.js +50 -0
  3. package/dist/api/job.api.service.d.ts +219 -0
  4. package/dist/api/job.api.service.js +216 -0
  5. package/dist/api/lazy-instances.d.ts +24 -0
  6. package/dist/api/lazy-instances.js +48 -0
  7. package/dist/api/postprocessor.api.service.d.ts +158 -0
  8. package/dist/api/postprocessor.api.service.js +111 -0
  9. package/dist/api/preprocessor.api.service.d.ts +158 -0
  10. package/dist/api/preprocessor.api.service.js +111 -0
  11. package/dist/api/user.data.api.service.d.ts +13 -0
  12. package/dist/api/user.data.api.service.js +20 -0
  13. package/dist/api/webhook.api.service.d.ts +151 -0
  14. package/dist/api/webhook.api.service.js +134 -0
  15. package/dist/api-exports.d.ts +176 -41
  16. package/dist/api-exports.js +195 -21
  17. package/dist/cli/command-definitions.js +85 -8
  18. package/dist/commands/chat.js +73 -36
  19. package/dist/commands/compile.js +140 -7
  20. package/dist/commands/dev.js +23 -2
  21. package/dist/commands/index.d.ts +4 -0
  22. package/dist/commands/index.js +4 -0
  23. package/dist/commands/init.js +53 -7
  24. package/dist/commands/jobs.d.ts +20 -0
  25. package/dist/commands/jobs.js +533 -0
  26. package/dist/commands/logs.js +2 -5
  27. package/dist/commands/postprocessors.d.ts +8 -0
  28. package/dist/commands/postprocessors.js +431 -0
  29. package/dist/commands/preprocessors.d.ts +8 -0
  30. package/dist/commands/preprocessors.js +431 -0
  31. package/dist/commands/push.d.ts +3 -2
  32. package/dist/commands/push.js +1216 -7
  33. package/dist/commands/test.d.ts +9 -18
  34. package/dist/commands/test.js +574 -82
  35. package/dist/commands/webhooks.d.ts +18 -0
  36. package/dist/commands/webhooks.js +424 -0
  37. package/dist/common/job.instance.d.ts +80 -0
  38. package/dist/common/job.instance.js +116 -0
  39. package/dist/common/user.instance.d.ts +1 -0
  40. package/dist/common/user.instance.js +9 -0
  41. package/dist/config/constants.d.ts +4 -3
  42. package/dist/config/constants.js +10 -8
  43. package/dist/interfaces/agent.d.ts +2 -1
  44. package/dist/interfaces/chat.d.ts +52 -1
  45. package/dist/interfaces/index.d.ts +10 -0
  46. package/dist/interfaces/index.js +7 -0
  47. package/dist/interfaces/jobs.d.ts +193 -0
  48. package/dist/interfaces/jobs.js +5 -0
  49. package/dist/interfaces/postprocessors.d.ts +35 -0
  50. package/dist/interfaces/postprocessors.js +4 -0
  51. package/dist/interfaces/preprocessors.d.ts +35 -0
  52. package/dist/interfaces/preprocessors.js +4 -0
  53. package/dist/interfaces/webhooks.d.ts +104 -0
  54. package/dist/interfaces/webhooks.js +5 -0
  55. package/dist/services/auth.d.ts +8 -2
  56. package/dist/services/auth.js +35 -3
  57. package/dist/types/api-contracts.d.ts +5 -0
  58. package/dist/types/compile.types.d.ts +49 -0
  59. package/dist/types/index.d.ts +1 -1
  60. package/dist/types/index.js +1 -1
  61. package/dist/types/skill.d.ts +521 -0
  62. package/dist/types/skill.js +471 -0
  63. package/dist/utils/agent-management.d.ts +25 -0
  64. package/dist/utils/agent-management.js +67 -0
  65. package/dist/utils/bundling.d.ts +44 -5
  66. package/dist/utils/bundling.js +723 -23
  67. package/dist/utils/compile.d.ts +63 -0
  68. package/dist/utils/compile.js +712 -36
  69. package/dist/utils/deployment.d.ts +2 -1
  70. package/dist/utils/deployment.js +16 -2
  71. package/dist/utils/dev-api.d.ts +42 -2
  72. package/dist/utils/dev-api.js +177 -4
  73. package/dist/utils/dev-server.d.ts +1 -1
  74. package/dist/utils/dev-server.js +4 -4
  75. package/dist/utils/dynamic-job-bundler.d.ts +17 -0
  76. package/dist/utils/dynamic-job-bundler.js +143 -0
  77. package/dist/utils/init-agent.d.ts +3 -1
  78. package/dist/utils/init-agent.js +6 -4
  79. package/dist/utils/init-prompts.d.ts +2 -1
  80. package/dist/utils/init-prompts.js +14 -9
  81. package/dist/utils/job-management.d.ts +24 -0
  82. package/dist/utils/job-management.js +264 -0
  83. package/dist/utils/postprocessor-management.d.ts +9 -0
  84. package/dist/utils/postprocessor-management.js +118 -0
  85. package/dist/utils/pre-bundle-jobs.d.ts +26 -0
  86. package/dist/utils/pre-bundle-jobs.js +176 -0
  87. package/dist/utils/preprocessor-management.d.ts +9 -0
  88. package/dist/utils/preprocessor-management.js +118 -0
  89. package/dist/utils/sandbox-storage.d.ts +48 -0
  90. package/dist/utils/sandbox-storage.js +114 -0
  91. package/dist/utils/sandbox.d.ts +61 -1
  92. package/dist/utils/sandbox.js +299 -72
  93. package/dist/utils/tool-detection.d.ts +3 -2
  94. package/dist/utils/tool-detection.js +18 -4
  95. package/dist/utils/webhook-management.d.ts +24 -0
  96. package/dist/utils/webhook-management.js +256 -0
  97. package/package.json +1 -1
  98. package/template/README.md +30 -2
  99. package/template/env.example +5 -0
  100. package/template/lua.skill.yaml +47 -0
  101. package/template/package-lock.json +10505 -0
  102. package/template/package.json +2 -1
  103. package/template/src/index.ts +103 -2
  104. package/template/src/jobs/AbandonedBasketProcessorJob.ts +139 -0
  105. package/template/src/jobs/DailyCleanupJob.ts +100 -0
  106. package/template/src/jobs/DataMigrationJob.ts +133 -0
  107. package/template/src/jobs/HealthCheckJob.ts +87 -0
  108. package/template/src/tools/CreateInlineJob.ts +42 -0
  109. package/template/src/tools/GameScoreTrackerTool.ts +356 -0
  110. package/template/src/tools/SmartBasketTool.ts +188 -0
  111. package/template/src/webhooks/PaymentWebhook.ts +113 -0
  112. package/template/src/webhooks/UserEventWebhook.ts +77 -0
  113. package/API_REFERENCE.md +0 -1408
  114. package/CHANGELOG.md +0 -236
  115. package/CLI_REFERENCE.md +0 -908
  116. package/GETTING_STARTED.md +0 -1040
  117. package/INSTANCE_TYPES.md +0 -1158
  118. package/README.md +0 -865
  119. package/TEMPLATE_GUIDE.md +0 -1398
  120. package/USER_DATA_INSTANCE.md +0 -621
  121. package/template/TOOL_EXAMPLES.md +0 -655
@@ -1,16 +1,18 @@
1
1
  /**
2
2
  * Base URLs for the API, Auth, and Chat - Production
3
3
  */
4
- export const BASE_URLS = {
5
- API: 'https://api.heylua.ai',
6
- AUTH: 'https://auth.heylua.ai',
7
- CHAT: 'https://api.heylua.ai',
8
- };
9
- /**
10
- * Base URLs for the API, Auth, and Chat - Development
11
- */
12
4
  // export const BASE_URLS = {
13
5
  // API: 'http://localhost:3022',
14
6
  // AUTH: 'https://auth.heylua.ai',
15
7
  // CHAT: 'http://localhost:3001',
8
+ // WEBHOOK: 'https://webhook.heylua.ai',
16
9
  // } as const;
10
+ /**
11
+ * Base URLs for the API, Auth, and Chat - Development
12
+ */
13
+ export const BASE_URLS = {
14
+ API: 'https://api.heylua.ai',
15
+ AUTH: 'https://auth.heylua.ai',
16
+ CHAT: 'https://api.heylua.ai',
17
+ WEBHOOK: 'https://webhook.heylua.ai',
18
+ };
@@ -39,7 +39,8 @@ export interface CreateAgentRequest {
39
39
  features: Record<string, boolean>;
40
40
  channels: any[];
41
41
  org: {
42
- registeredName: string;
42
+ id?: string;
43
+ registeredName?: string;
43
44
  };
44
45
  }
45
46
  /**
@@ -6,10 +6,21 @@
6
6
  * Chat message structure.
7
7
  * Currently only supports text messages.
8
8
  */
9
- export interface ChatMessage {
9
+ export type ChatMessage = TextMessage | ImageMessage | FileMessage;
10
+ export interface TextMessage {
10
11
  type: 'text';
11
12
  text: string;
12
13
  }
14
+ export interface ImageMessage {
15
+ type: 'image';
16
+ image: string;
17
+ mimeType: string;
18
+ }
19
+ export interface FileMessage {
20
+ type: 'file';
21
+ data: string;
22
+ mimeType: string;
23
+ }
13
24
  /**
14
25
  * Skill override for testing specific skill versions.
15
26
  * Used in dev mode to override production skills with sandbox versions.
@@ -18,6 +29,22 @@ export interface SkillOverride {
18
29
  skillId: string;
19
30
  sandboxId: string;
20
31
  }
32
+ /**
33
+ * PreProcessor override for sandbox testing.
34
+ * Maps production preprocessor ID to sandbox version ID.
35
+ */
36
+ export interface PreProcessorOverride {
37
+ preprocessorId: string;
38
+ sandboxId: string;
39
+ }
40
+ /**
41
+ * PostProcessor override for sandbox testing.
42
+ * Maps production postprocessor ID to sandbox version ID.
43
+ */
44
+ export interface PostProcessorOverride {
45
+ postprocessorId: string;
46
+ sandboxId: string;
47
+ }
21
48
  /**
22
49
  * Chat request payload.
23
50
  * Sent to the chat API to start or continue a conversation.
@@ -26,7 +53,10 @@ export interface ChatRequest {
26
53
  messages: ChatMessage[];
27
54
  navigate: boolean;
28
55
  skillOverride: SkillOverride[];
56
+ preprocessorOverride?: PreProcessorOverride[];
57
+ postprocessorOverride?: PostProcessorOverride[];
29
58
  personaOverride?: string;
59
+ runtimeContext?: string;
30
60
  }
31
61
  /**
32
62
  * Chat response from API.
@@ -59,3 +89,24 @@ export interface DetailedChatResponse {
59
89
  steps: any[];
60
90
  sources: any[];
61
91
  }
92
+ /**
93
+ * Chat history message content item
94
+ */
95
+ export interface ChatHistoryContent {
96
+ type: 'text' | 'image' | 'file';
97
+ text?: string;
98
+ url?: string;
99
+ filename?: string;
100
+ }
101
+ /**
102
+ * Chat history message from conversation
103
+ */
104
+ export interface ChatHistoryMessage {
105
+ role: 'user' | 'assistant';
106
+ id: string;
107
+ createdAt: string;
108
+ resourceId: string;
109
+ threadId: string;
110
+ type: string;
111
+ content: ChatHistoryContent[];
112
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Interfaces Module - Barrel Export
3
+ *
4
+ * This file serves as the main entry point for all interface definitions.
5
+ * It re-exports interfaces and DTOs from various modules for convenient importing.
6
+ */
7
+ export { CreateWebhookDTO, PushWebhookVersionDTO, UpdateWebhookVersionDTO, WebhookVersion, Webhook, GetWebhooksResponse, DeleteWebhookResponse, CreateWebhookResponse, PushWebhookVersionResponse, } from './webhooks.js';
8
+ export { CreateJobDTO, PushJobVersionDTO, UpdateJobVersionDTO, JobSchedule, JobScheduleType, JobRetryConfig, JobVersion, JobExecutionStatus, JobExecution, JobStatus, Job, GetJobsResponse, DeleteJobResponse, CreateJobResponse, PushJobVersionResponse, JobExecutionResponse, GetJobExecutionsResponse, } from './jobs.js';
9
+ export { ApiResponse, Pagination, } from './common.js';
10
+ export { SkillTool, SkillVersion, Skill, GetSkillsResponse, DeleteSkillResponse, } from './skills.js';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Interfaces Module - Barrel Export
3
+ *
4
+ * This file serves as the main entry point for all interface definitions.
5
+ * It re-exports interfaces and DTOs from various modules for convenient importing.
6
+ */
7
+ export {};
@@ -0,0 +1,193 @@
1
+ /**
2
+ * Jobs Interfaces
3
+ * Structures for job management
4
+ */
5
+ /**
6
+ * DTO for creating a new job
7
+ */
8
+ export interface CreateJobDTO {
9
+ name: string;
10
+ description?: string;
11
+ context?: string;
12
+ schedule: JobSchedule;
13
+ timeout?: number;
14
+ retry?: JobRetryConfig;
15
+ metadata?: Record<string, any>;
16
+ dynamic?: boolean;
17
+ /**
18
+ * Optional initial version data.
19
+ * If provided, creates the first version automatically.
20
+ */
21
+ version?: {
22
+ version: string;
23
+ description?: string;
24
+ context?: string;
25
+ code: string;
26
+ executeFunction: string;
27
+ timeout?: number;
28
+ retry?: JobRetryConfig;
29
+ metadata?: Record<string, any>;
30
+ };
31
+ /**
32
+ * Auto-publish and activate the job after creation.
33
+ * If true, the job will be immediately active and running.
34
+ * Default: false
35
+ */
36
+ activate?: boolean;
37
+ }
38
+ /**
39
+ * DTO for pushing a job version
40
+ */
41
+ export interface PushJobVersionDTO {
42
+ name: string;
43
+ version: string;
44
+ description?: string;
45
+ context?: string;
46
+ jobId: string;
47
+ schedule: JobSchedule;
48
+ timeout?: number;
49
+ retry?: JobRetryConfig;
50
+ code?: string;
51
+ executeFunction?: string;
52
+ metadata?: Record<string, any>;
53
+ }
54
+ /**
55
+ * DTO for updating a job version
56
+ */
57
+ export interface UpdateJobVersionDTO {
58
+ version?: string;
59
+ description?: string;
60
+ context?: string;
61
+ schedule?: JobSchedule;
62
+ timeout?: number;
63
+ retry?: JobRetryConfig;
64
+ code?: string;
65
+ executeFunction?: string;
66
+ metadata?: Record<string, any>;
67
+ }
68
+ /**
69
+ * Job schedule configuration
70
+ */
71
+ export type JobScheduleType = 'cron' | 'once' | 'interval';
72
+ export interface JobSchedule {
73
+ type: JobScheduleType;
74
+ expression?: string;
75
+ executeAt?: string;
76
+ seconds?: number;
77
+ timezone?: string;
78
+ }
79
+ /**
80
+ * Job retry configuration
81
+ */
82
+ export interface JobRetryConfig {
83
+ maxAttempts: number;
84
+ backoffSeconds?: number;
85
+ }
86
+ /**
87
+ * Job version information
88
+ */
89
+ export interface JobVersion {
90
+ id: string;
91
+ version: string;
92
+ description: string;
93
+ active: boolean;
94
+ context: string;
95
+ schedule: JobSchedule;
96
+ timeout?: number;
97
+ retry?: JobRetryConfig;
98
+ createdAt: string;
99
+ updatedAt: string;
100
+ }
101
+ /**
102
+ * Job execution status
103
+ */
104
+ export type JobExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'timeout';
105
+ /**
106
+ * Job execution record
107
+ */
108
+ export interface JobExecution {
109
+ id: string;
110
+ jobId: string;
111
+ versionId: string;
112
+ status: JobExecutionStatus;
113
+ startedAt: string;
114
+ completedAt?: string;
115
+ duration?: number;
116
+ result?: any;
117
+ error?: string;
118
+ retryCount?: number;
119
+ }
120
+ /**
121
+ * Job status
122
+ */
123
+ export type JobStatus = 'active' | 'paused' | 'failed' | 'inactive';
124
+ /**
125
+ * Job information
126
+ */
127
+ export interface Job {
128
+ id: string;
129
+ name: string;
130
+ description: string;
131
+ public: boolean;
132
+ active: boolean;
133
+ status: JobStatus;
134
+ createdAt: string;
135
+ updatedAt: string;
136
+ versions: JobVersion[];
137
+ activeVersionId?: string;
138
+ lastRunAt?: string;
139
+ nextRunAt?: string;
140
+ lastExecution?: JobExecution;
141
+ }
142
+ /**
143
+ * Response from get all jobs API endpoint
144
+ */
145
+ export interface GetJobsResponse {
146
+ jobs: Job[];
147
+ }
148
+ /**
149
+ * Response from delete job API endpoint
150
+ * If deleted is false and deactivated is true, the job has versions
151
+ * and cannot be deleted, so it was deactivated instead
152
+ */
153
+ export interface DeleteJobResponse {
154
+ message: string;
155
+ deleted: boolean;
156
+ deactivated: boolean;
157
+ }
158
+ /**
159
+ * Response from create job API endpoint
160
+ */
161
+ export interface CreateJobResponse {
162
+ id: string;
163
+ name: string;
164
+ description?: string;
165
+ agentId: string;
166
+ context?: string;
167
+ schedule: JobSchedule;
168
+ }
169
+ /**
170
+ * Response from push job version API endpoint
171
+ */
172
+ export interface PushJobVersionResponse {
173
+ versionId: string;
174
+ jobId: string;
175
+ version: string;
176
+ createdAt: string;
177
+ schedule: JobSchedule;
178
+ }
179
+ /**
180
+ * Response from job execution APIs
181
+ */
182
+ export interface JobExecutionResponse {
183
+ execution: JobExecution;
184
+ }
185
+ /**
186
+ * Response from get job executions API
187
+ */
188
+ export interface GetJobExecutionsResponse {
189
+ executions: JobExecution[];
190
+ total: number;
191
+ page?: number;
192
+ limit?: number;
193
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Jobs Interfaces
3
+ * Structures for job management
4
+ */
5
+ export {};
@@ -0,0 +1,35 @@
1
+ /**
2
+ * PostProcessor Interfaces
3
+ */
4
+ /**
5
+ * DTO for creating a new postprocessor
6
+ */
7
+ export interface CreatePostProcessorDTO {
8
+ name: string;
9
+ description?: string;
10
+ context?: string;
11
+ }
12
+ /**
13
+ * DTO for pushing a postprocessor version
14
+ */
15
+ export interface PushPostProcessorVersionDTO {
16
+ name: string;
17
+ version: string;
18
+ description?: string;
19
+ context?: string;
20
+ postprocessorId: string;
21
+ code?: string;
22
+ executeFunction?: string;
23
+ }
24
+ /**
25
+ * PostProcessor version information
26
+ */
27
+ export interface PostProcessorVersion {
28
+ id: string;
29
+ version: string;
30
+ description: string;
31
+ active: boolean;
32
+ context: string;
33
+ createdAt: string;
34
+ updatedAt: string;
35
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * PostProcessor Interfaces
3
+ */
4
+ export {};
@@ -0,0 +1,35 @@
1
+ /**
2
+ * PreProcessor Interfaces
3
+ */
4
+ /**
5
+ * DTO for creating a new preprocessor
6
+ */
7
+ export interface CreatePreProcessorDTO {
8
+ name: string;
9
+ description?: string;
10
+ context?: string;
11
+ }
12
+ /**
13
+ * DTO for pushing a preprocessor version
14
+ */
15
+ export interface PushPreProcessorVersionDTO {
16
+ name: string;
17
+ version: string;
18
+ description?: string;
19
+ context?: string;
20
+ preprocessorId: string;
21
+ code?: string;
22
+ executeFunction?: string;
23
+ }
24
+ /**
25
+ * PreProcessor version information
26
+ */
27
+ export interface PreProcessorVersion {
28
+ id: string;
29
+ version: string;
30
+ description: string;
31
+ active: boolean;
32
+ context: string;
33
+ createdAt: string;
34
+ updatedAt: string;
35
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * PreProcessor Interfaces
3
+ */
4
+ export {};
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Webhooks Interfaces
3
+ * Structures for webhook management
4
+ */
5
+ /**
6
+ * DTO for creating a new webhook
7
+ */
8
+ export interface CreateWebhookDTO {
9
+ name: string;
10
+ description?: string;
11
+ context?: string;
12
+ }
13
+ /**
14
+ * DTO for pushing a webhook version
15
+ */
16
+ export interface PushWebhookVersionDTO {
17
+ name: string;
18
+ version: string;
19
+ description?: string;
20
+ context?: string;
21
+ webhookId: string;
22
+ querySchema?: any;
23
+ headerSchema?: any;
24
+ bodySchema?: any;
25
+ code?: string;
26
+ executeFunction?: string;
27
+ }
28
+ /**
29
+ * DTO for updating a webhook version
30
+ */
31
+ export interface UpdateWebhookVersionDTO {
32
+ version?: string;
33
+ description?: string;
34
+ context?: string;
35
+ querySchema?: any;
36
+ headerSchema?: any;
37
+ bodySchema?: any;
38
+ code?: string;
39
+ executeFunction?: string;
40
+ }
41
+ /**
42
+ * Webhook version information
43
+ */
44
+ export interface WebhookVersion {
45
+ id: string;
46
+ version: string;
47
+ description: string;
48
+ active: boolean;
49
+ context: string;
50
+ querySchema?: any;
51
+ headerSchema?: any;
52
+ bodySchema?: any;
53
+ createdAt: string;
54
+ updatedAt: string;
55
+ }
56
+ /**
57
+ * Webhook information
58
+ */
59
+ export interface Webhook {
60
+ id: string;
61
+ name: string;
62
+ description: string;
63
+ public: boolean;
64
+ active: boolean;
65
+ createdAt: string;
66
+ updatedAt: string;
67
+ versions: WebhookVersion[];
68
+ activeVersionId?: string;
69
+ }
70
+ /**
71
+ * Response from get all webhooks API endpoint
72
+ */
73
+ export interface GetWebhooksResponse {
74
+ webhooks: Webhook[];
75
+ }
76
+ /**
77
+ * Response from delete webhook API endpoint
78
+ * If deleted is false and deactivated is true, the webhook has versions
79
+ * and cannot be deleted, so it was deactivated instead
80
+ */
81
+ export interface DeleteWebhookResponse {
82
+ message: string;
83
+ deleted: boolean;
84
+ deactivated: boolean;
85
+ }
86
+ /**
87
+ * Response from create webhook API endpoint
88
+ */
89
+ export interface CreateWebhookResponse {
90
+ id: string;
91
+ name: string;
92
+ description?: string;
93
+ agentId: string;
94
+ context?: string;
95
+ }
96
+ /**
97
+ * Response from push webhook version API endpoint
98
+ */
99
+ export interface PushWebhookVersionResponse {
100
+ versionId: string;
101
+ webhookId: string;
102
+ version: string;
103
+ createdAt: string;
104
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Webhooks Interfaces
3
+ * Structures for webhook management
4
+ */
5
+ export {};
@@ -13,9 +13,15 @@ import { UserData } from "../interfaces/admin.js";
13
13
  */
14
14
  export declare function saveApiKey(apiKey: string): Promise<void>;
15
15
  /**
16
- * Loads API key from secure system keychain.
16
+ * Loads API key from multiple sources in priority order:
17
+ * 1. Secure system keychain (macOS Keychain, Windows Credential Vault, Linux libsecret)
18
+ * 2. LUA_API_KEY environment variable
19
+ * 3. LUA_API_KEY from .env file
17
20
  *
18
- * @returns Promise resolving to API key or null if not found
21
+ * This fallback mechanism allows the CLI to work in CI/CD environments where
22
+ * keychain access isn't available.
23
+ *
24
+ * @returns Promise resolving to API key or null if not found in any source
19
25
  */
20
26
  export declare function loadApiKey(): Promise<string | null>;
21
27
  /**
@@ -22,12 +22,44 @@ export async function saveApiKey(apiKey) {
22
22
  await keytar.setPassword(KEYTAR_SERVICE, KEYTAR_ACCOUNT, apiKey);
23
23
  }
24
24
  /**
25
- * Loads API key from secure system keychain.
25
+ * Loads API key from multiple sources in priority order:
26
+ * 1. Secure system keychain (macOS Keychain, Windows Credential Vault, Linux libsecret)
27
+ * 2. LUA_API_KEY environment variable
28
+ * 3. LUA_API_KEY from .env file
26
29
  *
27
- * @returns Promise resolving to API key or null if not found
30
+ * This fallback mechanism allows the CLI to work in CI/CD environments where
31
+ * keychain access isn't available.
32
+ *
33
+ * @returns Promise resolving to API key or null if not found in any source
28
34
  */
29
35
  export async function loadApiKey() {
30
- return keytar.getPassword(KEYTAR_SERVICE, KEYTAR_ACCOUNT);
36
+ // Priority 1: Check secure system keychain
37
+ const keychainKey = await keytar.getPassword(KEYTAR_SERVICE, KEYTAR_ACCOUNT);
38
+ if (keychainKey) {
39
+ return keychainKey;
40
+ }
41
+ // Priority 2: Check environment variable
42
+ if (process.env.LUA_API_KEY) {
43
+ return process.env.LUA_API_KEY;
44
+ }
45
+ // Priority 3: Check .env file
46
+ try {
47
+ const fs = await import('fs');
48
+ const path = await import('path');
49
+ const envPath = path.join(process.cwd(), '.env');
50
+ if (fs.existsSync(envPath)) {
51
+ const envContent = fs.readFileSync(envPath, 'utf8');
52
+ const match = envContent.match(/^LUA_API_KEY=(.+)$/m);
53
+ if (match && match[1]) {
54
+ // Remove quotes if present
55
+ return match[1].trim().replace(/^["']|["']$/g, '');
56
+ }
57
+ }
58
+ }
59
+ catch (error) {
60
+ // Silently fail if .env file can't be read
61
+ }
62
+ return null;
31
63
  }
32
64
  /**
33
65
  * Deletes API key from secure system keychain.
@@ -35,6 +35,11 @@ export interface UserDataAPI {
35
35
  * @throws Error if the message sending fails or the request is unsuccessful
36
36
  */
37
37
  sendMessage(messages: Message[]): Promise<any>;
38
+ /**
39
+ * Gets chat history.
40
+ * @returns Promise resolving to chat history
41
+ */
42
+ getChatHistory(): Promise<any>;
38
43
  }
39
44
  /**
40
45
  * Product API contract.
@@ -20,6 +20,30 @@ export interface SkillMetadata {
20
20
  context: string;
21
21
  constructorTools: string[];
22
22
  }
23
+ /**
24
+ * Webhook metadata extracted from source code
25
+ */
26
+ export interface WebhookMetadata {
27
+ name: string;
28
+ version: string;
29
+ description: string;
30
+ context: string;
31
+ }
32
+ /**
33
+ * Job metadata extracted from source code
34
+ */
35
+ export interface JobMetadata {
36
+ name: string;
37
+ version: string;
38
+ description: string;
39
+ context: string;
40
+ schedule: any;
41
+ timeout?: number;
42
+ retry?: {
43
+ maxAttempts: number;
44
+ backoffSeconds?: number;
45
+ };
46
+ }
23
47
  /**
24
48
  * Configuration from lua.skill.yaml
25
49
  */
@@ -30,15 +54,40 @@ export interface SkillConfig {
30
54
  skillId?: string;
31
55
  description?: string;
32
56
  context?: string;
57
+ env?: Record<string, string>;
33
58
  };
34
59
  agent?: {
35
60
  agentId?: string;
61
+ orgId?: string;
62
+ persona?: string;
63
+ welcomeMessage?: string;
36
64
  };
37
65
  skills?: Array<{
38
66
  name: string;
39
67
  version: string;
40
68
  skillId: string;
41
69
  }>;
70
+ webhooks?: Array<{
71
+ name: string;
72
+ version: string;
73
+ webhookId: string;
74
+ }>;
75
+ jobs?: Array<{
76
+ name: string;
77
+ version: string;
78
+ jobId: string;
79
+ schedule?: any;
80
+ }>;
81
+ preprocessors?: Array<{
82
+ name: string;
83
+ version: string;
84
+ preprocessorId: string;
85
+ }>;
86
+ postprocessors?: Array<{
87
+ name: string;
88
+ version: string;
89
+ postprocessorId: string;
90
+ }>;
42
91
  }
43
92
  /**
44
93
  * Deployment data format for new deployment system
@@ -14,7 +14,7 @@
14
14
  * import { validateToolName } from './types/tool-validation.js';
15
15
  * ```
16
16
  */
17
- export { LuaSkill, LuaTool, LuaSkillConfig, env } from './skill.js';
17
+ export { LuaSkill, LuaTool, LuaSkillConfig, LuaWebhook, LuaWebhookConfig, LuaJob, LuaJobConfig, JobSchedule, env } from './skill.js';
18
18
  export { validateToolName, assertValidToolName } from './tool-validation.js';
19
19
  export { UserDataAPI, ProductAPI, BasketAPI, OrderAPI, CustomDataAPI } from './api-contracts.js';
20
20
  export { UserData, EmailAddress, Country, Admin, Organization, AgentAuth, OTPResponse, ApiKeyResponse } from '../interfaces/admin.js';