@alva-ai/toolkit 0.16.1-beta.0 → 0.16.1-beta.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.
package/dist/index.d.cts CHANGED
@@ -15,9 +15,14 @@ interface AlvaClientConfig {
15
15
  interface UserProfile {
16
16
  id: string;
17
17
  username: string;
18
- subscription_tier: 'free' | 'pro';
19
- telegram_username: string | null;
20
- slack_username: string | null;
18
+ subscription_tier: 'free' | 'pro' | 'max';
19
+ telegram_username: string;
20
+ discord_username: string;
21
+ slack_username: string;
22
+ whatsapp_username: string;
23
+ imessage_username: string;
24
+ active_channel: string;
25
+ toolkit_min_version: string;
21
26
  /** Caller's alfs home directory, e.g. `/alva/home/<username>`. */
22
27
  home_path: string;
23
28
  }
@@ -194,13 +199,14 @@ interface CronjobCreateRequest {
194
199
  * A string: SA ids are snowflake int64s that overflow JS number precision.
195
200
  */
196
201
  run_as_user_id?: string;
202
+ /** Inclusive RFC3339 lower bound. Omitted means start now (server clock). */
203
+ start_at?: string;
197
204
  /**
198
- * Lifetime ceiling (RFC3339 timestamp). Once now >= end_at the runner
199
- * self-terminates the cronjob before running (backend#1799). Omitted ⇒ no
200
- * expiry. The `alva loop create` sugar sets this to now + (expires_in ?? 7d);
201
- * feeds and other crons leave it unset.
205
+ * Exclusive RFC3339 upper bound. A run is admitted only while now < end_at.
202
206
  */
203
207
  end_at?: string;
208
+ /** Maximum number of admitted runs. */
209
+ max_runs?: number;
204
210
  }
205
211
  interface Cronjob {
206
212
  id: number;
@@ -217,11 +223,17 @@ interface Cronjob {
217
223
  * A string: snowflake int64 ids overflow JS number precision.
218
224
  */
219
225
  run_as_user_id: string;
226
+ /** Inclusive eligibility lower bound, resolved by the server on create. */
227
+ start_at?: string | null;
220
228
  /**
221
229
  * Lifetime ceiling (RFC3339), or null/omitted when the cronjob has no expiry.
222
230
  * Set by `alva loop create`; unset for feeds and other crons.
223
231
  */
224
232
  end_at?: string | null;
233
+ /** Maximum admitted runs, or null when unbounded by count. */
234
+ max_runs?: number | null;
235
+ /** Number of runs admitted so far. */
236
+ run_count: number;
225
237
  created_at: string;
226
238
  updated_at: string;
227
239
  }
@@ -282,6 +294,22 @@ interface CronjobRunsListResponse {
282
294
  stats?: CronjobRunStats;
283
295
  next_cursor?: number;
284
296
  }
297
+ interface CronjobRunStatusParams {
298
+ cronjob_id: number;
299
+ workflow_run_id: string;
300
+ }
301
+ interface CronjobRunStatusResponse {
302
+ workflow_run_id: string;
303
+ /**
304
+ * PENDING means no cronjob_runs row exists yet. It is not falsifiable:
305
+ * a mistyped workflow_run_id, a workflow_run_id from another cronjob, or
306
+ * a workflow that failed before persistence can remain PENDING forever.
307
+ * DISPATCHED and RUNNING mean an in-flight row exists. Pollers must stop
308
+ * on their own deadline if the run never reaches a terminal state.
309
+ */
310
+ state: 'PENDING' | 'DISPATCHED' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'SKIPPED' | 'UNSPECIFIED' | string;
311
+ run?: CronjobRun;
312
+ }
285
313
  interface CronjobRunLogsResponse {
286
314
  logs: string;
287
315
  }
@@ -289,8 +317,9 @@ interface CronjobTriggerResponse {
289
317
  /**
290
318
  * Hatchet workflow run id at enqueue. Async — the persisted
291
319
  * `cronjob_runs` row appears only after the worker finishes the run.
292
- * Callers verify completion by polling `deploy.listRuns({cronjob_id})`
293
- * and matching `runs[].workflow_run_id` against this value.
320
+ * Callers verify completion by polling
321
+ * `deploy.getRunStatus({cronjob_id, workflow_run_id})` with their own
322
+ * timeout/deadline.
294
323
  */
295
324
  workflow_run_id: string;
296
325
  }
@@ -790,8 +819,8 @@ interface PushSubscription {
790
819
  */
791
820
  kind?: 'PLAYBOOK_ALERTS' | 'FEED_ALERT' | 'UNSPECIFIED' | string;
792
821
  /**
793
- * Whether the caller also FOLLOWS the target playbook — the social
794
- * relation, distinct from this alert row. Always false for FEED targets.
822
+ * Legacy social playbook-follow signal. Do not use this to decide whether
823
+ * alert delivery is enabled; use kind + target_status instead.
795
824
  */
796
825
  following?: boolean;
797
826
  /**
@@ -1045,9 +1074,10 @@ declare class DeployResource {
1045
1074
  /**
1046
1075
  * Fire the cronjob workflow once, immediately, bypassing the schedule.
1047
1076
  * Async — returns the Hatchet workflow run id at enqueue. The
1048
- * `cronjob_runs` row appears only after the worker finishes the run;
1049
- * callers verify completion by polling `listRuns({cronjob_id})` and
1050
- * matching `runs[].workflow_run_id` against the returned id.
1077
+ * `cronjob_runs` row can appear as DISPATCHED/RUNNING before it reaches a
1078
+ * terminal status; callers verify completion by polling
1079
+ * `getRunStatus({cronjob_id, workflow_run_id})` with their own
1080
+ * timeout/deadline.
1051
1081
  *
1052
1082
  * Surfaces backend status as HTTP errors (handled by AlvaClient):
1053
1083
  * - 404 not found / cross-user
@@ -1058,6 +1088,7 @@ declare class DeployResource {
1058
1088
  id: number;
1059
1089
  }): Promise<CronjobTriggerResponse>;
1060
1090
  listRuns(params: CronjobRunsListParams): Promise<CronjobRunsListResponse>;
1091
+ getRunStatus(params: CronjobRunStatusParams): Promise<CronjobRunStatusResponse>;
1061
1092
  getRunLogs(params: {
1062
1093
  cronjob_id: number;
1063
1094
  run_id: number;
package/dist/index.d.ts CHANGED
@@ -15,9 +15,14 @@ interface AlvaClientConfig {
15
15
  interface UserProfile {
16
16
  id: string;
17
17
  username: string;
18
- subscription_tier: 'free' | 'pro';
19
- telegram_username: string | null;
20
- slack_username: string | null;
18
+ subscription_tier: 'free' | 'pro' | 'max';
19
+ telegram_username: string;
20
+ discord_username: string;
21
+ slack_username: string;
22
+ whatsapp_username: string;
23
+ imessage_username: string;
24
+ active_channel: string;
25
+ toolkit_min_version: string;
21
26
  /** Caller's alfs home directory, e.g. `/alva/home/<username>`. */
22
27
  home_path: string;
23
28
  }
@@ -194,13 +199,14 @@ interface CronjobCreateRequest {
194
199
  * A string: SA ids are snowflake int64s that overflow JS number precision.
195
200
  */
196
201
  run_as_user_id?: string;
202
+ /** Inclusive RFC3339 lower bound. Omitted means start now (server clock). */
203
+ start_at?: string;
197
204
  /**
198
- * Lifetime ceiling (RFC3339 timestamp). Once now >= end_at the runner
199
- * self-terminates the cronjob before running (backend#1799). Omitted ⇒ no
200
- * expiry. The `alva loop create` sugar sets this to now + (expires_in ?? 7d);
201
- * feeds and other crons leave it unset.
205
+ * Exclusive RFC3339 upper bound. A run is admitted only while now < end_at.
202
206
  */
203
207
  end_at?: string;
208
+ /** Maximum number of admitted runs. */
209
+ max_runs?: number;
204
210
  }
205
211
  interface Cronjob {
206
212
  id: number;
@@ -217,11 +223,17 @@ interface Cronjob {
217
223
  * A string: snowflake int64 ids overflow JS number precision.
218
224
  */
219
225
  run_as_user_id: string;
226
+ /** Inclusive eligibility lower bound, resolved by the server on create. */
227
+ start_at?: string | null;
220
228
  /**
221
229
  * Lifetime ceiling (RFC3339), or null/omitted when the cronjob has no expiry.
222
230
  * Set by `alva loop create`; unset for feeds and other crons.
223
231
  */
224
232
  end_at?: string | null;
233
+ /** Maximum admitted runs, or null when unbounded by count. */
234
+ max_runs?: number | null;
235
+ /** Number of runs admitted so far. */
236
+ run_count: number;
225
237
  created_at: string;
226
238
  updated_at: string;
227
239
  }
@@ -282,6 +294,22 @@ interface CronjobRunsListResponse {
282
294
  stats?: CronjobRunStats;
283
295
  next_cursor?: number;
284
296
  }
297
+ interface CronjobRunStatusParams {
298
+ cronjob_id: number;
299
+ workflow_run_id: string;
300
+ }
301
+ interface CronjobRunStatusResponse {
302
+ workflow_run_id: string;
303
+ /**
304
+ * PENDING means no cronjob_runs row exists yet. It is not falsifiable:
305
+ * a mistyped workflow_run_id, a workflow_run_id from another cronjob, or
306
+ * a workflow that failed before persistence can remain PENDING forever.
307
+ * DISPATCHED and RUNNING mean an in-flight row exists. Pollers must stop
308
+ * on their own deadline if the run never reaches a terminal state.
309
+ */
310
+ state: 'PENDING' | 'DISPATCHED' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'SKIPPED' | 'UNSPECIFIED' | string;
311
+ run?: CronjobRun;
312
+ }
285
313
  interface CronjobRunLogsResponse {
286
314
  logs: string;
287
315
  }
@@ -289,8 +317,9 @@ interface CronjobTriggerResponse {
289
317
  /**
290
318
  * Hatchet workflow run id at enqueue. Async — the persisted
291
319
  * `cronjob_runs` row appears only after the worker finishes the run.
292
- * Callers verify completion by polling `deploy.listRuns({cronjob_id})`
293
- * and matching `runs[].workflow_run_id` against this value.
320
+ * Callers verify completion by polling
321
+ * `deploy.getRunStatus({cronjob_id, workflow_run_id})` with their own
322
+ * timeout/deadline.
294
323
  */
295
324
  workflow_run_id: string;
296
325
  }
@@ -790,8 +819,8 @@ interface PushSubscription {
790
819
  */
791
820
  kind?: 'PLAYBOOK_ALERTS' | 'FEED_ALERT' | 'UNSPECIFIED' | string;
792
821
  /**
793
- * Whether the caller also FOLLOWS the target playbook — the social
794
- * relation, distinct from this alert row. Always false for FEED targets.
822
+ * Legacy social playbook-follow signal. Do not use this to decide whether
823
+ * alert delivery is enabled; use kind + target_status instead.
795
824
  */
796
825
  following?: boolean;
797
826
  /**
@@ -1045,9 +1074,10 @@ declare class DeployResource {
1045
1074
  /**
1046
1075
  * Fire the cronjob workflow once, immediately, bypassing the schedule.
1047
1076
  * Async — returns the Hatchet workflow run id at enqueue. The
1048
- * `cronjob_runs` row appears only after the worker finishes the run;
1049
- * callers verify completion by polling `listRuns({cronjob_id})` and
1050
- * matching `runs[].workflow_run_id` against the returned id.
1077
+ * `cronjob_runs` row can appear as DISPATCHED/RUNNING before it reaches a
1078
+ * terminal status; callers verify completion by polling
1079
+ * `getRunStatus({cronjob_id, workflow_run_id})` with their own
1080
+ * timeout/deadline.
1051
1081
  *
1052
1082
  * Surfaces backend status as HTTP errors (handled by AlvaClient):
1053
1083
  * - 404 not found / cross-user
@@ -1058,6 +1088,7 @@ declare class DeployResource {
1058
1088
  id: number;
1059
1089
  }): Promise<CronjobTriggerResponse>;
1060
1090
  listRuns(params: CronjobRunsListParams): Promise<CronjobRunsListResponse>;
1091
+ getRunStatus(params: CronjobRunStatusParams): Promise<CronjobRunStatusResponse>;
1061
1092
  getRunLogs(params: {
1062
1093
  cronjob_id: number;
1063
1094
  run_id: number;
package/dist/index.js CHANGED
@@ -220,7 +220,9 @@ var DeployResource = class {
220
220
  push_notify: params.push_notify,
221
221
  max_heap_size_mb: params.max_heap_size_mb,
222
222
  run_as_user_id: params.run_as_user_id,
223
- end_at: params.end_at
223
+ start_at: params.start_at,
224
+ end_at: params.end_at,
225
+ max_runs: params.max_runs
224
226
  }
225
227
  });
226
228
  }
@@ -265,9 +267,10 @@ var DeployResource = class {
265
267
  /**
266
268
  * Fire the cronjob workflow once, immediately, bypassing the schedule.
267
269
  * Async — returns the Hatchet workflow run id at enqueue. The
268
- * `cronjob_runs` row appears only after the worker finishes the run;
269
- * callers verify completion by polling `listRuns({cronjob_id})` and
270
- * matching `runs[].workflow_run_id` against the returned id.
270
+ * `cronjob_runs` row can appear as DISPATCHED/RUNNING before it reaches a
271
+ * terminal status; callers verify completion by polling
272
+ * `getRunStatus({cronjob_id, workflow_run_id})` with their own
273
+ * timeout/deadline.
271
274
  *
272
275
  * Surfaces backend status as HTTP errors (handled by AlvaClient):
273
276
  * - 404 not found / cross-user
@@ -291,6 +294,13 @@ var DeployResource = class {
291
294
  }
292
295
  );
293
296
  }
297
+ async getRunStatus(params) {
298
+ this.client._requireAuth();
299
+ return this.client._request(
300
+ "GET",
301
+ `/api/v1/deploy/cronjob/${params.cronjob_id}/runs/by-workflow/${encodeURIComponent(params.workflow_run_id)}`
302
+ );
303
+ }
294
304
  async getRunLogs(params) {
295
305
  this.client._requireAuth();
296
306
  return this.client._request(
@@ -3705,7 +3715,7 @@ var installPlaybookRuntime = (targetWindow) => {
3705
3715
  };
3706
3716
 
3707
3717
  // src/index.ts
3708
- var VERSION = true ? "0.16.1-beta.0" : "dev";
3718
+ var VERSION = true ? "0.16.1-beta.1" : "dev";
3709
3719
  export {
3710
3720
  AlertsResource,
3711
3721
  AlvaClient,