lua-cli 2.5.8 → 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 (98) hide show
  1. package/dist/api/job.api.service.d.ts +210 -0
  2. package/dist/api/job.api.service.js +200 -0
  3. package/dist/api/lazy-instances.d.ts +24 -0
  4. package/dist/api/lazy-instances.js +48 -0
  5. package/dist/api/postprocessor.api.service.d.ts +98 -0
  6. package/dist/api/postprocessor.api.service.js +76 -0
  7. package/dist/api/preprocessor.api.service.d.ts +98 -0
  8. package/dist/api/preprocessor.api.service.js +76 -0
  9. package/dist/api/user.data.api.service.d.ts +13 -0
  10. package/dist/api/user.data.api.service.js +20 -0
  11. package/dist/api/webhook.api.service.d.ts +151 -0
  12. package/dist/api/webhook.api.service.js +134 -0
  13. package/dist/api-exports.d.ts +156 -41
  14. package/dist/api-exports.js +182 -21
  15. package/dist/cli/command-definitions.js +75 -5
  16. package/dist/commands/compile.js +124 -5
  17. package/dist/commands/index.d.ts +4 -0
  18. package/dist/commands/index.js +4 -0
  19. package/dist/commands/init.js +53 -7
  20. package/dist/commands/jobs.d.ts +20 -0
  21. package/dist/commands/jobs.js +533 -0
  22. package/dist/commands/logs.js +2 -5
  23. package/dist/commands/postprocessors.d.ts +8 -0
  24. package/dist/commands/postprocessors.js +431 -0
  25. package/dist/commands/preprocessors.d.ts +8 -0
  26. package/dist/commands/preprocessors.js +431 -0
  27. package/dist/commands/push.js +684 -5
  28. package/dist/commands/test.d.ts +9 -18
  29. package/dist/commands/test.js +558 -82
  30. package/dist/commands/webhooks.d.ts +18 -0
  31. package/dist/commands/webhooks.js +424 -0
  32. package/dist/common/job.instance.d.ts +77 -0
  33. package/dist/common/job.instance.js +108 -0
  34. package/dist/common/user.instance.d.ts +1 -0
  35. package/dist/common/user.instance.js +9 -0
  36. package/dist/config/constants.d.ts +2 -2
  37. package/dist/config/constants.js +4 -4
  38. package/dist/interfaces/agent.d.ts +2 -1
  39. package/dist/interfaces/chat.d.ts +22 -0
  40. package/dist/interfaces/index.d.ts +10 -0
  41. package/dist/interfaces/index.js +7 -0
  42. package/dist/interfaces/jobs.d.ts +172 -0
  43. package/dist/interfaces/jobs.js +5 -0
  44. package/dist/interfaces/postprocessors.d.ts +35 -0
  45. package/dist/interfaces/postprocessors.js +4 -0
  46. package/dist/interfaces/preprocessors.d.ts +35 -0
  47. package/dist/interfaces/preprocessors.js +4 -0
  48. package/dist/interfaces/webhooks.d.ts +104 -0
  49. package/dist/interfaces/webhooks.js +5 -0
  50. package/dist/types/api-contracts.d.ts +5 -0
  51. package/dist/types/compile.types.d.ts +49 -0
  52. package/dist/types/index.d.ts +1 -1
  53. package/dist/types/index.js +1 -1
  54. package/dist/types/skill.d.ts +502 -0
  55. package/dist/types/skill.js +477 -0
  56. package/dist/utils/agent-management.d.ts +25 -0
  57. package/dist/utils/agent-management.js +67 -0
  58. package/dist/utils/bundling.d.ts +31 -1
  59. package/dist/utils/bundling.js +653 -10
  60. package/dist/utils/compile.d.ts +63 -0
  61. package/dist/utils/compile.js +691 -36
  62. package/dist/utils/deployment.d.ts +2 -1
  63. package/dist/utils/deployment.js +16 -2
  64. package/dist/utils/init-agent.d.ts +3 -1
  65. package/dist/utils/init-agent.js +6 -4
  66. package/dist/utils/init-prompts.d.ts +2 -1
  67. package/dist/utils/init-prompts.js +14 -9
  68. package/dist/utils/job-management.d.ts +24 -0
  69. package/dist/utils/job-management.js +264 -0
  70. package/dist/utils/postprocessor-management.d.ts +9 -0
  71. package/dist/utils/postprocessor-management.js +118 -0
  72. package/dist/utils/preprocessor-management.d.ts +9 -0
  73. package/dist/utils/preprocessor-management.js +118 -0
  74. package/dist/utils/sandbox.d.ts +61 -1
  75. package/dist/utils/sandbox.js +283 -72
  76. package/dist/utils/tool-detection.d.ts +3 -2
  77. package/dist/utils/tool-detection.js +18 -4
  78. package/dist/utils/webhook-management.d.ts +24 -0
  79. package/dist/utils/webhook-management.js +256 -0
  80. package/package.json +1 -1
  81. package/template/AGENT_CONFIGURATION.md +251 -0
  82. package/template/COMPLEX_JOB_EXAMPLES.md +795 -0
  83. package/template/DYNAMIC_JOB_CREATION.md +371 -0
  84. package/template/README.md +30 -2
  85. package/template/WEBHOOKS_JOBS_QUICKSTART.md +318 -0
  86. package/template/WEBHOOK_JOB_EXAMPLES.md +817 -0
  87. package/template/src/index-agent-example.ts +201 -0
  88. package/template/src/index.ts +39 -0
  89. package/template/src/jobs/AbandonedBasketProcessorJob.ts +139 -0
  90. package/template/src/jobs/DailyCleanupJob.ts +100 -0
  91. package/template/src/jobs/DataMigrationJob.ts +133 -0
  92. package/template/src/jobs/HealthCheckJob.ts +87 -0
  93. package/template/src/postprocessors/ResponseFormatter.ts +151 -0
  94. package/template/src/preprocessors/MessageFilter.ts +91 -0
  95. package/template/src/tools/GameScoreTrackerTool.ts +356 -0
  96. package/template/src/tools/SmartBasketTool.ts +188 -0
  97. package/template/src/webhooks/PaymentWebhook.ts +113 -0
  98. package/template/src/webhooks/UserEventWebhook.ts +77 -0
@@ -0,0 +1,98 @@
1
+ import { HttpClient } from "../common/http.client.js";
2
+ import { ApiResponse } from "../interfaces/common.js";
3
+ /**
4
+ * PreProcessor API Response Types
5
+ */
6
+ export interface PreProcessorVersion {
7
+ version: string;
8
+ preprocessorId: string;
9
+ createdAt: string | number;
10
+ isActive?: boolean;
11
+ }
12
+ export interface GetPreProcessorsResponse {
13
+ preprocessors: Array<{
14
+ id: string;
15
+ name: string;
16
+ description?: string;
17
+ context?: string;
18
+ versions: PreProcessorVersion[];
19
+ activeVersionId?: string;
20
+ }>;
21
+ }
22
+ export interface CreatePreProcessorResponse {
23
+ id: string;
24
+ name: string;
25
+ description?: string;
26
+ agentId: string;
27
+ context?: string;
28
+ }
29
+ export interface PreProcessorVersionResponse {
30
+ versionId: string;
31
+ preprocessorId: string;
32
+ version: string;
33
+ createdAt: string;
34
+ }
35
+ export interface DeletePreProcessorResponse {
36
+ deleted: boolean;
37
+ deactivated?: boolean;
38
+ message: string;
39
+ }
40
+ /**
41
+ * PreProcessor API Service
42
+ * Handles all preprocessor-related API calls
43
+ */
44
+ export default class PreProcessorApi extends HttpClient {
45
+ private apiKey;
46
+ private agentId;
47
+ constructor(baseUrl: string, apiKey: string, agentId: string);
48
+ /**
49
+ * Retrieves all preprocessors for the agent
50
+ */
51
+ getPreProcessors(): Promise<ApiResponse<GetPreProcessorsResponse>>;
52
+ /**
53
+ * Creates a new preprocessor for the agent
54
+ */
55
+ createPreProcessor(data: {
56
+ name: string;
57
+ description?: string;
58
+ context?: string;
59
+ }): Promise<ApiResponse<CreatePreProcessorResponse>>;
60
+ /**
61
+ * Pushes a new version of a preprocessor
62
+ */
63
+ pushPreProcessor(preprocessorId: string, versionData: any): Promise<ApiResponse<PreProcessorVersionResponse>>;
64
+ /**
65
+ * Retrieves all versions of a specific preprocessor
66
+ */
67
+ getPreProcessorVersions(preprocessorId: string): Promise<ApiResponse<{
68
+ versions: PreProcessorVersion[];
69
+ activeVersionId?: string;
70
+ }>>;
71
+ /**
72
+ * Publishes a specific version of a preprocessor to production
73
+ */
74
+ publishPreProcessorVersion(preprocessorId: string, version: string): Promise<ApiResponse<{
75
+ message: string;
76
+ preprocessorId: string;
77
+ activeVersionId: string;
78
+ publishedAt: string;
79
+ }>>;
80
+ /**
81
+ * Activates a preprocessor
82
+ */
83
+ activatePreProcessor(preprocessorId: string): Promise<ApiResponse<{
84
+ message: string;
85
+ active: boolean;
86
+ }>>;
87
+ /**
88
+ * Deactivates a preprocessor
89
+ */
90
+ deactivatePreProcessor(preprocessorId: string): Promise<ApiResponse<{
91
+ message: string;
92
+ active: boolean;
93
+ }>>;
94
+ /**
95
+ * Deletes a preprocessor
96
+ */
97
+ deletePreProcessor(preprocessorId: string): Promise<ApiResponse<DeletePreProcessorResponse>>;
98
+ }
@@ -0,0 +1,76 @@
1
+ import { HttpClient } from "../common/http.client.js";
2
+ /**
3
+ * PreProcessor API Service
4
+ * Handles all preprocessor-related API calls
5
+ */
6
+ export default class PreProcessorApi extends HttpClient {
7
+ constructor(baseUrl, apiKey, agentId) {
8
+ super(baseUrl);
9
+ this.apiKey = apiKey;
10
+ this.agentId = agentId;
11
+ }
12
+ /**
13
+ * Retrieves all preprocessors for the agent
14
+ */
15
+ async getPreProcessors() {
16
+ return this.httpGet(`/developer/preprocessors/${this.agentId}`, {
17
+ Authorization: `Bearer ${this.apiKey}`,
18
+ });
19
+ }
20
+ /**
21
+ * Creates a new preprocessor for the agent
22
+ */
23
+ async createPreProcessor(data) {
24
+ return this.httpPost(`/developer/preprocessors/${this.agentId}`, data, {
25
+ Authorization: `Bearer ${this.apiKey}`,
26
+ });
27
+ }
28
+ /**
29
+ * Pushes a new version of a preprocessor
30
+ */
31
+ async pushPreProcessor(preprocessorId, versionData) {
32
+ return this.httpPost(`/developer/preprocessors/${this.agentId}/${preprocessorId}/version`, versionData, {
33
+ Authorization: `Bearer ${this.apiKey}`,
34
+ });
35
+ }
36
+ /**
37
+ * Retrieves all versions of a specific preprocessor
38
+ */
39
+ async getPreProcessorVersions(preprocessorId) {
40
+ return this.httpGet(`/developer/preprocessors/${this.agentId}/${preprocessorId}/versions`, {
41
+ Authorization: `Bearer ${this.apiKey}`,
42
+ });
43
+ }
44
+ /**
45
+ * Publishes a specific version of a preprocessor to production
46
+ */
47
+ async publishPreProcessorVersion(preprocessorId, version) {
48
+ return this.httpPost(`/developer/preprocessors/${this.agentId}/${preprocessorId}/${version}/publish`, {}, {
49
+ Authorization: `Bearer ${this.apiKey}`,
50
+ });
51
+ }
52
+ /**
53
+ * Activates a preprocessor
54
+ */
55
+ async activatePreProcessor(preprocessorId) {
56
+ return this.httpPost(`/developer/preprocessors/${this.agentId}/${preprocessorId}/activate`, {}, {
57
+ Authorization: `Bearer ${this.apiKey}`,
58
+ });
59
+ }
60
+ /**
61
+ * Deactivates a preprocessor
62
+ */
63
+ async deactivatePreProcessor(preprocessorId) {
64
+ return this.httpPost(`/developer/preprocessors/${this.agentId}/${preprocessorId}/deactivate`, {}, {
65
+ Authorization: `Bearer ${this.apiKey}`,
66
+ });
67
+ }
68
+ /**
69
+ * Deletes a preprocessor
70
+ */
71
+ async deletePreProcessor(preprocessorId) {
72
+ return this.httpDelete(`/developer/preprocessors/${this.agentId}/${preprocessorId}`, {
73
+ Authorization: `Bearer ${this.apiKey}`,
74
+ });
75
+ }
76
+ }
@@ -2,6 +2,7 @@ import { HttpClient } from "../common/http.client.js";
2
2
  import UserDataInstance from "../common/user.instance.js";
3
3
  import { Message } from "../interfaces/message.js";
4
4
  import { UserDataAPI } from "../types/index.js";
5
+ import { ChatHistoryMessage } from "../interfaces/chat.js";
5
6
  export default class UserDataApi extends HttpClient implements UserDataAPI {
6
7
  private apiKey;
7
8
  private agentId;
@@ -45,4 +46,16 @@ export default class UserDataApi extends HttpClient implements UserDataAPI {
45
46
  * @throws Error if the admin user cannot be retrieved or the request is unsuccessful
46
47
  */
47
48
  getAdminUser(): Promise<any>;
49
+ /**
50
+ * Gets the chat history for the current user and agent
51
+ * @returns Promise resolving to an array of chat messages
52
+ * @throws Error if the chat history cannot be retrieved or the request is unsuccessful
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const history = await User.getChatHistory();
57
+ * // Returns: [{ role: 'user', content: [...], createdAt: '...' }, ...]
58
+ * ```
59
+ */
60
+ getChatHistory(): Promise<ChatHistoryMessage[]>;
48
61
  }
@@ -87,4 +87,24 @@ export default class UserDataApi extends HttpClient {
87
87
  }
88
88
  return response.data;
89
89
  }
90
+ /**
91
+ * Gets the chat history for the current user and agent
92
+ * @returns Promise resolving to an array of chat messages
93
+ * @throws Error if the chat history cannot be retrieved or the request is unsuccessful
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * const history = await User.getChatHistory();
98
+ * // Returns: [{ role: 'user', content: [...], createdAt: '...' }, ...]
99
+ * ```
100
+ */
101
+ async getChatHistory() {
102
+ const response = await this.httpGet(`/chat/history/${this.agentId}`, {
103
+ Authorization: `Bearer ${this.apiKey}`,
104
+ });
105
+ if (!response.success) {
106
+ throw new Error(response.error?.message || 'Failed to get chat history');
107
+ }
108
+ return response.data || [];
109
+ }
90
110
  }
@@ -0,0 +1,151 @@
1
+ import { HttpClient } from "../common/http.client.js";
2
+ import { ApiResponse } from "../interfaces/common.js";
3
+ import { CreateWebhookDTO, PushWebhookVersionDTO, UpdateWebhookVersionDTO } from "../interfaces/webhooks.js";
4
+ /**
5
+ * Webhook API Response Types
6
+ */
7
+ export interface WebhookVersion {
8
+ version: string;
9
+ webhookId: string;
10
+ createdAt: string | number;
11
+ isActive?: boolean;
12
+ }
13
+ export interface GetWebhooksResponse {
14
+ webhooks: Array<{
15
+ id: string;
16
+ name: string;
17
+ description?: string;
18
+ context?: string;
19
+ versions: WebhookVersion[];
20
+ activeVersionId?: string;
21
+ }>;
22
+ }
23
+ export interface CreateWebhookResponse {
24
+ id: string;
25
+ name: string;
26
+ description?: string;
27
+ agentId: string;
28
+ context?: string;
29
+ }
30
+ export interface WebhookVersionResponse {
31
+ versionId: string;
32
+ webhookId: string;
33
+ version: string;
34
+ createdAt: string;
35
+ }
36
+ export interface UpdateWebhookVersionResponse {
37
+ versionId: string;
38
+ webhookId: string;
39
+ version: string;
40
+ updatedAt: string;
41
+ }
42
+ export interface DeleteWebhookResponse {
43
+ deleted: boolean;
44
+ deactivated?: boolean;
45
+ message: string;
46
+ }
47
+ /**
48
+ * Webhook API Service
49
+ * Handles all webhook-related API calls
50
+ */
51
+ export default class WebhookApi extends HttpClient {
52
+ private apiKey;
53
+ private agentId;
54
+ /**
55
+ * Creates an instance of WebhookApi
56
+ * @param baseUrl - The base URL for the API
57
+ * @param apiKey - The API key for authentication
58
+ * @param agentId - The unique identifier of the agent
59
+ */
60
+ constructor(baseUrl: string, apiKey: string, agentId: string);
61
+ /**
62
+ * Retrieves all webhooks for the agent
63
+ * @returns Promise resolving to an ApiResponse containing an array of webhooks with their versions
64
+ * @throws Error if the API request fails or the agent is not found
65
+ */
66
+ getWebhooks(): Promise<ApiResponse<GetWebhooksResponse>>;
67
+ /**
68
+ * Creates a new webhook for the agent
69
+ * @param webhookData - The webhook data including name, description, and optional context
70
+ * @returns Promise resolving to an ApiResponse containing the created webhook details
71
+ * @throws Error if the webhook creation fails or validation errors occur
72
+ */
73
+ createWebhook(webhookData: CreateWebhookDTO): Promise<ApiResponse<CreateWebhookResponse>>;
74
+ /**
75
+ * Pushes a new version of a webhook to production
76
+ * @param webhookId - The unique identifier of the webhook
77
+ * @param versionData - The version data including code, configuration, and metadata
78
+ * @returns Promise resolving to an ApiResponse containing the created version details
79
+ * @throws Error if the webhook is not found or the push operation fails
80
+ */
81
+ pushWebhook(webhookId: string, versionData: PushWebhookVersionDTO): Promise<ApiResponse<WebhookVersionResponse>>;
82
+ /**
83
+ * Pushes a new development/sandbox version of a webhook for testing
84
+ * @param webhookId - The unique identifier of the webhook
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 webhook is not found or the push operation fails
88
+ */
89
+ pushDevWebhook(webhookId: string, versionData: PushWebhookVersionDTO): Promise<ApiResponse<WebhookVersionResponse>>;
90
+ /**
91
+ * Updates an existing development/sandbox version of a webhook
92
+ * @param webhookId - The unique identifier of the webhook
93
+ * @param sandboxVersionId - The unique identifier of the sandbox version to update
94
+ * @param versionData - The updated version data including code, configuration, and metadata
95
+ * @returns Promise resolving to an ApiResponse containing the updated version details
96
+ * @throws Error if the webhook or version is not found or the update fails
97
+ */
98
+ updateDevWebhook(webhookId: string, sandboxVersionId: string, versionData: UpdateWebhookVersionDTO): Promise<ApiResponse<UpdateWebhookVersionResponse>>;
99
+ /**
100
+ * Retrieves all versions of a specific webhook
101
+ * @param webhookId - The unique identifier of the webhook
102
+ * @returns Promise resolving to an ApiResponse containing an array of webhook versions
103
+ * @throws Error if the webhook is not found or the request fails
104
+ */
105
+ getWebhookVersions(webhookId: string): Promise<ApiResponse<{
106
+ versions: WebhookVersion[];
107
+ activeVersionId?: string;
108
+ }>>;
109
+ /**
110
+ * Publishes a specific version of a webhook to production
111
+ * @param webhookId - The unique identifier of the webhook
112
+ * @param version - The version identifier to publish
113
+ * @returns Promise resolving to an ApiResponse containing publication confirmation details
114
+ * @throws Error if the webhook or version is not found or the publish operation fails
115
+ */
116
+ publishWebhookVersion(webhookId: string, version: string): Promise<ApiResponse<{
117
+ message: string;
118
+ webhookId: string;
119
+ activeVersionId: string;
120
+ publishedAt: string;
121
+ }>>;
122
+ /**
123
+ * Activates a webhook (enables it to receive requests)
124
+ * @param webhookId - The unique identifier of the webhook to activate
125
+ * @returns Promise resolving to an ApiResponse with activation status
126
+ * @throws Error if the webhook is not found or the operation fails
127
+ */
128
+ activateWebhook(webhookId: string): Promise<ApiResponse<{
129
+ message: string;
130
+ active: boolean;
131
+ }>>;
132
+ /**
133
+ * Deactivates a webhook (stops it from receiving requests)
134
+ * @param webhookId - The unique identifier of the webhook to deactivate
135
+ * @returns Promise resolving to an ApiResponse with deactivation status
136
+ * @throws Error if the webhook is not found or the operation fails
137
+ */
138
+ deactivateWebhook(webhookId: string): Promise<ApiResponse<{
139
+ message: string;
140
+ active: boolean;
141
+ }>>;
142
+ /**
143
+ * Deletes a webhook and all its versions, or deactivates it if it has versions
144
+ * @param webhookId - The unique identifier of the webhook to delete
145
+ * @returns Promise resolving to an ApiResponse with deletion status
146
+ * - If deleted is true: webhook was successfully deleted
147
+ * - If deleted is false and deactivated is true: webhook has versions and was deactivated instead
148
+ * @throws Error if the webhook is not found or the delete operation fails
149
+ */
150
+ deleteWebhook(webhookId: string): Promise<ApiResponse<DeleteWebhookResponse>>;
151
+ }
@@ -0,0 +1,134 @@
1
+ import { HttpClient } from "../common/http.client.js";
2
+ /**
3
+ * Webhook API Service
4
+ * Handles all webhook-related API calls
5
+ */
6
+ export default class WebhookApi extends HttpClient {
7
+ /**
8
+ * Creates an instance of WebhookApi
9
+ * @param baseUrl - The base URL for the API
10
+ * @param apiKey - The API key for authentication
11
+ * @param agentId - The unique identifier of the agent
12
+ */
13
+ constructor(baseUrl, apiKey, agentId) {
14
+ super(baseUrl);
15
+ this.apiKey = apiKey;
16
+ this.agentId = agentId;
17
+ }
18
+ /**
19
+ * Retrieves all webhooks for the agent
20
+ * @returns Promise resolving to an ApiResponse containing an array of webhooks with their versions
21
+ * @throws Error if the API request fails or the agent is not found
22
+ */
23
+ async getWebhooks() {
24
+ return this.httpGet(`/developer/webhooks/${this.agentId}`, {
25
+ Authorization: `Bearer ${this.apiKey}`,
26
+ });
27
+ }
28
+ /**
29
+ * Creates a new webhook for the agent
30
+ * @param webhookData - The webhook data including name, description, and optional context
31
+ * @returns Promise resolving to an ApiResponse containing the created webhook details
32
+ * @throws Error if the webhook creation fails or validation errors occur
33
+ */
34
+ async createWebhook(webhookData) {
35
+ return this.httpPost(`/developer/webhooks/${this.agentId}`, webhookData, {
36
+ Authorization: `Bearer ${this.apiKey}`,
37
+ });
38
+ }
39
+ /**
40
+ * Pushes a new version of a webhook to production
41
+ * @param webhookId - The unique identifier of the webhook
42
+ * @param versionData - The version data including code, configuration, and metadata
43
+ * @returns Promise resolving to an ApiResponse containing the created version details
44
+ * @throws Error if the webhook is not found or the push operation fails
45
+ */
46
+ async pushWebhook(webhookId, versionData) {
47
+ return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/version`, versionData, {
48
+ Authorization: `Bearer ${this.apiKey}`,
49
+ });
50
+ }
51
+ /**
52
+ * Pushes a new development/sandbox version of a webhook for testing
53
+ * @param webhookId - The unique identifier of the webhook
54
+ * @param versionData - The version data including code, configuration, and metadata
55
+ * @returns Promise resolving to an ApiResponse containing the development version details
56
+ * @throws Error if the webhook is not found or the push operation fails
57
+ */
58
+ async pushDevWebhook(webhookId, versionData) {
59
+ return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/version/sandbox`, versionData, {
60
+ Authorization: `Bearer ${this.apiKey}`,
61
+ });
62
+ }
63
+ /**
64
+ * Updates an existing development/sandbox version of a webhook
65
+ * @param webhookId - The unique identifier of the webhook
66
+ * @param sandboxVersionId - The unique identifier of the sandbox version to update
67
+ * @param versionData - The updated version data including code, configuration, and metadata
68
+ * @returns Promise resolving to an ApiResponse containing the updated version details
69
+ * @throws Error if the webhook or version is not found or the update fails
70
+ */
71
+ async updateDevWebhook(webhookId, sandboxVersionId, versionData) {
72
+ return this.httpPut(`/developer/webhooks/${this.agentId}/${webhookId}/version/sandbox/${sandboxVersionId}`, versionData, {
73
+ Authorization: `Bearer ${this.apiKey}`,
74
+ });
75
+ }
76
+ /**
77
+ * Retrieves all versions of a specific webhook
78
+ * @param webhookId - The unique identifier of the webhook
79
+ * @returns Promise resolving to an ApiResponse containing an array of webhook versions
80
+ * @throws Error if the webhook is not found or the request fails
81
+ */
82
+ async getWebhookVersions(webhookId) {
83
+ return this.httpGet(`/developer/webhooks/${this.agentId}/${webhookId}/versions`, {
84
+ Authorization: `Bearer ${this.apiKey}`,
85
+ });
86
+ }
87
+ /**
88
+ * Publishes a specific version of a webhook to production
89
+ * @param webhookId - The unique identifier of the webhook
90
+ * @param version - The version identifier to publish
91
+ * @returns Promise resolving to an ApiResponse containing publication confirmation details
92
+ * @throws Error if the webhook or version is not found or the publish operation fails
93
+ */
94
+ async publishWebhookVersion(webhookId, version) {
95
+ return this.httpPut(`/developer/webhooks/${this.agentId}/${webhookId}/${version}/publish`, undefined, {
96
+ Authorization: `Bearer ${this.apiKey}`,
97
+ });
98
+ }
99
+ /**
100
+ * Activates a webhook (enables it to receive requests)
101
+ * @param webhookId - The unique identifier of the webhook to activate
102
+ * @returns Promise resolving to an ApiResponse with activation status
103
+ * @throws Error if the webhook is not found or the operation fails
104
+ */
105
+ async activateWebhook(webhookId) {
106
+ return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/activate`, {}, {
107
+ Authorization: `Bearer ${this.apiKey}`,
108
+ });
109
+ }
110
+ /**
111
+ * Deactivates a webhook (stops it from receiving requests)
112
+ * @param webhookId - The unique identifier of the webhook to deactivate
113
+ * @returns Promise resolving to an ApiResponse with deactivation status
114
+ * @throws Error if the webhook is not found or the operation fails
115
+ */
116
+ async deactivateWebhook(webhookId) {
117
+ return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/deactivate`, {}, {
118
+ Authorization: `Bearer ${this.apiKey}`,
119
+ });
120
+ }
121
+ /**
122
+ * Deletes a webhook and all its versions, or deactivates it if it has versions
123
+ * @param webhookId - The unique identifier of the webhook to delete
124
+ * @returns Promise resolving to an ApiResponse with deletion status
125
+ * - If deleted is true: webhook was successfully deleted
126
+ * - If deleted is false and deactivated is true: webhook has versions and was deactivated instead
127
+ * @throws Error if the webhook is not found or the delete operation fails
128
+ */
129
+ async deleteWebhook(webhookId) {
130
+ return this.httpDelete(`/developer/webhooks/${this.agentId}/${webhookId}`, {
131
+ Authorization: `Bearer ${this.apiKey}`,
132
+ });
133
+ }
134
+ }