@alva-ai/toolkit 0.17.0 → 0.17.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 +8 -2
- package/dist/cli.js +244 -44
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +6 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ interface AlvaClientConfig {
|
|
|
11
11
|
signal?: AbortSignal;
|
|
12
12
|
/** Alva chat session owning produced artifacts; sent as X-Alva-Origin-Session-Id. */
|
|
13
13
|
originSessionId?: string;
|
|
14
|
+
/** Session profile kind used to gate attached-context CLI commands. */
|
|
15
|
+
originSessionKind?: string;
|
|
14
16
|
}
|
|
15
17
|
interface UserProfile {
|
|
16
18
|
id: string;
|
|
@@ -340,6 +342,8 @@ interface FeedReleaseRequest {
|
|
|
340
342
|
* regular (non-agent) feed. The backend validates it against its catalog.
|
|
341
343
|
*/
|
|
342
344
|
agent_type?: string;
|
|
345
|
+
/** Suppress ReleaseFeed's default publish-time first run. */
|
|
346
|
+
skip_auto_trigger?: boolean;
|
|
343
347
|
}
|
|
344
348
|
interface FeedReleaseResponse {
|
|
345
349
|
feed_id: number;
|
|
@@ -1630,8 +1634,8 @@ declare class AlertsResource {
|
|
|
1630
1634
|
* Group push subscriptions for an external channel session.
|
|
1631
1635
|
*
|
|
1632
1636
|
* These APIs subscribe the Telegram/Discord group attached to `session_id`
|
|
1633
|
-
* to
|
|
1634
|
-
* the authenticated caller is that group's Alva admin.
|
|
1637
|
+
* to feed push events the group admin may read. Mutations are idempotent no-ops
|
|
1638
|
+
* unless the authenticated caller is that group's Alva admin.
|
|
1635
1639
|
*/
|
|
1636
1640
|
declare class ChannelGroupSubscriptionsResource {
|
|
1637
1641
|
private client;
|
|
@@ -1795,6 +1799,8 @@ declare class AlvaClient {
|
|
|
1795
1799
|
* from `gaSessionId` (browser analytics).
|
|
1796
1800
|
*/
|
|
1797
1801
|
readonly originSessionId?: string;
|
|
1802
|
+
/** Session profile kind associated with originSessionId. */
|
|
1803
|
+
readonly originSessionKind?: string;
|
|
1798
1804
|
private _fs?;
|
|
1799
1805
|
private _run?;
|
|
1800
1806
|
private _deploy?;
|
package/dist/cli.js
CHANGED
|
@@ -9858,7 +9858,8 @@ var ReleaseResource = class {
|
|
|
9858
9858
|
view_json: params.view_json,
|
|
9859
9859
|
description: params.description,
|
|
9860
9860
|
changelog: params.changelog,
|
|
9861
|
-
agent_type: params.agent_type
|
|
9861
|
+
agent_type: params.agent_type,
|
|
9862
|
+
skip_auto_trigger: params.skip_auto_trigger
|
|
9862
9863
|
}
|
|
9863
9864
|
});
|
|
9864
9865
|
}
|
|
@@ -12473,6 +12474,8 @@ var AlvaClient = class {
|
|
|
12473
12474
|
* from `gaSessionId` (browser analytics).
|
|
12474
12475
|
*/
|
|
12475
12476
|
originSessionId;
|
|
12477
|
+
/** Session profile kind associated with originSessionId. */
|
|
12478
|
+
originSessionKind;
|
|
12476
12479
|
_fs;
|
|
12477
12480
|
_run;
|
|
12478
12481
|
_deploy;
|
|
@@ -12511,6 +12514,7 @@ var AlvaClient = class {
|
|
|
12511
12514
|
this.utmParams = config.utmParams;
|
|
12512
12515
|
this.signal = config.signal;
|
|
12513
12516
|
this.originSessionId = config.originSessionId;
|
|
12517
|
+
this.originSessionKind = config.originSessionKind;
|
|
12514
12518
|
}
|
|
12515
12519
|
get fs() {
|
|
12516
12520
|
return this._fs ??= new FsResource(this);
|
|
@@ -12853,6 +12857,7 @@ function loadConfig(deps) {
|
|
|
12853
12857
|
const gaSessionIdEnv = env.ALVA_GA_SESSION_ID;
|
|
12854
12858
|
const utmParamsEnv = env.ALVA_UTM_PARAMS;
|
|
12855
12859
|
const originSessionIdEnv = env.ALVA_SESSION_ID;
|
|
12860
|
+
const originSessionKindEnv = env.ALVA_SESSION_KIND;
|
|
12856
12861
|
let fileProfile = {};
|
|
12857
12862
|
const path = configPath({ env, homedir: homedir3 });
|
|
12858
12863
|
try {
|
|
@@ -12877,7 +12882,8 @@ function loadConfig(deps) {
|
|
|
12877
12882
|
gaClientId: gaClientIdEnv,
|
|
12878
12883
|
gaSessionId: gaSessionIdEnv,
|
|
12879
12884
|
utmParams: utmParamsEnv,
|
|
12880
|
-
originSessionId: originSessionIdEnv
|
|
12885
|
+
originSessionId: originSessionIdEnv,
|
|
12886
|
+
originSessionKind: originSessionKindEnv
|
|
12881
12887
|
};
|
|
12882
12888
|
}
|
|
12883
12889
|
|
|
@@ -13642,6 +13648,19 @@ function formatAlertList(result) {
|
|
|
13642
13648
|
}
|
|
13643
13649
|
return lines.join("\n");
|
|
13644
13650
|
}
|
|
13651
|
+
function formatGroupAlertList(result) {
|
|
13652
|
+
const alerts = result.subscriptions ?? [];
|
|
13653
|
+
if (alerts.length === 0) return "(no group alerts)\n";
|
|
13654
|
+
const lines = [`${alerts.length} group alert(s):`, ""];
|
|
13655
|
+
for (const alert of alerts) {
|
|
13656
|
+
const targetID = alert.target?.id;
|
|
13657
|
+
const status = alert.enabled ? "enabled" : "disabled";
|
|
13658
|
+
lines.push(`\u2022 automation ${targetID ?? "(unknown)"} [${status}]`);
|
|
13659
|
+
lines.push(` event: ${alert.event_type}`);
|
|
13660
|
+
lines.push("");
|
|
13661
|
+
}
|
|
13662
|
+
return lines.join("\n");
|
|
13663
|
+
}
|
|
13645
13664
|
function alertTitle(alert) {
|
|
13646
13665
|
if (alert.feed_name) return alert.feed_name;
|
|
13647
13666
|
return alert.target?.id ? `target ${alert.target.id}` : "(unknown target)";
|
|
@@ -13652,7 +13671,7 @@ import * as fs2 from "fs";
|
|
|
13652
13671
|
import * as os2 from "os";
|
|
13653
13672
|
import * as fsPromises2 from "fs/promises";
|
|
13654
13673
|
import { Agent, setGlobalDispatcher } from "undici";
|
|
13655
|
-
var CLI_VERSION = true ? "0.17.
|
|
13674
|
+
var CLI_VERSION = true ? "0.17.1-beta.1" : "dev";
|
|
13656
13675
|
var DEFAULT_RUN_TIMEOUT_MS = 6e5;
|
|
13657
13676
|
var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
|
|
13658
13677
|
var configuredRunFetchTimeoutMs;
|
|
@@ -13701,7 +13720,7 @@ Commands:
|
|
|
13701
13720
|
notification-preferences Notification preferences (list, enable-session-completed, disable-session-completed)
|
|
13702
13721
|
feedback Submit user-confirmed Alva platform feedback (submit)
|
|
13703
13722
|
subscriptions Playbook follows and feed alert subscriptions
|
|
13704
|
-
channel
|
|
13723
|
+
channel Deprecated group-alert compatibility commands
|
|
13705
13724
|
remix Save playbook remix lineage
|
|
13706
13725
|
portfolio Connected-account portfolio (accounts, summary, activities)
|
|
13707
13726
|
trading Trading operations (accounts, portfolio, orders, subscriptions, equity-history, risk-rules, subscribe, unsubscribe, execute, update-risk-rules)
|
|
@@ -14044,14 +14063,14 @@ Build-time verify (fire once, then poll up to 5 minutes):
|
|
|
14044
14063
|
--run-id "$(echo "$STATUS_JSON" | jq -r .run.id)"`,
|
|
14045
14064
|
loop: `Usage: alva loop <subcommand> [options]
|
|
14046
14065
|
|
|
14047
|
-
Create a bounded, self-scheduled in-channel goal loop
|
|
14048
|
-
|
|
14049
|
-
@alva/loop SDK), continuing that channel's conversation toward a goal.
|
|
14050
|
-
|
|
14051
|
-
|
|
14066
|
+
Create a bounded, self-scheduled in-channel goal loop. Each tick runs one
|
|
14067
|
+
fire-and-forget agent turn on a channel's stable main session (via the
|
|
14068
|
+
@alva/loop SDK), continuing that channel's conversation toward a goal. Creation
|
|
14069
|
+
seeds a shared runner, creates its cronjob, and registers the cronjob as an
|
|
14070
|
+
Automation without starting an extra publish-time run.
|
|
14052
14071
|
|
|
14053
14072
|
Subcommands:
|
|
14054
|
-
create Create a loop
|
|
14073
|
+
create Create a loop and its visible Automation
|
|
14055
14074
|
|
|
14056
14075
|
Create flags:
|
|
14057
14076
|
--goal <text> Instruction run each tick (required)
|
|
@@ -14064,7 +14083,9 @@ Create flags:
|
|
|
14064
14083
|
1-63 lowercase alphanumeric/hyphens)
|
|
14065
14084
|
|
|
14066
14085
|
At least one of --until or --runs is required. RFC3339 timestamps must include
|
|
14067
|
-
a timezone (Z or \xB1HH:MM).
|
|
14086
|
+
a timezone (Z or \xB1HH:MM). The result includes automation_id and cronjob_id.
|
|
14087
|
+
Use 'alva automation inspect/stop/resume/delete --id <automation_id>' for
|
|
14088
|
+
lifecycle management; deletion also removes the Automation's producer cronjob.
|
|
14068
14089
|
|
|
14069
14090
|
Examples:
|
|
14070
14091
|
alva loop create --channel-id 7284... --goal "watch NVDA pre-market, alert on setup" --cron "*/5 * * * *" --until "2026-07-15T09:30:00-04:00"
|
|
@@ -14134,12 +14155,15 @@ Examples:
|
|
|
14134
14155
|
|
|
14135
14156
|
Manage alerts. Alert subscriptions target automations (feeds) only. Playbook
|
|
14136
14157
|
follows are independent; delivery history and global preferences live here too.
|
|
14158
|
+
Personal alerts may be routed to different Alva delivery channels. Group alerts
|
|
14159
|
+
are managed explicitly through "alert group" and target the current group.
|
|
14137
14160
|
|
|
14138
14161
|
Subcommands:
|
|
14139
14162
|
list List the caller's active alerts
|
|
14140
14163
|
follows List the playbooks the caller follows
|
|
14141
14164
|
enable Enable alerts by automation name or ids
|
|
14142
14165
|
disable Disable alerts by automation name or ids
|
|
14166
|
+
group Manage alerts delivered to the current external group
|
|
14143
14167
|
history List alert delivery history for an automation
|
|
14144
14168
|
preferences List global alert preferences
|
|
14145
14169
|
enable-session-completed
|
|
@@ -14152,6 +14176,14 @@ Enable/disable-by-id flags:
|
|
|
14152
14176
|
--automation-ids <a,b> Comma-separated automation target ids
|
|
14153
14177
|
--channel-id <id> Delivery channel for batch enable (optional)
|
|
14154
14178
|
|
|
14179
|
+
Group subcommands:
|
|
14180
|
+
alva alert group list
|
|
14181
|
+
alva alert group enable --automation-ids <id>
|
|
14182
|
+
alva alert group disable --automation-ids <id>
|
|
14183
|
+
|
|
14184
|
+
Group commands must run inside the attached channel-group sandbox. The current
|
|
14185
|
+
group is inferred automatically; there is no session-id argument.
|
|
14186
|
+
|
|
14155
14187
|
List flags:
|
|
14156
14188
|
--first <n> Optional page size
|
|
14157
14189
|
--cursor <token> Optional cursor from previous response
|
|
@@ -14173,6 +14205,7 @@ Examples:
|
|
|
14173
14205
|
alva alert disable --automation alice/btc-ema
|
|
14174
14206
|
alva alert enable --automation-ids 13292,13293
|
|
14175
14207
|
alva alert disable --automation-ids 13292
|
|
14208
|
+
alva alert group enable --automation-ids 13292
|
|
14176
14209
|
alva alert history --automation alice/btc-ema --status sent
|
|
14177
14210
|
alva alert preferences`,
|
|
14178
14211
|
feed: `Usage: alva feed <subcommand> [options]
|
|
@@ -14671,29 +14704,32 @@ Examples:
|
|
|
14671
14704
|
alva subscriptions follows`,
|
|
14672
14705
|
channel: `Usage: alva channel group-subscriptions <subcommand> [options]
|
|
14673
14706
|
|
|
14674
|
-
|
|
14675
|
-
|
|
14707
|
+
Deprecated compatibility surface. Normal alva alert list/enable/disable
|
|
14708
|
+
commands remain personal-channel operations. Use alva alert group
|
|
14709
|
+
list/enable/disable for the current external group. This alias remains available
|
|
14710
|
+
for existing scripts.
|
|
14711
|
+
|
|
14712
|
+
Manage alerts delivered into the external group chat attached to a channel
|
|
14713
|
+
session. The group can subscribe to feeds the group admin may read.
|
|
14676
14714
|
Subscribe/unsubscribe are idempotent no-ops unless the authenticated caller
|
|
14677
14715
|
is that group's Alva admin.
|
|
14678
14716
|
|
|
14679
14717
|
Subcommands:
|
|
14680
14718
|
context Show group admin status and current subscriptions
|
|
14681
14719
|
list List active subscriptions for the group
|
|
14682
|
-
subscribe Subscribe the group to a
|
|
14720
|
+
subscribe Subscribe the group to a feed the admin may read
|
|
14683
14721
|
unsubscribe Unsubscribe the group from a feed
|
|
14684
14722
|
|
|
14685
|
-
Common flags:
|
|
14686
|
-
--session-id <id> Channel session id for the group (required)
|
|
14687
|
-
|
|
14688
14723
|
Subscribe/unsubscribe flags:
|
|
14689
|
-
--
|
|
14690
|
-
--target-id <id> Numeric feed_id (required)
|
|
14724
|
+
--feed-id <id> Numeric feed_id (required)
|
|
14691
14725
|
|
|
14692
14726
|
Examples:
|
|
14693
|
-
alva channel group-subscriptions context
|
|
14694
|
-
alva channel group-subscriptions list
|
|
14695
|
-
alva channel group-subscriptions subscribe --
|
|
14696
|
-
alva channel group-subscriptions unsubscribe --
|
|
14727
|
+
alva channel group-subscriptions context
|
|
14728
|
+
alva channel group-subscriptions list
|
|
14729
|
+
alva channel group-subscriptions subscribe --feed-id 8169
|
|
14730
|
+
alva channel group-subscriptions unsubscribe --feed-id 8169
|
|
14731
|
+
|
|
14732
|
+
These commands use the current sandbox session from ALVA_SESSION_ID.`,
|
|
14697
14733
|
remix: `Usage: alva remix --child-username <u> --child-name <n> --parents <json>
|
|
14698
14734
|
|
|
14699
14735
|
Record remix lineage when creating a playbook based on existing playbooks.
|
|
@@ -15063,13 +15099,89 @@ function configureRunFetchTimeout(timeoutMs, deps) {
|
|
|
15063
15099
|
configuredRunFetchTimeoutMs = timeoutMs;
|
|
15064
15100
|
}
|
|
15065
15101
|
function requireGroupSubscriptionTargetType(flags, command) {
|
|
15066
|
-
const val =
|
|
15102
|
+
const val = flags["target-type"]?.trim().toLowerCase() ?? "feed";
|
|
15067
15103
|
if (val === "feed") return val;
|
|
15068
15104
|
throw new CliUsageError(
|
|
15069
15105
|
`--target-type must be feed for '${command}', got '${val}'`,
|
|
15070
15106
|
command.split(" ")[0]
|
|
15071
15107
|
);
|
|
15072
15108
|
}
|
|
15109
|
+
function requireGroupSubscriptionSessionID(client, flags, command) {
|
|
15110
|
+
const val = flags["session-id"] ?? client.originSessionId;
|
|
15111
|
+
if (val === void 0) {
|
|
15112
|
+
throw new CliUsageError(
|
|
15113
|
+
`current group session is unavailable for '${command}'; run inside an Alva sandbox with ALVA_SESSION_ID`,
|
|
15114
|
+
"channel"
|
|
15115
|
+
);
|
|
15116
|
+
}
|
|
15117
|
+
if (!/^[1-9]\d*$/.test(val)) {
|
|
15118
|
+
throw new CliUsageError(
|
|
15119
|
+
`current group session must be a positive integer for '${command}', got '${val}'`,
|
|
15120
|
+
"channel"
|
|
15121
|
+
);
|
|
15122
|
+
}
|
|
15123
|
+
return val;
|
|
15124
|
+
}
|
|
15125
|
+
function requireGroupSubscriptionFeedID(flags, command) {
|
|
15126
|
+
const val = flags["feed-id"] ?? flags["target-id"];
|
|
15127
|
+
if (val === void 0) {
|
|
15128
|
+
throw new CliUsageError(
|
|
15129
|
+
`--feed-id is required for '${command}'`,
|
|
15130
|
+
"channel"
|
|
15131
|
+
);
|
|
15132
|
+
}
|
|
15133
|
+
if (!/^[1-9]\d*$/.test(val)) {
|
|
15134
|
+
throw new CliUsageError(
|
|
15135
|
+
`--feed-id must be a positive integer for '${command}', got '${val}'`,
|
|
15136
|
+
"channel"
|
|
15137
|
+
);
|
|
15138
|
+
}
|
|
15139
|
+
return val;
|
|
15140
|
+
}
|
|
15141
|
+
function requireCurrentGroupAlertSessionID(client, command) {
|
|
15142
|
+
if (client.originSessionKind !== "channel_group") {
|
|
15143
|
+
throw new CliUsageError(
|
|
15144
|
+
`'${command}' is only available inside a channel-group sandbox`,
|
|
15145
|
+
"alert"
|
|
15146
|
+
);
|
|
15147
|
+
}
|
|
15148
|
+
const sessionID = client.originSessionId;
|
|
15149
|
+
if (sessionID === void 0) {
|
|
15150
|
+
throw new CliUsageError(
|
|
15151
|
+
`current group session is unavailable for '${command}'`,
|
|
15152
|
+
"alert"
|
|
15153
|
+
);
|
|
15154
|
+
}
|
|
15155
|
+
if (!/^[1-9]\d*$/.test(sessionID)) {
|
|
15156
|
+
throw new CliUsageError(
|
|
15157
|
+
`current group session must be a positive integer for '${command}', got '${sessionID}'`,
|
|
15158
|
+
"alert"
|
|
15159
|
+
);
|
|
15160
|
+
}
|
|
15161
|
+
return sessionID;
|
|
15162
|
+
}
|
|
15163
|
+
function requireSingleGroupAlertFeedID(flags, command) {
|
|
15164
|
+
if (flags.automation !== void 0) {
|
|
15165
|
+
throw new CliUsageError(
|
|
15166
|
+
`Group alerts require --automation-ids for '${command}'`,
|
|
15167
|
+
"alert"
|
|
15168
|
+
);
|
|
15169
|
+
}
|
|
15170
|
+
if (flags["channel-id"] !== void 0) {
|
|
15171
|
+
throw new CliUsageError(
|
|
15172
|
+
`--channel-id selects a personal Alva channel; omit it for '${command}'`,
|
|
15173
|
+
"alert"
|
|
15174
|
+
);
|
|
15175
|
+
}
|
|
15176
|
+
const ids = csvList(flags["automation-ids"]) ?? [];
|
|
15177
|
+
if (ids.length !== 1 || !/^[1-9]\d*$/.test(ids[0])) {
|
|
15178
|
+
throw new CliUsageError(
|
|
15179
|
+
`Group alerts require exactly one positive --automation-ids value for '${command}'`,
|
|
15180
|
+
"alert"
|
|
15181
|
+
);
|
|
15182
|
+
}
|
|
15183
|
+
return ids[0];
|
|
15184
|
+
}
|
|
15073
15185
|
function num(val) {
|
|
15074
15186
|
if (val === void 0) return void 0;
|
|
15075
15187
|
const n = Number(val);
|
|
@@ -15255,6 +15367,12 @@ function loopCronjobName(flags, goal) {
|
|
|
15255
15367
|
const slug = (base ? `loop-${base}` : "loop").slice(0, 63).replace(/-+$/g, "");
|
|
15256
15368
|
return slug || "loop";
|
|
15257
15369
|
}
|
|
15370
|
+
function loopAutomationDescription(goal) {
|
|
15371
|
+
const prefix = "Channel loop: ";
|
|
15372
|
+
const maxDescriptionRunes = 4096;
|
|
15373
|
+
const availableGoalRunes = maxDescriptionRunes - Array.from(prefix).length;
|
|
15374
|
+
return prefix + Array.from(goal).slice(0, availableGoalRunes).join("");
|
|
15375
|
+
}
|
|
15258
15376
|
function parseCreditsItemsParams(flags) {
|
|
15259
15377
|
const command = "credits items";
|
|
15260
15378
|
const hasToday = boolFlag(flags["today"]) === true;
|
|
@@ -15410,22 +15528,38 @@ async function readAllStdin() {
|
|
|
15410
15528
|
}
|
|
15411
15529
|
return Buffer.concat(chunks).toString("utf8");
|
|
15412
15530
|
}
|
|
15531
|
+
function brokerStdinNeedsIntentId(stdin) {
|
|
15532
|
+
let value;
|
|
15533
|
+
try {
|
|
15534
|
+
value = JSON.parse(stdin);
|
|
15535
|
+
} catch {
|
|
15536
|
+
return false;
|
|
15537
|
+
}
|
|
15538
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
15539
|
+
return false;
|
|
15540
|
+
}
|
|
15541
|
+
const input = value;
|
|
15542
|
+
const owns = (key) => Object.prototype.hasOwnProperty.call(input, key);
|
|
15543
|
+
if (owns("intentId") || owns("clientOrderId")) return false;
|
|
15544
|
+
if (!owns("dryRun")) return true;
|
|
15545
|
+
return input.dryRun === false;
|
|
15546
|
+
}
|
|
15413
15547
|
async function handleBroker(client, brokerArgv, deps) {
|
|
15414
15548
|
let argv = brokerArgv;
|
|
15415
15549
|
const isOrderPlace = brokerArgv[0] === "order" && brokerArgv[1] === "place";
|
|
15416
15550
|
const hasFlag = (name) => brokerArgv.some((a) => a === name || a.startsWith(`${name}=`));
|
|
15417
15551
|
const hasHandle = hasFlag("--intent-id") || hasFlag("--client-order-id");
|
|
15418
15552
|
const isDryRun = hasFlag("--dry-run");
|
|
15419
|
-
|
|
15553
|
+
let stdin;
|
|
15554
|
+
if (hasFlag("--stdin")) {
|
|
15555
|
+
stdin = await readAllStdin();
|
|
15556
|
+
}
|
|
15557
|
+
if (isOrderPlace && !hasHandle && !isDryRun && (stdin === void 0 || brokerStdinNeedsIntentId(stdin))) {
|
|
15420
15558
|
const intentId = crypto3.randomUUID();
|
|
15421
15559
|
process.stderr.write(`alva broker: intent-id ${intentId}
|
|
15422
15560
|
`);
|
|
15423
15561
|
argv = [...brokerArgv, "--intent-id", intentId];
|
|
15424
15562
|
}
|
|
15425
|
-
let stdin;
|
|
15426
|
-
if (hasFlag("--stdin")) {
|
|
15427
|
-
stdin = await readAllStdin();
|
|
15428
|
-
}
|
|
15429
15563
|
let envelope;
|
|
15430
15564
|
let exit = 2;
|
|
15431
15565
|
try {
|
|
@@ -15750,13 +15884,14 @@ async function dispatch(client, args, meta, deps) {
|
|
|
15750
15884
|
"loop"
|
|
15751
15885
|
);
|
|
15752
15886
|
}
|
|
15887
|
+
const name = loopCronjobName(flags, goal);
|
|
15753
15888
|
await client.fs.write({
|
|
15754
15889
|
path: LOOP_RUNNER_PATH,
|
|
15755
15890
|
data: LOOP_RUNNER_SRC,
|
|
15756
15891
|
mkdir_parents: true
|
|
15757
15892
|
});
|
|
15758
|
-
|
|
15759
|
-
name
|
|
15893
|
+
const cronjob = await client.deploy.create({
|
|
15894
|
+
name,
|
|
15760
15895
|
path: LOOP_RUNNER_PATH,
|
|
15761
15896
|
cron_expression: cron,
|
|
15762
15897
|
args: channelId ? { goal, channelId } : { goal },
|
|
@@ -15764,6 +15899,33 @@ async function dispatch(client, args, meta, deps) {
|
|
|
15764
15899
|
end_at: endAt,
|
|
15765
15900
|
max_runs: maxRuns
|
|
15766
15901
|
});
|
|
15902
|
+
try {
|
|
15903
|
+
const automation = await client.automation.publish({
|
|
15904
|
+
name,
|
|
15905
|
+
version: "1.0.0",
|
|
15906
|
+
cronjob_id: cronjob.id,
|
|
15907
|
+
description: loopAutomationDescription(goal),
|
|
15908
|
+
skip_auto_trigger: true
|
|
15909
|
+
});
|
|
15910
|
+
return {
|
|
15911
|
+
name,
|
|
15912
|
+
automation_id: String(automation.feed_id),
|
|
15913
|
+
cronjob_id: cronjob.id
|
|
15914
|
+
};
|
|
15915
|
+
} catch (publishError) {
|
|
15916
|
+
const publishMessage = publishError instanceof Error ? publishError.message : String(publishError);
|
|
15917
|
+
try {
|
|
15918
|
+
await client.deploy.delete({ id: cronjob.id });
|
|
15919
|
+
} catch (rollbackError) {
|
|
15920
|
+
const rollbackMessage = rollbackError instanceof Error ? rollbackError.message : String(rollbackError);
|
|
15921
|
+
throw new Error(
|
|
15922
|
+
`failed to publish loop "${name}" as an automation after creating cronjob ${cronjob.id}: ${publishMessage}; automatic rollback failed: ${rollbackMessage}; cronjob ${cronjob.id} may still exist; run \`alva deploy delete --id ${cronjob.id}\``
|
|
15923
|
+
);
|
|
15924
|
+
}
|
|
15925
|
+
throw new Error(
|
|
15926
|
+
`failed to publish loop "${name}" as an automation; rolled back cronjob ${cronjob.id}: ${publishMessage}`
|
|
15927
|
+
);
|
|
15928
|
+
}
|
|
15767
15929
|
}
|
|
15768
15930
|
default:
|
|
15769
15931
|
throw new CliUsageError(
|
|
@@ -16599,6 +16761,45 @@ async function dispatch(client, args, meta, deps) {
|
|
|
16599
16761
|
requireAutomationAlertTarget(flags, "alert disable")
|
|
16600
16762
|
);
|
|
16601
16763
|
}
|
|
16764
|
+
case "group": {
|
|
16765
|
+
const leaf = args[2];
|
|
16766
|
+
if (!leaf || leaf === "--help" || leaf === "-h") {
|
|
16767
|
+
return { _help: true, text: COMMAND_HELP.alert };
|
|
16768
|
+
}
|
|
16769
|
+
const command = `alert group ${leaf}`;
|
|
16770
|
+
if (flags["session-id"] !== void 0) {
|
|
16771
|
+
throw new CliUsageError(
|
|
16772
|
+
`'${command}' uses the attached group and does not accept --session-id`,
|
|
16773
|
+
"alert"
|
|
16774
|
+
);
|
|
16775
|
+
}
|
|
16776
|
+
const sessionID = requireCurrentGroupAlertSessionID(client, command);
|
|
16777
|
+
switch (leaf) {
|
|
16778
|
+
case "list": {
|
|
16779
|
+
const result = await client.channelGroupSubscriptions.list({
|
|
16780
|
+
session_id: sessionID
|
|
16781
|
+
});
|
|
16782
|
+
return boolFlag(flags["json"]) ? result : formatGroupAlertList(result);
|
|
16783
|
+
}
|
|
16784
|
+
case "enable":
|
|
16785
|
+
return client.channelGroupSubscriptions.subscribe({
|
|
16786
|
+
session_id: sessionID,
|
|
16787
|
+
target_type: "feed",
|
|
16788
|
+
target_id: requireSingleGroupAlertFeedID(flags, command)
|
|
16789
|
+
});
|
|
16790
|
+
case "disable":
|
|
16791
|
+
return client.channelGroupSubscriptions.unsubscribe({
|
|
16792
|
+
session_id: sessionID,
|
|
16793
|
+
target_type: "feed",
|
|
16794
|
+
target_id: requireSingleGroupAlertFeedID(flags, command)
|
|
16795
|
+
});
|
|
16796
|
+
default:
|
|
16797
|
+
throw new CliUsageError(
|
|
16798
|
+
`Unknown subcommand: alert group ${leaf}`,
|
|
16799
|
+
"alert"
|
|
16800
|
+
);
|
|
16801
|
+
}
|
|
16802
|
+
}
|
|
16602
16803
|
case "history": {
|
|
16603
16804
|
rejectPlaybookAlertTarget(flags, "alert history");
|
|
16604
16805
|
const target = requireAutomationAlertTarget(flags, "alert history");
|
|
@@ -16651,51 +16852,49 @@ async function dispatch(client, args, meta, deps) {
|
|
|
16651
16852
|
switch (leaf) {
|
|
16652
16853
|
case "context":
|
|
16653
16854
|
return client.channelGroupSubscriptions.context({
|
|
16654
|
-
session_id:
|
|
16855
|
+
session_id: requireGroupSubscriptionSessionID(
|
|
16856
|
+
client,
|
|
16655
16857
|
channelFlags,
|
|
16656
|
-
"session-id",
|
|
16657
16858
|
commandName
|
|
16658
16859
|
)
|
|
16659
16860
|
});
|
|
16660
16861
|
case "list":
|
|
16661
16862
|
return client.channelGroupSubscriptions.list({
|
|
16662
|
-
session_id:
|
|
16863
|
+
session_id: requireGroupSubscriptionSessionID(
|
|
16864
|
+
client,
|
|
16663
16865
|
channelFlags,
|
|
16664
|
-
"session-id",
|
|
16665
16866
|
commandName
|
|
16666
16867
|
)
|
|
16667
16868
|
});
|
|
16668
16869
|
case "subscribe":
|
|
16669
16870
|
return client.channelGroupSubscriptions.subscribe({
|
|
16670
|
-
session_id:
|
|
16871
|
+
session_id: requireGroupSubscriptionSessionID(
|
|
16872
|
+
client,
|
|
16671
16873
|
channelFlags,
|
|
16672
|
-
"session-id",
|
|
16673
16874
|
commandName
|
|
16674
16875
|
),
|
|
16675
16876
|
target_type: requireGroupSubscriptionTargetType(
|
|
16676
16877
|
channelFlags,
|
|
16677
16878
|
commandName
|
|
16678
16879
|
),
|
|
16679
|
-
target_id:
|
|
16880
|
+
target_id: requireGroupSubscriptionFeedID(
|
|
16680
16881
|
channelFlags,
|
|
16681
|
-
"target-id",
|
|
16682
16882
|
commandName
|
|
16683
16883
|
)
|
|
16684
16884
|
});
|
|
16685
16885
|
case "unsubscribe":
|
|
16686
16886
|
return client.channelGroupSubscriptions.unsubscribe({
|
|
16687
|
-
session_id:
|
|
16887
|
+
session_id: requireGroupSubscriptionSessionID(
|
|
16888
|
+
client,
|
|
16688
16889
|
channelFlags,
|
|
16689
|
-
"session-id",
|
|
16690
16890
|
commandName
|
|
16691
16891
|
),
|
|
16692
16892
|
target_type: requireGroupSubscriptionTargetType(
|
|
16693
16893
|
channelFlags,
|
|
16694
16894
|
commandName
|
|
16695
16895
|
),
|
|
16696
|
-
target_id:
|
|
16896
|
+
target_id: requireGroupSubscriptionFeedID(
|
|
16697
16897
|
channelFlags,
|
|
16698
|
-
"target-id",
|
|
16699
16898
|
commandName
|
|
16700
16899
|
)
|
|
16701
16900
|
});
|
|
@@ -17054,7 +17253,8 @@ async function main() {
|
|
|
17054
17253
|
gaClientId: config.gaClientId,
|
|
17055
17254
|
gaSessionId: config.gaSessionId,
|
|
17056
17255
|
utmParams: config.utmParams,
|
|
17057
|
-
originSessionId: config.originSessionId
|
|
17256
|
+
originSessionId: config.originSessionId,
|
|
17257
|
+
originSessionKind: config.originSessionKind
|
|
17058
17258
|
});
|
|
17059
17259
|
const cleanArgs = stripGlobalFlags(rawArgs);
|
|
17060
17260
|
const result = await dispatch(client, cleanArgs, {
|