@alva-ai/toolkit 0.16.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/browser.global.js +2 -2
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.d.ts +53 -10
- package/dist/cli.js +202 -16
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +16 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -10
- package/dist/index.d.ts +53 -10
- package/dist/index.js +16 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.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
|
|
20
|
-
|
|
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,6 +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;
|
|
204
|
+
/**
|
|
205
|
+
* Exclusive RFC3339 upper bound. A run is admitted only while now < end_at.
|
|
206
|
+
*/
|
|
207
|
+
end_at?: string;
|
|
208
|
+
/** Maximum number of admitted runs. */
|
|
209
|
+
max_runs?: number;
|
|
197
210
|
}
|
|
198
211
|
interface Cronjob {
|
|
199
212
|
id: number;
|
|
@@ -210,6 +223,17 @@ interface Cronjob {
|
|
|
210
223
|
* A string: snowflake int64 ids overflow JS number precision.
|
|
211
224
|
*/
|
|
212
225
|
run_as_user_id: string;
|
|
226
|
+
/** Inclusive eligibility lower bound, resolved by the server on create. */
|
|
227
|
+
start_at?: string | null;
|
|
228
|
+
/**
|
|
229
|
+
* Lifetime ceiling (RFC3339), or null/omitted when the cronjob has no expiry.
|
|
230
|
+
* Set by `alva loop create`; unset for feeds and other crons.
|
|
231
|
+
*/
|
|
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;
|
|
213
237
|
created_at: string;
|
|
214
238
|
updated_at: string;
|
|
215
239
|
}
|
|
@@ -270,6 +294,22 @@ interface CronjobRunsListResponse {
|
|
|
270
294
|
stats?: CronjobRunStats;
|
|
271
295
|
next_cursor?: number;
|
|
272
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
|
+
}
|
|
273
313
|
interface CronjobRunLogsResponse {
|
|
274
314
|
logs: string;
|
|
275
315
|
}
|
|
@@ -277,8 +317,9 @@ interface CronjobTriggerResponse {
|
|
|
277
317
|
/**
|
|
278
318
|
* Hatchet workflow run id at enqueue. Async — the persisted
|
|
279
319
|
* `cronjob_runs` row appears only after the worker finishes the run.
|
|
280
|
-
* Callers verify completion by polling
|
|
281
|
-
*
|
|
320
|
+
* Callers verify completion by polling
|
|
321
|
+
* `deploy.getRunStatus({cronjob_id, workflow_run_id})` with their own
|
|
322
|
+
* timeout/deadline.
|
|
282
323
|
*/
|
|
283
324
|
workflow_run_id: string;
|
|
284
325
|
}
|
|
@@ -778,8 +819,8 @@ interface PushSubscription {
|
|
|
778
819
|
*/
|
|
779
820
|
kind?: 'PLAYBOOK_ALERTS' | 'FEED_ALERT' | 'UNSPECIFIED' | string;
|
|
780
821
|
/**
|
|
781
|
-
*
|
|
782
|
-
*
|
|
822
|
+
* Legacy social playbook-follow signal. Do not use this to decide whether
|
|
823
|
+
* alert delivery is enabled; use kind + target_status instead.
|
|
783
824
|
*/
|
|
784
825
|
following?: boolean;
|
|
785
826
|
/**
|
|
@@ -1033,9 +1074,10 @@ declare class DeployResource {
|
|
|
1033
1074
|
/**
|
|
1034
1075
|
* Fire the cronjob workflow once, immediately, bypassing the schedule.
|
|
1035
1076
|
* Async — returns the Hatchet workflow run id at enqueue. The
|
|
1036
|
-
* `cronjob_runs` row
|
|
1037
|
-
* callers verify completion by polling
|
|
1038
|
-
*
|
|
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.
|
|
1039
1081
|
*
|
|
1040
1082
|
* Surfaces backend status as HTTP errors (handled by AlvaClient):
|
|
1041
1083
|
* - 404 not found / cross-user
|
|
@@ -1046,6 +1088,7 @@ declare class DeployResource {
|
|
|
1046
1088
|
id: number;
|
|
1047
1089
|
}): Promise<CronjobTriggerResponse>;
|
|
1048
1090
|
listRuns(params: CronjobRunsListParams): Promise<CronjobRunsListResponse>;
|
|
1091
|
+
getRunStatus(params: CronjobRunStatusParams): Promise<CronjobRunStatusResponse>;
|
|
1049
1092
|
getRunLogs(params: {
|
|
1050
1093
|
cronjob_id: number;
|
|
1051
1094
|
run_id: number;
|
package/dist/cli.js
CHANGED
|
@@ -9704,7 +9704,10 @@ var DeployResource = class {
|
|
|
9704
9704
|
args: params.args,
|
|
9705
9705
|
push_notify: params.push_notify,
|
|
9706
9706
|
max_heap_size_mb: params.max_heap_size_mb,
|
|
9707
|
-
run_as_user_id: params.run_as_user_id
|
|
9707
|
+
run_as_user_id: params.run_as_user_id,
|
|
9708
|
+
start_at: params.start_at,
|
|
9709
|
+
end_at: params.end_at,
|
|
9710
|
+
max_runs: params.max_runs
|
|
9708
9711
|
}
|
|
9709
9712
|
});
|
|
9710
9713
|
}
|
|
@@ -9749,9 +9752,10 @@ var DeployResource = class {
|
|
|
9749
9752
|
/**
|
|
9750
9753
|
* Fire the cronjob workflow once, immediately, bypassing the schedule.
|
|
9751
9754
|
* Async — returns the Hatchet workflow run id at enqueue. The
|
|
9752
|
-
* `cronjob_runs` row
|
|
9753
|
-
* callers verify completion by polling
|
|
9754
|
-
*
|
|
9755
|
+
* `cronjob_runs` row can appear as DISPATCHED/RUNNING before it reaches a
|
|
9756
|
+
* terminal status; callers verify completion by polling
|
|
9757
|
+
* `getRunStatus({cronjob_id, workflow_run_id})` with their own
|
|
9758
|
+
* timeout/deadline.
|
|
9755
9759
|
*
|
|
9756
9760
|
* Surfaces backend status as HTTP errors (handled by AlvaClient):
|
|
9757
9761
|
* - 404 not found / cross-user
|
|
@@ -9775,6 +9779,13 @@ var DeployResource = class {
|
|
|
9775
9779
|
}
|
|
9776
9780
|
);
|
|
9777
9781
|
}
|
|
9782
|
+
async getRunStatus(params) {
|
|
9783
|
+
this.client._requireAuth();
|
|
9784
|
+
return this.client._request(
|
|
9785
|
+
"GET",
|
|
9786
|
+
`/api/v1/deploy/cronjob/${params.cronjob_id}/runs/by-workflow/${encodeURIComponent(params.workflow_run_id)}`
|
|
9787
|
+
);
|
|
9788
|
+
}
|
|
9778
9789
|
async getRunLogs(params) {
|
|
9779
9790
|
this.client._requireAuth();
|
|
9780
9791
|
return this.client._request(
|
|
@@ -13650,7 +13661,7 @@ import * as fs2 from "fs";
|
|
|
13650
13661
|
import * as os2 from "os";
|
|
13651
13662
|
import * as fsPromises2 from "fs/promises";
|
|
13652
13663
|
import { Agent, setGlobalDispatcher } from "undici";
|
|
13653
|
-
var CLI_VERSION = true ? "0.16.
|
|
13664
|
+
var CLI_VERSION = true ? "0.16.1-beta.1" : "dev";
|
|
13654
13665
|
var DEFAULT_RUN_TIMEOUT_MS = 6e5;
|
|
13655
13666
|
var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
|
|
13656
13667
|
var configuredRunFetchTimeoutMs;
|
|
@@ -13680,6 +13691,7 @@ Commands:
|
|
|
13680
13691
|
fs Filesystem operations (read, write, stat, readdir, mkdir, remove, rename, copy, symlink, readlink, chmod, grant, revoke)
|
|
13681
13692
|
run Execute code in the Alva runtime
|
|
13682
13693
|
deploy Cronjob management (create, list, get, update, delete, pause, resume, runs, run-logs)
|
|
13694
|
+
loop Self-scheduled in-channel goal loops (create)
|
|
13683
13695
|
service-account Restricted run-as identities (create, list, delete, grant, revoke)
|
|
13684
13696
|
release Feed and playbook releases (feed, playbook-draft, playbook)
|
|
13685
13697
|
lint Design-system lint (playbook)
|
|
@@ -13794,9 +13806,13 @@ Subcommands:
|
|
|
13794
13806
|
Response fields:
|
|
13795
13807
|
id User ID
|
|
13796
13808
|
username Username (used in ALFS paths and playbook URLs)
|
|
13797
|
-
subscription_tier "free" or "
|
|
13798
|
-
telegram_username Telegram
|
|
13799
|
-
|
|
13809
|
+
subscription_tier "free", "pro", or "max" \u2014 determines release flow and feature gates
|
|
13810
|
+
telegram_username Telegram display name if connected, empty otherwise
|
|
13811
|
+
discord_username Discord display name if connected, empty otherwise
|
|
13812
|
+
slack_username Slack display name if connected, empty otherwise
|
|
13813
|
+
whatsapp_username WhatsApp display name if connected, empty otherwise
|
|
13814
|
+
imessage_username iMessage display name if connected, empty otherwise
|
|
13815
|
+
active_channel Currently selected IM delivery channel
|
|
13800
13816
|
|
|
13801
13817
|
Examples:
|
|
13802
13818
|
alva user me`,
|
|
@@ -13957,8 +13973,9 @@ Subcommands:
|
|
|
13957
13973
|
pause Pause a running cronjob
|
|
13958
13974
|
resume Resume a paused cronjob
|
|
13959
13975
|
trigger Fire the cronjob once, immediately, bypassing the schedule
|
|
13960
|
-
(returns workflow_run_id; poll '
|
|
13976
|
+
(returns workflow_run_id; poll 'run-status' with a timeout)
|
|
13961
13977
|
runs List runs for a cronjob (cursor-paginated)
|
|
13978
|
+
run-status Get one triggered run's pollable status by workflow_run_id
|
|
13962
13979
|
run-logs Get stdout/stderr logs for a single cronjob run
|
|
13963
13980
|
|
|
13964
13981
|
Create/Update flags:
|
|
@@ -13987,6 +14004,10 @@ Runs flags:
|
|
|
13987
14004
|
--first <n> Max results per page
|
|
13988
14005
|
--cursor <cursor> Pagination cursor from previous response
|
|
13989
14006
|
|
|
14007
|
+
Run-status flags:
|
|
14008
|
+
--id <id> Cronjob ID (required)
|
|
14009
|
+
--workflow-run-id <id> Workflow run ID returned by deploy trigger
|
|
14010
|
+
|
|
13990
14011
|
Run-logs flags:
|
|
13991
14012
|
--id <id> Cronjob ID (required)
|
|
13992
14013
|
--run-id <id> Run ID (required)
|
|
@@ -14013,17 +14034,49 @@ Examples:
|
|
|
14013
14034
|
alva deploy delete --id 42
|
|
14014
14035
|
alva deploy runs --id 42
|
|
14015
14036
|
alva deploy runs --id 42 --first 10
|
|
14037
|
+
alva deploy run-status --id 42 --workflow-run-id hatchet-run-id
|
|
14016
14038
|
alva deploy run-logs --id 42 --run-id 123
|
|
14017
14039
|
|
|
14018
|
-
Build-time verify (fire once, then poll
|
|
14040
|
+
Build-time verify (fire once, then poll up to 5 minutes):
|
|
14019
14041
|
WF=$(alva deploy trigger --id 42 | jq -r .workflow_run_id)
|
|
14020
|
-
|
|
14021
|
-
|
|
14042
|
+
for _ in {1..60}; do
|
|
14043
|
+
STATUS_JSON=$(alva deploy run-status --id 42 --workflow-run-id "$WF")
|
|
14044
|
+
STATE=$(echo "$STATUS_JSON" | jq -r .state)
|
|
14045
|
+
case "$STATE" in PENDING|DISPATCHED|RUNNING) ;; *) break ;; esac
|
|
14022
14046
|
sleep 5
|
|
14023
14047
|
done
|
|
14024
|
-
|
|
14025
|
-
|
|
14026
|
-
|
|
14048
|
+
case "$STATE" in
|
|
14049
|
+
PENDING|DISPATCHED|RUNNING) echo "Timed out waiting for run completion" >&2; exit 1 ;;
|
|
14050
|
+
esac
|
|
14051
|
+
[ "$STATE" = COMPLETED ] || alva deploy run-logs --id 42 \\
|
|
14052
|
+
--run-id "$(echo "$STATUS_JSON" | jq -r .run.id)"`,
|
|
14053
|
+
loop: `Usage: alva loop <subcommand> [options]
|
|
14054
|
+
|
|
14055
|
+
Create a bounded, self-scheduled in-channel goal loop: a cronjob that each tick runs
|
|
14056
|
+
one fire-and-forget agent turn on a channel's stable main session (via the
|
|
14057
|
+
@alva/loop SDK), continuing that channel's conversation toward a goal. Sugar
|
|
14058
|
+
over 'alva deploy create' \u2014 it seeds a shared loop-runner script and packs the
|
|
14059
|
+
goal/channel into the cronjob's args.
|
|
14060
|
+
|
|
14061
|
+
Subcommands:
|
|
14062
|
+
create Create a loop (seeds the shared loop-runner + a cronjob)
|
|
14063
|
+
|
|
14064
|
+
Create flags:
|
|
14065
|
+
--goal <text> Instruction run each tick (required)
|
|
14066
|
+
--cron <expression> Cron schedule (required, e.g. "0 * * * *")
|
|
14067
|
+
--channel-id <id> Target channel id. Omit \u21D2 your DM/agent channel
|
|
14068
|
+
--start <time> First eligible time: 'now' (default) or RFC3339
|
|
14069
|
+
--until <time> Exclusive RFC3339 cutoff
|
|
14070
|
+
--runs <count> Maximum admitted runs after --start
|
|
14071
|
+
--name <name> Cronjob name (default: derived from --goal;
|
|
14072
|
+
1-63 lowercase alphanumeric/hyphens)
|
|
14073
|
+
|
|
14074
|
+
At least one of --until or --runs is required. RFC3339 timestamps must include
|
|
14075
|
+
a timezone (Z or \xB1HH:MM).
|
|
14076
|
+
|
|
14077
|
+
Examples:
|
|
14078
|
+
alva loop create --channel-id 7284... --goal "watch NVDA pre-market, alert on setup" --cron "*/5 * * * *" --until "2026-07-15T09:30:00-04:00"
|
|
14079
|
+
alva loop create --goal "check the next 12 intervals" --cron "0 * * * *" --start now --runs 12`,
|
|
14027
14080
|
"service-account": `Usage: alva service-account <subcommand> [options]
|
|
14028
14081
|
|
|
14029
14082
|
Manage restricted run-as identities. A service account executes a UDF or
|
|
@@ -14625,7 +14678,6 @@ Follows flags:
|
|
|
14625
14678
|
|
|
14626
14679
|
List response notes:
|
|
14627
14680
|
items[].kind PLAYBOOK_ALERTS (playbook-level wildcard) | FEED_ALERT
|
|
14628
|
-
items[].following Whether the caller also FOLLOWS the playbook
|
|
14629
14681
|
items[].target_status ACTIVE | TARGET_DELETED (ghost \u2014 clear via
|
|
14630
14682
|
unsubscribe --playbook-ids/--feed-ids) | PAUSED
|
|
14631
14683
|
items[].playbook {owner_username, name, display_name} for PLAYBOOK rows
|
|
@@ -15153,6 +15205,79 @@ function parseCreditsDurationMs(value) {
|
|
|
15153
15205
|
}
|
|
15154
15206
|
return durationMs;
|
|
15155
15207
|
}
|
|
15208
|
+
var LOOP_RUNNER_PATH = "~/loops/_runner/index.js";
|
|
15209
|
+
var LOOP_RUNNER_SRC = [
|
|
15210
|
+
"const { loop } = require('@alva/loop');",
|
|
15211
|
+
"const { goal, channelId } = require('env').args;",
|
|
15212
|
+
"loop(goal, channelId ? { channelId } : {});",
|
|
15213
|
+
""
|
|
15214
|
+
].join("\n");
|
|
15215
|
+
function parseLoopTimestamp(value, flag) {
|
|
15216
|
+
const raw = value.trim();
|
|
15217
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:[zZ]|([+-])(\d{2}):(\d{2}))$/.exec(
|
|
15218
|
+
raw
|
|
15219
|
+
);
|
|
15220
|
+
if (!match) {
|
|
15221
|
+
throw new CliUsageError(
|
|
15222
|
+
`--${flag} must be an RFC3339 timestamp with a timezone (Z or \xB1HH:MM), got '${value}'`,
|
|
15223
|
+
"loop"
|
|
15224
|
+
);
|
|
15225
|
+
}
|
|
15226
|
+
const year = Number(match[1]);
|
|
15227
|
+
const month = Number(match[2]);
|
|
15228
|
+
const day = Number(match[3]);
|
|
15229
|
+
const hour = Number(match[4]);
|
|
15230
|
+
const minute = Number(match[5]);
|
|
15231
|
+
const second = Number(match[6]);
|
|
15232
|
+
const offsetHour = Number(match[8] ?? 0);
|
|
15233
|
+
const offsetMinute = Number(match[9] ?? 0);
|
|
15234
|
+
const leapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
15235
|
+
const monthDays = [
|
|
15236
|
+
31,
|
|
15237
|
+
leapYear ? 29 : 28,
|
|
15238
|
+
31,
|
|
15239
|
+
30,
|
|
15240
|
+
31,
|
|
15241
|
+
30,
|
|
15242
|
+
31,
|
|
15243
|
+
31,
|
|
15244
|
+
30,
|
|
15245
|
+
31,
|
|
15246
|
+
30,
|
|
15247
|
+
31
|
|
15248
|
+
];
|
|
15249
|
+
if (month < 1 || month > 12 || day < 1 || day > monthDays[month - 1] || hour > 23 || minute > 59 || second > 59 || offsetHour > 23 || offsetMinute > 59) {
|
|
15250
|
+
throw new CliUsageError(
|
|
15251
|
+
`--${flag} must be a valid RFC3339 timestamp, got '${value}'`,
|
|
15252
|
+
"loop"
|
|
15253
|
+
);
|
|
15254
|
+
}
|
|
15255
|
+
const timestamp = Date.parse(raw);
|
|
15256
|
+
if (!Number.isFinite(timestamp)) {
|
|
15257
|
+
throw new CliUsageError(
|
|
15258
|
+
`--${flag} must be a valid RFC3339 timestamp, got '${value}'`,
|
|
15259
|
+
"loop"
|
|
15260
|
+
);
|
|
15261
|
+
}
|
|
15262
|
+
return new Date(timestamp).toISOString();
|
|
15263
|
+
}
|
|
15264
|
+
function parseLoopRuns(value) {
|
|
15265
|
+
if (value === void 0) return void 0;
|
|
15266
|
+
if (!/^[1-9]\d*$/.test(value)) {
|
|
15267
|
+
throw new CliUsageError("--runs must be a positive integer", "loop");
|
|
15268
|
+
}
|
|
15269
|
+
const runs = Number(value);
|
|
15270
|
+
if (!Number.isSafeInteger(runs) || runs > 2147483647) {
|
|
15271
|
+
throw new CliUsageError("--runs is too large", "loop");
|
|
15272
|
+
}
|
|
15273
|
+
return runs;
|
|
15274
|
+
}
|
|
15275
|
+
function loopCronjobName(flags, goal) {
|
|
15276
|
+
if (flags["name"] !== void 0) return flags["name"];
|
|
15277
|
+
const base = goal.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
15278
|
+
const slug = (base ? `loop-${base}` : "loop").slice(0, 63).replace(/-+$/g, "");
|
|
15279
|
+
return slug || "loop";
|
|
15280
|
+
}
|
|
15156
15281
|
function parseCreditsItemsParams(flags) {
|
|
15157
15282
|
const command = "credits items";
|
|
15158
15283
|
const hasToday = boolFlag(flags["today"]) === true;
|
|
@@ -15595,6 +15720,15 @@ async function dispatch(client, args, meta, deps) {
|
|
|
15595
15720
|
first: num(flags["first"]),
|
|
15596
15721
|
cursor: flags["cursor"]
|
|
15597
15722
|
});
|
|
15723
|
+
case "run-status":
|
|
15724
|
+
return client.deploy.getRunStatus({
|
|
15725
|
+
cronjob_id: requireNumericFlag(flags, "id", "deploy run-status"),
|
|
15726
|
+
workflow_run_id: requireFlag(
|
|
15727
|
+
flags,
|
|
15728
|
+
"workflow-run-id",
|
|
15729
|
+
"deploy run-status"
|
|
15730
|
+
)
|
|
15731
|
+
});
|
|
15598
15732
|
case "run-logs":
|
|
15599
15733
|
return client.deploy.getRunLogs({
|
|
15600
15734
|
cronjob_id: requireNumericFlag(flags, "id", "deploy run-logs"),
|
|
@@ -15607,6 +15741,58 @@ async function dispatch(client, args, meta, deps) {
|
|
|
15607
15741
|
);
|
|
15608
15742
|
}
|
|
15609
15743
|
}
|
|
15744
|
+
case "loop": {
|
|
15745
|
+
if (!subcommand)
|
|
15746
|
+
throw new CliUsageError("Missing subcommand for loop", "loop");
|
|
15747
|
+
switch (subcommand) {
|
|
15748
|
+
case "create": {
|
|
15749
|
+
if (flags["expires-in"] !== void 0) {
|
|
15750
|
+
throw new CliUsageError(
|
|
15751
|
+
"Unknown flag --expires-in; use --until and/or --runs",
|
|
15752
|
+
"loop"
|
|
15753
|
+
);
|
|
15754
|
+
}
|
|
15755
|
+
const goal = requireFlag(flags, "goal", "loop create");
|
|
15756
|
+
const cron = requireFlag(flags, "cron", "loop create");
|
|
15757
|
+
const channelId = flags["channel-id"];
|
|
15758
|
+
const startRaw = (flags["start"] ?? "now").trim();
|
|
15759
|
+
const startAt = startRaw.toLowerCase() === "now" ? void 0 : parseLoopTimestamp(startRaw, "start");
|
|
15760
|
+
const endAt = flags["until"] ? parseLoopTimestamp(flags["until"], "until") : void 0;
|
|
15761
|
+
const maxRuns = parseLoopRuns(flags["runs"]);
|
|
15762
|
+
if (endAt === void 0 && maxRuns === void 0) {
|
|
15763
|
+
throw new CliUsageError(
|
|
15764
|
+
"loop create requires at least one of --until or --runs",
|
|
15765
|
+
"loop"
|
|
15766
|
+
);
|
|
15767
|
+
}
|
|
15768
|
+
if (startAt !== void 0 && endAt !== void 0 && endAt <= startAt) {
|
|
15769
|
+
throw new CliUsageError(
|
|
15770
|
+
"--until must be later than --start",
|
|
15771
|
+
"loop"
|
|
15772
|
+
);
|
|
15773
|
+
}
|
|
15774
|
+
await client.fs.write({
|
|
15775
|
+
path: LOOP_RUNNER_PATH,
|
|
15776
|
+
data: LOOP_RUNNER_SRC,
|
|
15777
|
+
mkdir_parents: true
|
|
15778
|
+
});
|
|
15779
|
+
return client.deploy.create({
|
|
15780
|
+
name: loopCronjobName(flags, goal),
|
|
15781
|
+
path: LOOP_RUNNER_PATH,
|
|
15782
|
+
cron_expression: cron,
|
|
15783
|
+
args: channelId ? { goal, channelId } : { goal },
|
|
15784
|
+
start_at: startAt,
|
|
15785
|
+
end_at: endAt,
|
|
15786
|
+
max_runs: maxRuns
|
|
15787
|
+
});
|
|
15788
|
+
}
|
|
15789
|
+
default:
|
|
15790
|
+
throw new CliUsageError(
|
|
15791
|
+
`Unknown subcommand: loop ${subcommand}`,
|
|
15792
|
+
"loop"
|
|
15793
|
+
);
|
|
15794
|
+
}
|
|
15795
|
+
}
|
|
15610
15796
|
case "service-account": {
|
|
15611
15797
|
if (!subcommand)
|
|
15612
15798
|
throw new CliUsageError(
|