@axiom-lattice/client-sdk 2.1.11 → 2.1.13

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/dist/index.mjs CHANGED
@@ -1840,6 +1840,20 @@ var AuthenticationError = class extends Error {
1840
1840
  this.name = "AuthenticationError";
1841
1841
  }
1842
1842
  };
1843
+ var ScheduleExecutionType = /* @__PURE__ */ ((ScheduleExecutionType2) => {
1844
+ ScheduleExecutionType2["ONCE"] = "once";
1845
+ ScheduleExecutionType2["CRON"] = "cron";
1846
+ return ScheduleExecutionType2;
1847
+ })(ScheduleExecutionType || {});
1848
+ var ScheduledTaskStatus = /* @__PURE__ */ ((ScheduledTaskStatus2) => {
1849
+ ScheduledTaskStatus2["PENDING"] = "pending";
1850
+ ScheduledTaskStatus2["RUNNING"] = "running";
1851
+ ScheduledTaskStatus2["COMPLETED"] = "completed";
1852
+ ScheduledTaskStatus2["FAILED"] = "failed";
1853
+ ScheduledTaskStatus2["CANCELLED"] = "cancelled";
1854
+ ScheduledTaskStatus2["PAUSED"] = "paused";
1855
+ return ScheduledTaskStatus2;
1856
+ })(ScheduledTaskStatus || {});
1843
1857
 
1844
1858
  // src/abstract-client.ts
1845
1859
  var AbstractClient = class {
@@ -2139,6 +2153,99 @@ var AbstractClient = class {
2139
2153
  }
2140
2154
  }
2141
2155
  };
2156
+ /**
2157
+ * Schedules namespace for managing scheduled tasks
2158
+ */
2159
+ this.schedules = {
2160
+ /**
2161
+ * Gets scheduled tasks for a specific thread
2162
+ * @param options - Options for getting scheduled tasks
2163
+ * @returns A promise that resolves to the list of scheduled tasks
2164
+ */
2165
+ getByThread: async (options) => {
2166
+ try {
2167
+ let url = `/api/assistants/${this.assistantId}/threads/${options.threadId}/schedules`;
2168
+ const params = new URLSearchParams();
2169
+ if (options.status) {
2170
+ params.append("status", options.status);
2171
+ }
2172
+ if (options.limit !== void 0) {
2173
+ params.append("limit", options.limit.toString());
2174
+ }
2175
+ if (options.offset !== void 0) {
2176
+ params.append("offset", options.offset.toString());
2177
+ }
2178
+ const queryString = params.toString();
2179
+ if (queryString) {
2180
+ url += `?${queryString}`;
2181
+ }
2182
+ const response = await this.makeRequest(
2183
+ url
2184
+ );
2185
+ return response.data.records;
2186
+ } catch (error) {
2187
+ throw error;
2188
+ }
2189
+ },
2190
+ /**
2191
+ * Gets a single scheduled task by ID
2192
+ * @param taskId - Task identifier
2193
+ * @returns A promise that resolves to the scheduled task or null
2194
+ */
2195
+ get: async (taskId) => {
2196
+ try {
2197
+ const response = await this.makeRequest(`/api/schedules/${taskId}`);
2198
+ return response.data;
2199
+ } catch (error) {
2200
+ throw error;
2201
+ }
2202
+ },
2203
+ /**
2204
+ * Cancels a scheduled task
2205
+ * @param taskId - Task identifier
2206
+ * @returns A promise that resolves when the task is cancelled
2207
+ */
2208
+ cancel: async (taskId) => {
2209
+ try {
2210
+ const response = await this.makeRequest(`/api/schedules/${taskId}/cancel`, {
2211
+ method: "POST"
2212
+ });
2213
+ return response.success;
2214
+ } catch (error) {
2215
+ throw error;
2216
+ }
2217
+ },
2218
+ /**
2219
+ * Pauses a scheduled cron task
2220
+ * @param taskId - Task identifier
2221
+ * @returns A promise that resolves when the task is paused
2222
+ */
2223
+ pause: async (taskId) => {
2224
+ try {
2225
+ const response = await this.makeRequest(`/api/schedules/${taskId}/pause`, {
2226
+ method: "POST"
2227
+ });
2228
+ return response.success;
2229
+ } catch (error) {
2230
+ throw error;
2231
+ }
2232
+ },
2233
+ /**
2234
+ * Resumes a paused cron task
2235
+ * @param taskId - Task identifier
2236
+ * @returns A promise that resolves when the task is resumed
2237
+ */
2238
+ resume: async (taskId) => {
2239
+ try {
2240
+ const response = await this.makeRequest(`/api/schedules/${taskId}/resume`, {
2241
+ method: "POST"
2242
+ });
2243
+ return response.success;
2244
+ } catch (error) {
2245
+ throw error;
2246
+ }
2247
+ }
2248
+ };
2142
2249
  this.config = {
2143
2250
  timeout: 3e5,
2144
2251
  // Default timeout
@@ -3164,6 +3271,8 @@ export {
3164
3271
  AuthenticationError,
3165
3272
  Client,
3166
3273
  NetworkError,
3274
+ ScheduleExecutionType,
3275
+ ScheduledTaskStatus,
3167
3276
  WeChatClient,
3168
3277
  createSimpleMessageMerger
3169
3278
  };