lua-cli 2.5.7 → 3.0.0-alpha.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.
Files changed (124) hide show
  1. package/dist/api/agent.api.service.d.ts +45 -0
  2. package/dist/api/agent.api.service.js +54 -0
  3. package/dist/api/job.api.service.d.ts +210 -0
  4. package/dist/api/job.api.service.js +200 -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 +98 -0
  8. package/dist/api/postprocessor.api.service.js +76 -0
  9. package/dist/api/preprocessor.api.service.d.ts +98 -0
  10. package/dist/api/preprocessor.api.service.js +76 -0
  11. package/dist/api/user.data.api.service.d.ts +28 -0
  12. package/dist/api/user.data.api.service.js +51 -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 +156 -41
  16. package/dist/api-exports.js +182 -21
  17. package/dist/cli/command-definitions.js +149 -7
  18. package/dist/commands/compile.js +124 -5
  19. package/dist/commands/completion.d.ts +11 -0
  20. package/dist/commands/completion.js +209 -0
  21. package/dist/commands/env.d.ts +3 -2
  22. package/dist/commands/env.js +42 -17
  23. package/dist/commands/features.d.ts +16 -0
  24. package/dist/commands/features.js +352 -0
  25. package/dist/commands/index.d.ts +7 -0
  26. package/dist/commands/index.js +7 -0
  27. package/dist/commands/init.js +53 -7
  28. package/dist/commands/jobs.d.ts +20 -0
  29. package/dist/commands/jobs.js +533 -0
  30. package/dist/commands/logs.js +2 -5
  31. package/dist/commands/persona.d.ts +3 -2
  32. package/dist/commands/persona.js +43 -18
  33. package/dist/commands/postprocessors.d.ts +8 -0
  34. package/dist/commands/postprocessors.js +431 -0
  35. package/dist/commands/preprocessors.d.ts +8 -0
  36. package/dist/commands/preprocessors.js +431 -0
  37. package/dist/commands/push.d.ts +9 -13
  38. package/dist/commands/push.js +937 -69
  39. package/dist/commands/skills.d.ts +16 -0
  40. package/dist/commands/skills.js +438 -0
  41. package/dist/commands/test.d.ts +9 -18
  42. package/dist/commands/test.js +558 -82
  43. package/dist/commands/webhooks.d.ts +18 -0
  44. package/dist/commands/webhooks.js +424 -0
  45. package/dist/common/data.entry.instance.d.ts +7 -0
  46. package/dist/common/data.entry.instance.js +15 -0
  47. package/dist/common/job.instance.d.ts +77 -0
  48. package/dist/common/job.instance.js +108 -0
  49. package/dist/common/order.instance.d.ts +6 -0
  50. package/dist/common/order.instance.js +14 -0
  51. package/dist/common/product.instance.d.ts +6 -0
  52. package/dist/common/product.instance.js +14 -0
  53. package/dist/common/user.instance.d.ts +15 -0
  54. package/dist/common/user.instance.js +38 -0
  55. package/dist/config/constants.d.ts +2 -2
  56. package/dist/config/constants.js +4 -4
  57. package/dist/index.js +14 -3
  58. package/dist/interfaces/agent.d.ts +33 -1
  59. package/dist/interfaces/chat.d.ts +22 -0
  60. package/dist/interfaces/index.d.ts +10 -0
  61. package/dist/interfaces/index.js +7 -0
  62. package/dist/interfaces/jobs.d.ts +172 -0
  63. package/dist/interfaces/jobs.js +5 -0
  64. package/dist/interfaces/message.d.ts +18 -0
  65. package/dist/interfaces/message.js +1 -0
  66. package/dist/interfaces/postprocessors.d.ts +35 -0
  67. package/dist/interfaces/postprocessors.js +4 -0
  68. package/dist/interfaces/preprocessors.d.ts +35 -0
  69. package/dist/interfaces/preprocessors.js +4 -0
  70. package/dist/interfaces/webhooks.d.ts +104 -0
  71. package/dist/interfaces/webhooks.js +5 -0
  72. package/dist/types/api-contracts.d.ts +14 -0
  73. package/dist/types/api-contracts.js +0 -7
  74. package/dist/types/compile.types.d.ts +49 -0
  75. package/dist/types/index.d.ts +1 -1
  76. package/dist/types/index.js +1 -1
  77. package/dist/types/skill.d.ts +502 -0
  78. package/dist/types/skill.js +477 -0
  79. package/dist/utils/agent-management.d.ts +25 -0
  80. package/dist/utils/agent-management.js +67 -0
  81. package/dist/utils/bundling.d.ts +31 -1
  82. package/dist/utils/bundling.js +653 -10
  83. package/dist/utils/compile.d.ts +63 -0
  84. package/dist/utils/compile.js +691 -36
  85. package/dist/utils/deployment.d.ts +2 -1
  86. package/dist/utils/deployment.js +16 -2
  87. package/dist/utils/init-agent.d.ts +3 -1
  88. package/dist/utils/init-agent.js +6 -4
  89. package/dist/utils/init-prompts.d.ts +2 -1
  90. package/dist/utils/init-prompts.js +14 -9
  91. package/dist/utils/job-management.d.ts +24 -0
  92. package/dist/utils/job-management.js +264 -0
  93. package/dist/utils/postprocessor-management.d.ts +9 -0
  94. package/dist/utils/postprocessor-management.js +118 -0
  95. package/dist/utils/preprocessor-management.d.ts +9 -0
  96. package/dist/utils/preprocessor-management.js +118 -0
  97. package/dist/utils/sandbox.d.ts +61 -1
  98. package/dist/utils/sandbox.js +283 -72
  99. package/dist/utils/tool-detection.d.ts +3 -2
  100. package/dist/utils/tool-detection.js +18 -4
  101. package/dist/utils/webhook-management.d.ts +24 -0
  102. package/dist/utils/webhook-management.js +256 -0
  103. package/dist/web/app.css +152 -736
  104. package/dist/web/app.js +45 -45
  105. package/package.json +2 -2
  106. package/template/AGENT_CONFIGURATION.md +251 -0
  107. package/template/COMPLEX_JOB_EXAMPLES.md +795 -0
  108. package/template/DYNAMIC_JOB_CREATION.md +371 -0
  109. package/template/README.md +30 -2
  110. package/template/WEBHOOKS_JOBS_QUICKSTART.md +318 -0
  111. package/template/WEBHOOK_JOB_EXAMPLES.md +817 -0
  112. package/template/package.json +1 -1
  113. package/template/src/index-agent-example.ts +201 -0
  114. package/template/src/index.ts +39 -0
  115. package/template/src/jobs/AbandonedBasketProcessorJob.ts +139 -0
  116. package/template/src/jobs/DailyCleanupJob.ts +100 -0
  117. package/template/src/jobs/DataMigrationJob.ts +133 -0
  118. package/template/src/jobs/HealthCheckJob.ts +87 -0
  119. package/template/src/postprocessors/ResponseFormatter.ts +151 -0
  120. package/template/src/preprocessors/MessageFilter.ts +91 -0
  121. package/template/src/tools/GameScoreTrackerTool.ts +356 -0
  122. package/template/src/tools/SmartBasketTool.ts +188 -0
  123. package/template/src/webhooks/PaymentWebhook.ts +113 -0
  124. package/template/src/webhooks/UserEventWebhook.ts +77 -0
@@ -14,6 +14,9 @@ import { CreateSlackChannelRequest } from "../interfaces/agent.js";
14
14
  import { CreateSlackChannelResponse } from "../interfaces/agent.js";
15
15
  import { CreateEmailChannelRequest } from "../interfaces/agent.js";
16
16
  import { CreateEmailChannelResponse } from "../interfaces/agent.js";
17
+ import { GetAgentFeaturesResponse } from "../interfaces/agent.js";
18
+ import { UpdateAgentFeatureRequest } from "../interfaces/agent.js";
19
+ import { UpdateAgentFeatureResponse } from "../interfaces/agent.js";
17
20
  /**
18
21
  * Agent API calls
19
22
  */
@@ -94,4 +97,46 @@ export default class AgentApi extends HttpClient {
94
97
  * @throws Error if the API request fails or the channel creation is unsuccessful
95
98
  */
96
99
  createEmailChannel(agentId: string, channelData: CreateEmailChannelRequest): Promise<ApiResponse<CreateEmailChannelResponse>>;
100
+ /**
101
+ * Retrieves all features configured for a specific agent
102
+ * @param agentId - The unique identifier of the agent
103
+ * @returns Promise resolving to an ApiResponse containing an array of agent features
104
+ * @throws Error if the API request fails or the agent is not found
105
+ * @example
106
+ * const features = await agentApi.getAgentFeatures('baseAgent_agent_123');
107
+ * features.data.features.forEach(feature => {
108
+ * console.log(`${feature.title}: ${feature.active ? 'enabled' : 'disabled'}`);
109
+ * });
110
+ */
111
+ getAgentFeatures(agentId: string): Promise<ApiResponse<GetAgentFeaturesResponse>>;
112
+ /**
113
+ * Updates a specific feature for an agent
114
+ * @param agentId - The unique identifier of the agent
115
+ * @param featureData - The feature update configuration
116
+ * @param featureData.featureName - The name of the feature to update (required)
117
+ * @param featureData.active - Whether the feature should be enabled or disabled (optional)
118
+ * @param featureData.featureContext - Custom context/instructions for the feature (optional)
119
+ * @returns Promise resolving to an ApiResponse with success message
120
+ * @throws Error if the API request fails, the agent/feature is not found, or neither active nor featureContext is provided
121
+ * @example
122
+ * // Enable a feature
123
+ * await agentApi.updateAgentFeature('baseAgent_agent_123', {
124
+ * featureName: 'inquiry',
125
+ * active: true
126
+ * });
127
+ *
128
+ * // Update feature context
129
+ * await agentApi.updateAgentFeature('baseAgent_agent_123', {
130
+ * featureName: 'tickets',
131
+ * featureContext: 'Custom instructions for ticket handling'
132
+ * });
133
+ *
134
+ * // Update both
135
+ * await agentApi.updateAgentFeature('baseAgent_agent_123', {
136
+ * featureName: 'rag',
137
+ * active: true,
138
+ * featureContext: 'Enhanced RAG search instructions'
139
+ * });
140
+ */
141
+ updateAgentFeature(agentId: string, featureData: UpdateAgentFeatureRequest): Promise<ApiResponse<UpdateAgentFeatureResponse>>;
97
142
  }
@@ -117,4 +117,58 @@ export default class AgentApi extends HttpClient {
117
117
  Authorization: `Bearer ${this.apiKey}`,
118
118
  });
119
119
  }
120
+ /**
121
+ * Retrieves all features configured for a specific agent
122
+ * @param agentId - The unique identifier of the agent
123
+ * @returns Promise resolving to an ApiResponse containing an array of agent features
124
+ * @throws Error if the API request fails or the agent is not found
125
+ * @example
126
+ * const features = await agentApi.getAgentFeatures('baseAgent_agent_123');
127
+ * features.data.features.forEach(feature => {
128
+ * console.log(`${feature.title}: ${feature.active ? 'enabled' : 'disabled'}`);
129
+ * });
130
+ */
131
+ async getAgentFeatures(agentId) {
132
+ return this.httpGet(`/admin/agents/${agentId}/features`, {
133
+ Authorization: `Bearer ${this.apiKey}`,
134
+ });
135
+ }
136
+ /**
137
+ * Updates a specific feature for an agent
138
+ * @param agentId - The unique identifier of the agent
139
+ * @param featureData - The feature update configuration
140
+ * @param featureData.featureName - The name of the feature to update (required)
141
+ * @param featureData.active - Whether the feature should be enabled or disabled (optional)
142
+ * @param featureData.featureContext - Custom context/instructions for the feature (optional)
143
+ * @returns Promise resolving to an ApiResponse with success message
144
+ * @throws Error if the API request fails, the agent/feature is not found, or neither active nor featureContext is provided
145
+ * @example
146
+ * // Enable a feature
147
+ * await agentApi.updateAgentFeature('baseAgent_agent_123', {
148
+ * featureName: 'inquiry',
149
+ * active: true
150
+ * });
151
+ *
152
+ * // Update feature context
153
+ * await agentApi.updateAgentFeature('baseAgent_agent_123', {
154
+ * featureName: 'tickets',
155
+ * featureContext: 'Custom instructions for ticket handling'
156
+ * });
157
+ *
158
+ * // Update both
159
+ * await agentApi.updateAgentFeature('baseAgent_agent_123', {
160
+ * featureName: 'rag',
161
+ * active: true,
162
+ * featureContext: 'Enhanced RAG search instructions'
163
+ * });
164
+ */
165
+ async updateAgentFeature(agentId, featureData) {
166
+ // Validate that at least one optional field is provided
167
+ if (featureData.active === undefined && featureData.featureContext === undefined) {
168
+ throw new Error('At least one of "active" or "featureContext" must be provided');
169
+ }
170
+ return this.httpPut(`/admin/agents/${agentId}/features`, featureData, {
171
+ Authorization: `Bearer ${this.apiKey}`,
172
+ });
173
+ }
120
174
  }
@@ -0,0 +1,210 @@
1
+ import { HttpClient } from "../common/http.client.js";
2
+ import { ApiResponse } from "../interfaces/common.js";
3
+ import { CreateJobDTO, PushJobVersionDTO, UpdateJobVersionDTO } from "../interfaces/jobs.js";
4
+ import { JobInstance } from "../common/job.instance.js";
5
+ /**
6
+ * Job API Response Types
7
+ */
8
+ export interface JobVersion {
9
+ version: string;
10
+ jobId: string;
11
+ createdAt: string | number;
12
+ isActive?: boolean;
13
+ schedule?: any;
14
+ timeout?: number;
15
+ retry?: {
16
+ maxAttempts: number;
17
+ backoffSeconds?: number;
18
+ };
19
+ }
20
+ export interface GetJobsResponse {
21
+ jobs: Array<{
22
+ id: string;
23
+ name: string;
24
+ description?: string;
25
+ context?: string;
26
+ versions: JobVersion[];
27
+ activeVersionId?: string;
28
+ lastRunAt?: string;
29
+ nextRunAt?: string;
30
+ status?: 'active' | 'paused' | 'failed';
31
+ }>;
32
+ }
33
+ export interface CreateJobResponse {
34
+ id: string;
35
+ name: string;
36
+ description?: string;
37
+ agentId: string;
38
+ context?: string;
39
+ }
40
+ export interface JobVersionResponse {
41
+ versionId: string;
42
+ jobId: string;
43
+ version: string;
44
+ createdAt: string;
45
+ schedule: any;
46
+ }
47
+ export interface UpdateJobVersionResponse {
48
+ versionId: string;
49
+ jobId: string;
50
+ version: string;
51
+ updatedAt: string;
52
+ }
53
+ export interface DeleteJobResponse {
54
+ deleted: boolean;
55
+ deactivated?: boolean;
56
+ message: string;
57
+ }
58
+ export interface JobExecutionResponse {
59
+ executionId: string;
60
+ jobId: string;
61
+ startedAt: string;
62
+ completedAt?: string;
63
+ status: 'pending' | 'running' | 'completed' | 'failed';
64
+ result?: any;
65
+ error?: string;
66
+ }
67
+ /**
68
+ * Job API Service
69
+ * Handles all job-related API calls
70
+ */
71
+ export default class JobApi extends HttpClient {
72
+ private apiKey;
73
+ private agentId;
74
+ /**
75
+ * Creates an instance of JobApi
76
+ * @param baseUrl - The base URL for the API
77
+ * @param apiKey - The API key for authentication
78
+ * @param agentId - The unique identifier of the agent
79
+ */
80
+ constructor(baseUrl: string, apiKey: string, agentId: string);
81
+ /**
82
+ * Retrieves all jobs for the agent
83
+ * @returns Promise resolving to an ApiResponse containing an array of jobs with their versions
84
+ * @throws Error if the API request fails or the agent is not found
85
+ */
86
+ getJobs(): Promise<ApiResponse<GetJobsResponse>>;
87
+ /**
88
+ * Retrieves a job by its unique identifier
89
+ * @param jobId - The unique identifier of the job to retrieve
90
+ * @returns Promise resolving to an JobInstance representing the job
91
+ * @throws Error if the job is not found or the request fails
92
+ */
93
+ getJob(jobId: string): Promise<JobInstance>;
94
+ /**
95
+ * Creates a new job for the agent
96
+ * @param jobData - The job data including name, description, and optional context
97
+ * @returns Promise resolving to an ApiResponse containing the created job details
98
+ * @throws Error if the job creation fails or validation errors occur
99
+ */
100
+ createJob(jobData: CreateJobDTO): Promise<ApiResponse<CreateJobResponse>>;
101
+ /**
102
+ * Creates a new job for the agent
103
+ * @param jobData - The job data including name, description, and optional context
104
+ * @returns Promise resolving to an JobInstance containing the created job details
105
+ * @throws Error if the job creation fails or validation errors occur
106
+ */
107
+ createJobInstance(jobData: CreateJobDTO): Promise<JobInstance>;
108
+ /**
109
+ * Pushes a new version of a job to production
110
+ * @param jobId - The unique identifier of the job
111
+ * @param versionData - The version data including code, configuration, and metadata
112
+ * @returns Promise resolving to an ApiResponse containing the created version details
113
+ * @throws Error if the job is not found or the push operation fails
114
+ */
115
+ pushJob(jobId: string, versionData: PushJobVersionDTO): Promise<ApiResponse<JobVersionResponse>>;
116
+ /**
117
+ * Pushes a new development/sandbox version of a job for testing
118
+ * @param jobId - The unique identifier of the job
119
+ * @param versionData - The version data including code, configuration, and metadata
120
+ * @returns Promise resolving to an ApiResponse containing the development version details
121
+ * @throws Error if the job is not found or the push operation fails
122
+ */
123
+ pushDevJob(jobId: string, versionData: PushJobVersionDTO): Promise<ApiResponse<JobVersionResponse>>;
124
+ /**
125
+ * Updates an existing development/sandbox version of a job
126
+ * @param jobId - The unique identifier of the job
127
+ * @param sandboxVersionId - The unique identifier of the sandbox version to update
128
+ * @param versionData - The updated version data including code, configuration, and metadata
129
+ * @returns Promise resolving to an ApiResponse containing the updated version details
130
+ * @throws Error if the job or version is not found or the update fails
131
+ */
132
+ updateDevJob(jobId: string, sandboxVersionId: string, versionData: UpdateJobVersionDTO): Promise<ApiResponse<UpdateJobVersionResponse>>;
133
+ /**
134
+ * Retrieves all versions of a specific job
135
+ * @param jobId - The unique identifier of the job
136
+ * @returns Promise resolving to an ApiResponse containing an array of job versions
137
+ * @throws Error if the job is not found or the request fails
138
+ */
139
+ getJobVersions(jobId: string): Promise<ApiResponse<{
140
+ versions: JobVersion[];
141
+ activeVersionId?: string;
142
+ }>>;
143
+ /**
144
+ * Publishes a specific version of a job to production
145
+ * @param jobId - The unique identifier of the job
146
+ * @param version - The version identifier to publish
147
+ * @returns Promise resolving to an ApiResponse containing publication confirmation details
148
+ * @throws Error if the job or version is not found or the publish operation fails
149
+ */
150
+ publishJobVersion(jobId: string, version: string): Promise<ApiResponse<{
151
+ message: string;
152
+ jobId: string;
153
+ activeVersionId: string;
154
+ publishedAt: string;
155
+ }>>;
156
+ /**
157
+ * Deletes a job and all its versions, or deactivates it if it has versions
158
+ * @param jobId - The unique identifier of the job to delete
159
+ * @returns Promise resolving to an ApiResponse with deletion status
160
+ * - If deleted is true: job was successfully deleted
161
+ * - If deleted is false and deactivated is true: job has versions and was deactivated instead
162
+ * @throws Error if the job is not found or the delete operation fails
163
+ */
164
+ deleteJob(jobId: string): Promise<ApiResponse<DeleteJobResponse>>;
165
+ /**
166
+ * Activates a job (enables it to run on schedule)
167
+ * @param jobId - The unique identifier of the job to activate
168
+ * @returns Promise resolving to an ApiResponse with activation status
169
+ * @throws Error if the job is not found or the operation fails
170
+ */
171
+ activateJob(jobId: string): Promise<ApiResponse<{
172
+ message: string;
173
+ active: boolean;
174
+ }>>;
175
+ /**
176
+ * Deactivates a job (disables it from running)
177
+ * @param jobId - The unique identifier of the job to deactivate
178
+ * @returns Promise resolving to an ApiResponse with deactivation status
179
+ * @throws Error if the job is not found or the operation fails
180
+ */
181
+ deactivateJob(jobId: string): Promise<ApiResponse<{
182
+ message: string;
183
+ active: boolean;
184
+ }>>;
185
+ /**
186
+ * Manually triggers a job execution (ignores schedule)
187
+ * @param jobId - The unique identifier of the job to trigger
188
+ * @returns Promise resolving to an ApiResponse with execution details
189
+ * @throws Error if the job is not found or the operation fails
190
+ */
191
+ triggerJob(jobId: string): Promise<ApiResponse<JobExecutionResponse>>;
192
+ /**
193
+ * Retrieves execution history for a job
194
+ * @param jobId - The unique identifier of the job
195
+ * @param limit - Maximum number of executions to return (default: 50)
196
+ * @returns Promise resolving to an ApiResponse with execution history
197
+ * @throws Error if the job is not found or the request fails
198
+ */
199
+ getJobExecutions(jobId: string, limit?: number): Promise<ApiResponse<{
200
+ executions: JobExecutionResponse[];
201
+ }>>;
202
+ /**
203
+ * Updates the metadata of a job
204
+ * @param jobId - The unique identifier of the job
205
+ * @param metadata - The metadata object to update or merge with existing metadata
206
+ * @returns Promise resolving to the updated metadata
207
+ * @throws Error if the job is not found or the metadata update fails
208
+ */
209
+ updateMetadata(jobId: string, metadata: any): Promise<ApiResponse<any>>;
210
+ }
@@ -0,0 +1,200 @@
1
+ import { HttpClient } from "../common/http.client.js";
2
+ import { JobInstance } from "../common/job.instance.js";
3
+ /**
4
+ * Job API Service
5
+ * Handles all job-related API calls
6
+ */
7
+ export default class JobApi extends HttpClient {
8
+ /**
9
+ * Creates an instance of JobApi
10
+ * @param baseUrl - The base URL for the API
11
+ * @param apiKey - The API key for authentication
12
+ * @param agentId - The unique identifier of the agent
13
+ */
14
+ constructor(baseUrl, apiKey, agentId) {
15
+ super(baseUrl);
16
+ this.apiKey = apiKey;
17
+ this.agentId = agentId;
18
+ }
19
+ /**
20
+ * Retrieves all jobs for the agent
21
+ * @returns Promise resolving to an ApiResponse containing an array of jobs with their versions
22
+ * @throws Error if the API request fails or the agent is not found
23
+ */
24
+ async getJobs() {
25
+ return this.httpGet(`/developer/jobs/${this.agentId}`, {
26
+ Authorization: `Bearer ${this.apiKey}`,
27
+ });
28
+ }
29
+ /**
30
+ * Retrieves a job by its unique identifier
31
+ * @param jobId - The unique identifier of the job to retrieve
32
+ * @returns Promise resolving to an JobInstance representing the job
33
+ * @throws Error if the job is not found or the request fails
34
+ */
35
+ async getJob(jobId) {
36
+ const response = await this.httpGet(`/developer/jobs/${this.agentId}/${jobId}`, {
37
+ Authorization: `Bearer ${this.apiKey}`,
38
+ });
39
+ if (response.success && response.data) {
40
+ return new JobInstance(this, response.data);
41
+ }
42
+ throw new Error(response.error?.message || 'Failed to get job');
43
+ }
44
+ /**
45
+ * Creates a new job for the agent
46
+ * @param jobData - The job data including name, description, and optional context
47
+ * @returns Promise resolving to an ApiResponse containing the created job details
48
+ * @throws Error if the job creation fails or validation errors occur
49
+ */
50
+ async createJob(jobData) {
51
+ return this.httpPost(`/developer/jobs/${this.agentId}`, jobData, {
52
+ Authorization: `Bearer ${this.apiKey}`,
53
+ });
54
+ }
55
+ /**
56
+ * Creates a new job for the agent
57
+ * @param jobData - The job data including name, description, and optional context
58
+ * @returns Promise resolving to an JobInstance containing the created job details
59
+ * @throws Error if the job creation fails or validation errors occur
60
+ */
61
+ async createJobInstance(jobData) {
62
+ const response = await this.httpPost(`/developer/jobs/${this.agentId}`, jobData, {
63
+ Authorization: `Bearer ${this.apiKey}`,
64
+ });
65
+ if (response.success && response.data) {
66
+ return new JobInstance(this, response.data);
67
+ }
68
+ throw new Error(response.error?.message || 'Failed to create job');
69
+ }
70
+ /**
71
+ * Pushes a new version of a job to production
72
+ * @param jobId - The unique identifier of the job
73
+ * @param versionData - The version data including code, configuration, and metadata
74
+ * @returns Promise resolving to an ApiResponse containing the created version details
75
+ * @throws Error if the job is not found or the push operation fails
76
+ */
77
+ async pushJob(jobId, versionData) {
78
+ return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/version`, versionData, {
79
+ Authorization: `Bearer ${this.apiKey}`,
80
+ });
81
+ }
82
+ /**
83
+ * Pushes a new development/sandbox version of a job for testing
84
+ * @param jobId - The unique identifier of the job
85
+ * @param versionData - The version data including code, configuration, and metadata
86
+ * @returns Promise resolving to an ApiResponse containing the development version details
87
+ * @throws Error if the job is not found or the push operation fails
88
+ */
89
+ async pushDevJob(jobId, versionData) {
90
+ return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/version/sandbox`, versionData, {
91
+ Authorization: `Bearer ${this.apiKey}`,
92
+ });
93
+ }
94
+ /**
95
+ * Updates an existing development/sandbox version of a job
96
+ * @param jobId - The unique identifier of the job
97
+ * @param sandboxVersionId - The unique identifier of the sandbox version to update
98
+ * @param versionData - The updated version data including code, configuration, and metadata
99
+ * @returns Promise resolving to an ApiResponse containing the updated version details
100
+ * @throws Error if the job or version is not found or the update fails
101
+ */
102
+ async updateDevJob(jobId, sandboxVersionId, versionData) {
103
+ return this.httpPut(`/developer/jobs/${this.agentId}/${jobId}/version/sandbox/${sandboxVersionId}`, versionData, {
104
+ Authorization: `Bearer ${this.apiKey}`,
105
+ });
106
+ }
107
+ /**
108
+ * Retrieves all versions of a specific job
109
+ * @param jobId - The unique identifier of the job
110
+ * @returns Promise resolving to an ApiResponse containing an array of job versions
111
+ * @throws Error if the job is not found or the request fails
112
+ */
113
+ async getJobVersions(jobId) {
114
+ return this.httpGet(`/developer/jobs/${this.agentId}/${jobId}/versions`, {
115
+ Authorization: `Bearer ${this.apiKey}`,
116
+ });
117
+ }
118
+ /**
119
+ * Publishes a specific version of a job to production
120
+ * @param jobId - The unique identifier of the job
121
+ * @param version - The version identifier to publish
122
+ * @returns Promise resolving to an ApiResponse containing publication confirmation details
123
+ * @throws Error if the job or version is not found or the publish operation fails
124
+ */
125
+ async publishJobVersion(jobId, version) {
126
+ return this.httpPut(`/developer/jobs/${this.agentId}/${jobId}/${version}/publish`, undefined, {
127
+ Authorization: `Bearer ${this.apiKey}`,
128
+ });
129
+ }
130
+ /**
131
+ * Deletes a job and all its versions, or deactivates it if it has versions
132
+ * @param jobId - The unique identifier of the job to delete
133
+ * @returns Promise resolving to an ApiResponse with deletion status
134
+ * - If deleted is true: job was successfully deleted
135
+ * - If deleted is false and deactivated is true: job has versions and was deactivated instead
136
+ * @throws Error if the job is not found or the delete operation fails
137
+ */
138
+ async deleteJob(jobId) {
139
+ return this.httpDelete(`/developer/jobs/${this.agentId}/${jobId}`, {
140
+ Authorization: `Bearer ${this.apiKey}`,
141
+ });
142
+ }
143
+ /**
144
+ * Activates a job (enables it to run on schedule)
145
+ * @param jobId - The unique identifier of the job to activate
146
+ * @returns Promise resolving to an ApiResponse with activation status
147
+ * @throws Error if the job is not found or the operation fails
148
+ */
149
+ async activateJob(jobId) {
150
+ return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/activate`, {}, {
151
+ Authorization: `Bearer ${this.apiKey}`,
152
+ });
153
+ }
154
+ /**
155
+ * Deactivates a job (disables it from running)
156
+ * @param jobId - The unique identifier of the job to deactivate
157
+ * @returns Promise resolving to an ApiResponse with deactivation status
158
+ * @throws Error if the job is not found or the operation fails
159
+ */
160
+ async deactivateJob(jobId) {
161
+ return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/deactivate`, {}, {
162
+ Authorization: `Bearer ${this.apiKey}`,
163
+ });
164
+ }
165
+ /**
166
+ * Manually triggers a job execution (ignores schedule)
167
+ * @param jobId - The unique identifier of the job to trigger
168
+ * @returns Promise resolving to an ApiResponse with execution details
169
+ * @throws Error if the job is not found or the operation fails
170
+ */
171
+ async triggerJob(jobId) {
172
+ return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/trigger`, {}, {
173
+ Authorization: `Bearer ${this.apiKey}`,
174
+ });
175
+ }
176
+ /**
177
+ * Retrieves execution history for a job
178
+ * @param jobId - The unique identifier of the job
179
+ * @param limit - Maximum number of executions to return (default: 50)
180
+ * @returns Promise resolving to an ApiResponse with execution history
181
+ * @throws Error if the job is not found or the request fails
182
+ */
183
+ async getJobExecutions(jobId, limit = 50) {
184
+ return this.httpGet(`/developer/jobs/${this.agentId}/${jobId}/executions?limit=${limit}`, {
185
+ Authorization: `Bearer ${this.apiKey}`,
186
+ });
187
+ }
188
+ /**
189
+ * Updates the metadata of a job
190
+ * @param jobId - The unique identifier of the job
191
+ * @param metadata - The metadata object to update or merge with existing metadata
192
+ * @returns Promise resolving to the updated metadata
193
+ * @throws Error if the job is not found or the metadata update fails
194
+ */
195
+ async updateMetadata(jobId, metadata) {
196
+ return this.httpPut(`/developer/jobs/${this.agentId}/${jobId}/metadata`, metadata, {
197
+ Authorization: `Bearer ${this.apiKey}`,
198
+ });
199
+ }
200
+ }
@@ -7,6 +7,9 @@ import BasketApiService from "./basket.api.service.js";
7
7
  import OrderApiService from "./order.api.service.js";
8
8
  import UserDataApiService from "./user.data.api.service.js";
9
9
  import CustomDataApiService from "./custom.data.api.service.js";
10
+ import WebhookApi from "./webhook.api.service.js";
11
+ import JobApi from "./job.api.service.js";
12
+ import ChatApi from "./chat.api.service.js";
10
13
  /**
11
14
  * Gets or creates User Data API instance.
12
15
  * Instance is created once and reused for subsequent calls.
@@ -42,6 +45,27 @@ export declare function getBasketsInstance(): Promise<BasketApiService>;
42
45
  * @returns OrderApiService instance
43
46
  */
44
47
  export declare function getOrderInstance(): Promise<OrderApiService>;
48
+ /**
49
+ * Gets or creates Webhook API instance.
50
+ * Instance is created once and reused for subsequent calls.
51
+ *
52
+ * @returns WebhookApi instance
53
+ */
54
+ export declare function getWebhookInstance(): Promise<WebhookApi>;
55
+ /**
56
+ * Gets or creates Job API instance.
57
+ * Instance is created once and reused for subsequent calls.
58
+ *
59
+ * @returns JobApi instance
60
+ */
61
+ export declare function getJobInstance(): Promise<JobApi>;
62
+ /**
63
+ * Gets or creates Chat API instance.
64
+ * Instance is created once and reused for subsequent calls.
65
+ *
66
+ * @returns ChatApi instance
67
+ */
68
+ export declare function getChatInstance(): Promise<ChatApi>;
45
69
  /**
46
70
  * Clears all cached API instances.
47
71
  * Useful for testing or when credentials change.
@@ -9,6 +9,9 @@ import BasketApiService from "./basket.api.service.js";
9
9
  import OrderApiService from "./order.api.service.js";
10
10
  import UserDataApiService from "./user.data.api.service.js";
11
11
  import CustomDataApiService from "./custom.data.api.service.js";
12
+ import WebhookApi from "./webhook.api.service.js";
13
+ import JobApi from "./job.api.service.js";
14
+ import ChatApi from "./chat.api.service.js";
12
15
  /**
13
16
  * Singleton instances (lazy-loaded)
14
17
  */
@@ -17,6 +20,9 @@ let _dataInstance = null;
17
20
  let _productsInstance = null;
18
21
  let _basketsInstance = null;
19
22
  let _orderInstance = null;
23
+ let _webhookInstance = null;
24
+ let _jobInstance = null;
25
+ let _chatInstance = null;
20
26
  /**
21
27
  * Gets or creates User Data API instance.
22
28
  * Instance is created once and reused for subsequent calls.
@@ -82,6 +88,45 @@ export async function getOrderInstance() {
82
88
  }
83
89
  return _orderInstance;
84
90
  }
91
+ /**
92
+ * Gets or creates Webhook API instance.
93
+ * Instance is created once and reused for subsequent calls.
94
+ *
95
+ * @returns WebhookApi instance
96
+ */
97
+ export async function getWebhookInstance() {
98
+ if (!_webhookInstance) {
99
+ const creds = await getCredentials();
100
+ _webhookInstance = new WebhookApi(BASE_URLS.API, creds.apiKey, creds.agentId);
101
+ }
102
+ return _webhookInstance;
103
+ }
104
+ /**
105
+ * Gets or creates Job API instance.
106
+ * Instance is created once and reused for subsequent calls.
107
+ *
108
+ * @returns JobApi instance
109
+ */
110
+ export async function getJobInstance() {
111
+ if (!_jobInstance) {
112
+ const creds = await getCredentials();
113
+ _jobInstance = new JobApi(BASE_URLS.API, creds.apiKey, creds.agentId);
114
+ }
115
+ return _jobInstance;
116
+ }
117
+ /**
118
+ * Gets or creates Chat API instance.
119
+ * Instance is created once and reused for subsequent calls.
120
+ *
121
+ * @returns ChatApi instance
122
+ */
123
+ export async function getChatInstance() {
124
+ if (!_chatInstance) {
125
+ const creds = await getCredentials();
126
+ _chatInstance = new ChatApi(BASE_URLS.API, creds.apiKey);
127
+ }
128
+ return _chatInstance;
129
+ }
85
130
  /**
86
131
  * Clears all cached API instances.
87
132
  * Useful for testing or when credentials change.
@@ -92,4 +137,7 @@ export function clearAllInstances() {
92
137
  _productsInstance = null;
93
138
  _basketsInstance = null;
94
139
  _orderInstance = null;
140
+ _webhookInstance = null;
141
+ _jobInstance = null;
142
+ _chatInstance = null;
95
143
  }