@alva-ai/toolkit 0.19.0 → 0.20.0

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/cli.js CHANGED
@@ -9498,10 +9498,10 @@ var AlvaError = class extends Error {
9498
9498
  };
9499
9499
  var CliUsageError = class extends Error {
9500
9500
  command;
9501
- constructor(message, command) {
9501
+ constructor(message, command2) {
9502
9502
  super(message);
9503
9503
  this.name = "CliUsageError";
9504
- this.command = command;
9504
+ this.command = command2;
9505
9505
  }
9506
9506
  };
9507
9507
 
@@ -9755,6 +9755,8 @@ var DeployResource = class {
9755
9755
  }
9756
9756
  /**
9757
9757
  * Fire the cronjob workflow once, immediately, bypassing the schedule.
9758
+ * This is not a dry run: when publisher push and subscriber alert bindings
9759
+ * are enabled, a successful Feed execution may send real notifications.
9758
9760
  * Async — returns the Hatchet workflow run id at enqueue. The
9759
9761
  * `cronjob_runs` row can appear as DISPATCHED/RUNNING before it reaches a
9760
9762
  * terminal status; callers verify completion by polling
@@ -10972,40 +10974,40 @@ var SKILL_ENDPOINT_METADATA = [
10972
10974
  file: "contracts",
10973
10975
  method: "GET",
10974
10976
  path: "/api/v1/options/contracts",
10975
- tier: "alternative",
10976
- required_subscription_tier: "pro",
10977
- access: "pro_only",
10978
- pro_required: true
10977
+ tier: "public",
10978
+ required_subscription_tier: "free",
10979
+ access: "free_and_pro",
10980
+ pro_required: false
10979
10981
  },
10980
10982
  {
10981
10983
  skill: "arrays-data-api-options",
10982
10984
  file: "kline",
10983
10985
  method: "GET",
10984
10986
  path: "/api/v1/options/kline",
10985
- tier: "alternative",
10986
- required_subscription_tier: "pro",
10987
- access: "pro_only",
10988
- pro_required: true
10987
+ tier: "public",
10988
+ required_subscription_tier: "free",
10989
+ access: "free_and_pro",
10990
+ pro_required: false
10989
10991
  },
10990
10992
  {
10991
10993
  skill: "arrays-data-api-options",
10992
10994
  file: "greeks",
10993
10995
  method: "GET",
10994
10996
  path: "/api/v1/options/greeks",
10995
- tier: "alternative",
10996
- required_subscription_tier: "pro",
10997
- access: "pro_only",
10998
- pro_required: true
10997
+ tier: "public",
10998
+ required_subscription_tier: "free",
10999
+ access: "free_and_pro",
11000
+ pro_required: false
10999
11001
  },
11000
11002
  {
11001
11003
  skill: "arrays-data-api-options",
11002
11004
  file: "chain",
11003
11005
  method: "GET",
11004
11006
  path: "/api/v1/options/chain",
11005
- tier: "alternative",
11006
- required_subscription_tier: "pro",
11007
- access: "pro_only",
11008
- pro_required: true
11007
+ tier: "public",
11008
+ required_subscription_tier: "free",
11009
+ access: "free_and_pro",
11010
+ pro_required: false
11009
11011
  },
11010
11012
  {
11011
11013
  skill: "arrays-data-api-equity-fundamentals",
@@ -11922,7 +11924,15 @@ var SubscriptionsResource = class {
11922
11924
  async subscribeFeed(params) {
11923
11925
  this.client._requireAuth();
11924
11926
  const path = `/api/v1/subscriptions/feed/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}`;
11925
- return this.client._request("POST", path);
11927
+ if (params.channelId === void 0) {
11928
+ return this.client._request(
11929
+ "POST",
11930
+ path
11931
+ );
11932
+ }
11933
+ return this.client._request("POST", path, {
11934
+ body: { channel_id: params.channelId }
11935
+ });
11926
11936
  }
11927
11937
  /**
11928
11938
  * Unsubscribe from one feed `(username, name)` — disable that automation's
@@ -12896,6 +12906,634 @@ import * as os from "os";
12896
12906
  import * as fsPromises from "fs/promises";
12897
12907
  import * as readline from "readline";
12898
12908
 
12909
+ // src/cli/commandDefinitions.ts
12910
+ function command(path, {
12911
+ values = [],
12912
+ booleans = [],
12913
+ positionals = [],
12914
+ optionalPositionals = 0,
12915
+ passthrough = false
12916
+ } = {}) {
12917
+ const flags = {};
12918
+ for (const name of values) {
12919
+ flags[name] = "value";
12920
+ }
12921
+ for (const name of booleans) {
12922
+ if (flags[name] !== void 0) {
12923
+ throw new Error(`CLI flag --${name} has conflicting definitions`);
12924
+ }
12925
+ flags[name] = "boolean";
12926
+ }
12927
+ return {
12928
+ path: path.split(" "),
12929
+ flags,
12930
+ positionals: {
12931
+ names: positionals,
12932
+ min: positionals.length - optionalPositionals,
12933
+ max: positionals.length
12934
+ },
12935
+ passthrough
12936
+ };
12937
+ }
12938
+ var GLOBAL_FLAG_DEFINITIONS = {
12939
+ "api-key": "value",
12940
+ "base-url": "value",
12941
+ profile: "value",
12942
+ "arrays-endpoint": "value",
12943
+ help: "boolean"
12944
+ };
12945
+ var COMMAND_DEFINITIONS = [
12946
+ command("configure", {
12947
+ values: ["api-key", "base-url", "profile"]
12948
+ }),
12949
+ // Some route-map nodes are also valid help targets. Their handlers preserve
12950
+ // the existing bare-command help behavior while the trie still resolves
12951
+ // deeper leaves.
12952
+ command("auth"),
12953
+ command("auth login", {
12954
+ values: ["profile", "auth-url", "base-url"],
12955
+ booleans: ["browser", "no-browser"]
12956
+ }),
12957
+ command("whoami"),
12958
+ command("user me"),
12959
+ command("fs read", { values: ["path", "offset", "size"] }),
12960
+ command("fs write", {
12961
+ values: ["path", "data", "file"],
12962
+ booleans: ["mkdir-parents", "append"]
12963
+ }),
12964
+ command("fs stat", { values: ["path"] }),
12965
+ command("fs readdir", {
12966
+ values: ["path"],
12967
+ booleans: ["recursive"]
12968
+ }),
12969
+ command("fs mkdir", { values: ["path"] }),
12970
+ command("fs remove", {
12971
+ values: ["path"],
12972
+ booleans: ["recursive"]
12973
+ }),
12974
+ command("fs rename", { values: ["old-path", "new-path"] }),
12975
+ command("fs copy", { values: ["src-path", "dst-path"] }),
12976
+ command("fs symlink", { values: ["target-path", "link-path"] }),
12977
+ command("fs readlink", { values: ["path"] }),
12978
+ command("fs chmod", { values: ["path", "mode"] }),
12979
+ command("fs grant", { values: ["path", "subject", "permission"] }),
12980
+ command("fs revoke", { values: ["path", "subject", "permission"] }),
12981
+ command("run", {
12982
+ values: [
12983
+ "code",
12984
+ "local-file",
12985
+ "entry-path",
12986
+ "working-dir",
12987
+ "args",
12988
+ "max-heap-size-mb",
12989
+ "timeout-ms"
12990
+ ]
12991
+ }),
12992
+ command("deploy create", {
12993
+ values: [
12994
+ "name",
12995
+ "path",
12996
+ "cron",
12997
+ "args",
12998
+ "max-heap-size-mb",
12999
+ "execution-timeout-seconds",
13000
+ "run-as-service-account"
13001
+ ],
13002
+ booleans: ["push-notify"]
13003
+ }),
13004
+ command("deploy list", { values: ["limit", "cursor"] }),
13005
+ command("deploy get", { values: ["id"] }),
13006
+ command("deploy update", {
13007
+ values: [
13008
+ "id",
13009
+ "name",
13010
+ "cron",
13011
+ "args",
13012
+ "max-heap-size-mb",
13013
+ "execution-timeout-seconds",
13014
+ "run-as-service-account"
13015
+ ],
13016
+ booleans: ["push-notify", "clear-run-as"]
13017
+ }),
13018
+ command("deploy delete", { values: ["id"] }),
13019
+ command("deploy pause", { values: ["id"] }),
13020
+ command("deploy resume", { values: ["id"] }),
13021
+ command("deploy trigger", { values: ["id"] }),
13022
+ command("deploy runs", { values: ["id", "first", "cursor"] }),
13023
+ command("deploy run-status", {
13024
+ values: ["id", "workflow-run-id"]
13025
+ }),
13026
+ command("deploy run-logs", { values: ["id", "run-id"] }),
13027
+ command("loop create", {
13028
+ values: [
13029
+ "goal",
13030
+ "cron",
13031
+ "channel-id",
13032
+ "start",
13033
+ "until",
13034
+ "runs",
13035
+ "name",
13036
+ // Retained so the handler can emit the existing migration guidance.
13037
+ "expires-in"
13038
+ ]
13039
+ }),
13040
+ command("service-account create", { values: ["name"] }),
13041
+ command("service-account list"),
13042
+ command("service-account delete", { values: ["id"] }),
13043
+ command("service-account grant", {
13044
+ values: ["id", "path", "permission"]
13045
+ }),
13046
+ command("service-account revoke", {
13047
+ values: ["id", "path", "permission"]
13048
+ }),
13049
+ command("feed list", { values: ["limit", "cursor", "status"] }),
13050
+ command("feed stop", { values: ["id"] }),
13051
+ command("feed resume", { values: ["id"] }),
13052
+ command("feed delete", { values: ["id"] }),
13053
+ command("feed set-visibility", { values: ["id", "visibility"] }),
13054
+ command("automation list", {
13055
+ values: ["limit", "cursor", "status"],
13056
+ booleans: ["json"]
13057
+ }),
13058
+ command("automation inspect", {
13059
+ values: ["id"],
13060
+ booleans: ["json"]
13061
+ }),
13062
+ command("automation publish", {
13063
+ values: [
13064
+ "name",
13065
+ "version",
13066
+ "cronjob-id",
13067
+ "view-json",
13068
+ "description",
13069
+ "changelog",
13070
+ "agent-type"
13071
+ ]
13072
+ }),
13073
+ command("automation stop", { values: ["id"] }),
13074
+ command("automation resume", { values: ["id"] }),
13075
+ command("automation delete", { values: ["id"] }),
13076
+ command("credits wallet"),
13077
+ command("credits items", {
13078
+ values: ["last", "start", "end", "session-id", "first", "after"],
13079
+ booleans: ["today"]
13080
+ }),
13081
+ command("playbooks trending", {
13082
+ values: ["keyword", "tags", "tag", "sort", "limit", "cursor", "current"],
13083
+ booleans: ["json"]
13084
+ }),
13085
+ command("playbooks set-visibility", {
13086
+ values: ["name", "visibility"]
13087
+ }),
13088
+ command("playbooks get", {
13089
+ values: ["ids", "id", "ref"],
13090
+ booleans: ["json"]
13091
+ }),
13092
+ command("playbooks list", {
13093
+ values: ["owner", "limit", "cursor"],
13094
+ booleans: ["json"]
13095
+ }),
13096
+ command("functions allowance"),
13097
+ command("functions allowance get", { values: ["playbook-id"] }),
13098
+ command("functions allowance list"),
13099
+ command("functions allowance create", {
13100
+ values: ["playbook-id", "amount"]
13101
+ }),
13102
+ command("functions allowance revoke", { values: ["playbook-id"] }),
13103
+ command("functions register", {
13104
+ values: [
13105
+ "playbook-id",
13106
+ "function-name",
13107
+ "entry-script-path",
13108
+ "params-schema",
13109
+ "params-schema-file",
13110
+ "run-as-service-account"
13111
+ ],
13112
+ booleans: ["allow-charges", "clear-run-as"]
13113
+ }),
13114
+ command("functions list", { values: ["playbook-id"] }),
13115
+ command("functions delete", {
13116
+ values: ["playbook-id", "function-name"]
13117
+ }),
13118
+ command("functions invoke", {
13119
+ values: ["playbook-id", "function-name", "params"]
13120
+ }),
13121
+ command("release feed", {
13122
+ values: [
13123
+ "name",
13124
+ "version",
13125
+ "cronjob-id",
13126
+ "view-json",
13127
+ "description",
13128
+ "changelog",
13129
+ "agent-type"
13130
+ ]
13131
+ }),
13132
+ command("release playbook-draft", {
13133
+ values: [
13134
+ "name",
13135
+ "display-name",
13136
+ "description",
13137
+ "feeds",
13138
+ "trading-symbols",
13139
+ "skill-id",
13140
+ "tags"
13141
+ ]
13142
+ }),
13143
+ command("release playbook", {
13144
+ values: ["name", "version", "feeds", "changelog", "readme-url"],
13145
+ booleans: ["bypass-lint"]
13146
+ }),
13147
+ command("lint playbook", {
13148
+ values: ["format"],
13149
+ positionals: ["file argument"]
13150
+ }),
13151
+ command("secrets create", { values: ["name", "value"] }),
13152
+ command("secrets list"),
13153
+ command("secrets get", { values: ["name"] }),
13154
+ command("secrets update", { values: ["name", "value"] }),
13155
+ command("secrets delete", { values: ["name"] }),
13156
+ command("sdk doc", { values: ["name"] }),
13157
+ command("sdk partitions"),
13158
+ command("sdk partition-summary", { values: ["partition"] }),
13159
+ command("data-skills list", { booleans: ["json"] }),
13160
+ command("data-skills summary", {
13161
+ booleans: ["json"],
13162
+ positionals: ["skill name"]
13163
+ }),
13164
+ command("data-skills endpoint", {
13165
+ booleans: ["json"],
13166
+ positionals: ["skill name", "endpoint file"]
13167
+ }),
13168
+ command("skillhub list", {
13169
+ values: ["tag", "username"],
13170
+ booleans: ["json"]
13171
+ }),
13172
+ command("skillhub tags", { booleans: ["json"] }),
13173
+ command("skillhub get", {
13174
+ booleans: ["json"],
13175
+ positionals: ["playbook skill identifier"]
13176
+ }),
13177
+ command("skillhub file", {
13178
+ booleans: ["json"],
13179
+ positionals: ["playbook skill identifier", "file path"]
13180
+ }),
13181
+ command("comments create", {
13182
+ values: ["username", "name", "content", "parent-id"]
13183
+ }),
13184
+ command("comments pin", { values: ["comment-id"] }),
13185
+ command("comments unpin", { values: ["comment-id"] }),
13186
+ command("notification-history list-feed", {
13187
+ values: [
13188
+ "username",
13189
+ "name",
13190
+ "delivery-provider",
13191
+ // Retained so the handler can emit the existing rename guidance.
13192
+ "channel",
13193
+ "status",
13194
+ "since",
13195
+ "first",
13196
+ "cursor"
13197
+ ]
13198
+ }),
13199
+ command("notification-preferences list"),
13200
+ command("notification-preferences enable-session-completed"),
13201
+ command("notification-preferences disable-session-completed"),
13202
+ command("feedback submit", {
13203
+ values: [
13204
+ "source",
13205
+ "category",
13206
+ "severity",
13207
+ "summary",
13208
+ "details",
13209
+ "evidence-json",
13210
+ "context-json",
13211
+ // Retained so the handler can emit the existing migration guidance.
13212
+ "dedupe-key"
13213
+ ]
13214
+ }),
13215
+ command("subscriptions follow-playbook", {
13216
+ values: ["username", "name"]
13217
+ }),
13218
+ command("subscriptions unfollow-playbook", {
13219
+ values: ["username", "name"]
13220
+ }),
13221
+ command("subscriptions subscribe-feed", {
13222
+ values: ["username", "name"]
13223
+ }),
13224
+ command("subscriptions unsubscribe-feed", {
13225
+ values: ["username", "name"]
13226
+ }),
13227
+ command("subscriptions list", { values: ["first", "cursor"] }),
13228
+ command("subscriptions follows", { values: ["limit", "cursor"] }),
13229
+ command("subscriptions subscribe", {
13230
+ values: ["feed-ids", "channel-id", "playbook-ids"]
13231
+ }),
13232
+ command("subscriptions unsubscribe", {
13233
+ values: ["feed-ids", "playbook-ids"]
13234
+ }),
13235
+ command("alert list", {
13236
+ values: ["first", "cursor"],
13237
+ booleans: ["json"]
13238
+ }),
13239
+ command("alert follows", { values: ["limit", "cursor"] }),
13240
+ command("alert enable", {
13241
+ values: [
13242
+ "automation",
13243
+ "automation-ids",
13244
+ "channel-id",
13245
+ "playbook",
13246
+ "playbook-ids"
13247
+ ]
13248
+ }),
13249
+ command("alert disable", {
13250
+ values: ["automation", "automation-ids", "playbook", "playbook-ids"]
13251
+ }),
13252
+ command("alert group"),
13253
+ command("alert group list", {
13254
+ values: ["session-id"],
13255
+ booleans: ["json"]
13256
+ }),
13257
+ command("alert group enable", {
13258
+ values: ["automation", "automation-ids", "channel-id", "session-id"]
13259
+ }),
13260
+ command("alert group disable", {
13261
+ values: ["automation", "automation-ids", "channel-id", "session-id"]
13262
+ }),
13263
+ command("alert history", {
13264
+ values: [
13265
+ "automation",
13266
+ "playbook",
13267
+ "playbook-ids",
13268
+ "delivery-provider",
13269
+ // Retained so the handler can emit the existing rename guidance.
13270
+ "channel",
13271
+ "status",
13272
+ "since",
13273
+ "first",
13274
+ "cursor"
13275
+ ]
13276
+ }),
13277
+ command("alert preferences"),
13278
+ command("alert enable-session-completed"),
13279
+ command("alert disable-session-completed"),
13280
+ command("remix", {
13281
+ values: ["child-username", "child-name", "parents"]
13282
+ }),
13283
+ command("arrays"),
13284
+ command("arrays token"),
13285
+ command("arrays token ensure"),
13286
+ command("arrays token status"),
13287
+ command("screenshot", {
13288
+ values: [
13289
+ "url",
13290
+ "out",
13291
+ "selector",
13292
+ "xpath",
13293
+ "compress-quality",
13294
+ "compress-max-width"
13295
+ ],
13296
+ booleans: ["base64", "full", "compress"]
13297
+ }),
13298
+ command("portfolio accounts"),
13299
+ command("portfolio summary", { values: ["account-id"] }),
13300
+ command("portfolio activities", {
13301
+ values: ["account-id", "limit", "page-token"]
13302
+ }),
13303
+ command("trading accounts"),
13304
+ command("trading portfolio", { values: ["account-id"] }),
13305
+ command("trading orders", {
13306
+ values: ["account-id", "source", "since", "limit"]
13307
+ }),
13308
+ command("trading subscriptions", { values: ["account-id"] }),
13309
+ command("trading equity-history", {
13310
+ values: ["account-id", "timeframe", "since-ms", "until-ms"]
13311
+ }),
13312
+ command("trading risk-rules"),
13313
+ command("trading subscribe", {
13314
+ values: [
13315
+ "account-id",
13316
+ "source-username",
13317
+ "source-feed",
13318
+ "playbook-id",
13319
+ "playbook-version"
13320
+ ],
13321
+ booleans: ["execute-latest"]
13322
+ }),
13323
+ command("trading unsubscribe", { values: ["subscription-id"] }),
13324
+ command("trading execute", {
13325
+ values: ["account-id", "signal", "source-username", "source-feed"],
13326
+ booleans: ["dry-run"]
13327
+ }),
13328
+ command("trading update-risk-rules", {
13329
+ values: [
13330
+ "max-single-order-value",
13331
+ "max-single-order-enabled",
13332
+ "max-daily-turnover-value",
13333
+ "max-daily-turnover-enabled",
13334
+ "max-daily-orders-value",
13335
+ "max-daily-orders-enabled"
13336
+ ]
13337
+ }),
13338
+ command("broker", { passthrough: true })
13339
+ ];
13340
+
13341
+ // src/cli/commandSchema.ts
13342
+ function buildCommandTree(definitions) {
13343
+ const root = { children: /* @__PURE__ */ new Map() };
13344
+ for (const definition of definitions) {
13345
+ if (definition.path.length === 0) {
13346
+ throw new Error("CLI command path cannot be empty");
13347
+ }
13348
+ if (definition.positionals.min < 0 || definition.positionals.max < definition.positionals.min || definition.positionals.max !== definition.positionals.names.length) {
13349
+ throw new Error(
13350
+ `Invalid positional definition for '${definition.path.join(" ")}'`
13351
+ );
13352
+ }
13353
+ let node = root;
13354
+ for (const segment of definition.path) {
13355
+ let child = node.children.get(segment);
13356
+ if (child === void 0) {
13357
+ child = { children: /* @__PURE__ */ new Map() };
13358
+ node.children.set(segment, child);
13359
+ }
13360
+ node = child;
13361
+ }
13362
+ if (node.definition !== void 0) {
13363
+ throw new Error(
13364
+ `Duplicate CLI command definition '${definition.path.join(" ")}'`
13365
+ );
13366
+ }
13367
+ node.definition = definition;
13368
+ }
13369
+ return root;
13370
+ }
13371
+ var COMMAND_TREE = buildCommandTree(COMMAND_DEFINITIONS);
13372
+ function editDistance(a, b) {
13373
+ let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
13374
+ for (let row = 1; row <= a.length; row++) {
13375
+ const current = [row];
13376
+ for (let column = 1; column <= b.length; column++) {
13377
+ current[column] = Math.min(
13378
+ current[column - 1] + 1,
13379
+ previous[column] + 1,
13380
+ previous[column - 1] + (a[row - 1] === b[column - 1] ? 0 : 1)
13381
+ );
13382
+ }
13383
+ previous = current;
13384
+ }
13385
+ return previous[b.length];
13386
+ }
13387
+ function closestFlag(input, available) {
13388
+ let closest;
13389
+ let distance = Number.POSITIVE_INFINITY;
13390
+ for (const candidate of Object.keys(available)) {
13391
+ const candidateDistance = editDistance(input, candidate);
13392
+ if (candidateDistance < distance) {
13393
+ closest = candidate;
13394
+ distance = candidateDistance;
13395
+ }
13396
+ }
13397
+ const threshold = input.length <= 4 ? 1 : 2;
13398
+ return distance <= threshold ? closest : void 0;
13399
+ }
13400
+ function mergeFlags(definition) {
13401
+ return { ...GLOBAL_FLAG_DEFINITIONS, ...definition.flags };
13402
+ }
13403
+ function resolveCommand(args) {
13404
+ let node = COMMAND_TREE;
13405
+ let consumed = 0;
13406
+ while (consumed < args.length) {
13407
+ const input = args[consumed];
13408
+ if (input.startsWith("-")) break;
13409
+ const child = node.children.get(input);
13410
+ if (child !== void 0) {
13411
+ node = child;
13412
+ consumed++;
13413
+ continue;
13414
+ }
13415
+ if (node.definition !== void 0 && node.children.size === 0) break;
13416
+ if (consumed === 0) {
13417
+ throw new CliUsageError(`Unknown command: '${input}'`);
13418
+ }
13419
+ const group2 = args[0];
13420
+ const command2 = args.slice(0, consumed).join(" ");
13421
+ throw new CliUsageError(
13422
+ `Unknown subcommand: ${command2} ${input}. Use 'alva ${group2} --help' for usage.`,
13423
+ group2
13424
+ );
13425
+ }
13426
+ if (node.definition !== void 0) {
13427
+ return { definition: node.definition, consumed };
13428
+ }
13429
+ const group = args[0];
13430
+ if (group === void 0) {
13431
+ throw new CliUsageError("Missing command");
13432
+ }
13433
+ throw new CliUsageError(`Missing subcommand for ${group}`, group);
13434
+ }
13435
+ function unsupportedFlag(name, definition, available) {
13436
+ const command2 = definition.path.join(" ");
13437
+ const suggestion = closestFlag(name, available);
13438
+ const suffix = suggestion === void 0 ? "" : ` Did you mean '--${suggestion}'?`;
13439
+ return new CliUsageError(
13440
+ `--${name} is not supported for '${command2}'.${suffix}`,
13441
+ definition.path[0]
13442
+ );
13443
+ }
13444
+ function parseCommand(args) {
13445
+ const { definition, consumed } = resolveCommand(args);
13446
+ if (definition.passthrough === true) {
13447
+ return {
13448
+ path: definition.path,
13449
+ flags: {},
13450
+ positionals: [],
13451
+ passthrough: args.slice(consumed)
13452
+ };
13453
+ }
13454
+ const available = mergeFlags(definition);
13455
+ const flags = {};
13456
+ const positionals = [];
13457
+ for (let index = consumed; index < args.length; index++) {
13458
+ const input = args[index];
13459
+ if (input === "-h") {
13460
+ flags.help = "true";
13461
+ continue;
13462
+ }
13463
+ if (!input.startsWith("--")) {
13464
+ positionals.push(input);
13465
+ continue;
13466
+ }
13467
+ const equalsIndex = input.indexOf("=");
13468
+ const externalName = equalsIndex === -1 ? input.slice(2) : input.slice(2, equalsIndex);
13469
+ let name = externalName;
13470
+ let kind = available[name];
13471
+ let negated = false;
13472
+ if (kind === void 0 && name.startsWith("no-") && available[name.slice(3)] === "boolean") {
13473
+ name = name.slice(3);
13474
+ kind = "boolean";
13475
+ negated = true;
13476
+ }
13477
+ if (kind === void 0) {
13478
+ throw unsupportedFlag(externalName, definition, available);
13479
+ }
13480
+ if (equalsIndex !== -1) {
13481
+ const value2 = input.slice(equalsIndex + 1);
13482
+ if (kind === "boolean") {
13483
+ if (value2 !== "true" && value2 !== "false") {
13484
+ throw new CliUsageError(
13485
+ `--${externalName} must be true or false`,
13486
+ definition.path[0]
13487
+ );
13488
+ }
13489
+ flags[name] = negated === true ? value2 === "true" ? "false" : "true" : value2;
13490
+ } else {
13491
+ flags[name] = value2;
13492
+ }
13493
+ continue;
13494
+ }
13495
+ if (kind === "boolean") {
13496
+ flags[name] = negated ? "false" : "true";
13497
+ continue;
13498
+ }
13499
+ const value = args[index + 1];
13500
+ if (value === void 0 || value.startsWith("--")) {
13501
+ throw new CliUsageError(
13502
+ `--${externalName} requires a value`,
13503
+ definition.path[0]
13504
+ );
13505
+ }
13506
+ flags[name] = value;
13507
+ index++;
13508
+ }
13509
+ const command2 = definition.path.join(" ");
13510
+ if (flags.help !== void 0) {
13511
+ return {
13512
+ path: definition.path,
13513
+ flags,
13514
+ positionals
13515
+ };
13516
+ }
13517
+ if (positionals.length < definition.positionals.min) {
13518
+ const missingName = definition.positionals.names[positionals.length] ?? "argument";
13519
+ throw new CliUsageError(
13520
+ `Missing ${missingName} for '${command2}'`,
13521
+ definition.path[0]
13522
+ );
13523
+ }
13524
+ if (positionals.length > definition.positionals.max) {
13525
+ throw new CliUsageError(
13526
+ `Unexpected argument '${positionals[definition.positionals.max]}' for '${command2}'`,
13527
+ definition.path[0]
13528
+ );
13529
+ }
13530
+ return {
13531
+ path: definition.path,
13532
+ flags,
13533
+ positionals
13534
+ };
13535
+ }
13536
+
12899
13537
  // src/cli/pkce.ts
12900
13538
  import * as crypto from "crypto";
12901
13539
  function generateCodeVerifier() {
@@ -12913,22 +13551,6 @@ var DEFAULT_BASE_URL2 = "https://api-llm.prd.alva.ai";
12913
13551
  var DEFAULT_AUTH_URL = "https://alva.ai";
12914
13552
  var CLIENT_ID = "alva-cli";
12915
13553
  var SCOPE = "cli";
12916
- function parseFlags(argv) {
12917
- const flags = {};
12918
- for (let i = 0; i < argv.length; i++) {
12919
- const arg = argv[i];
12920
- if (arg.startsWith("--")) {
12921
- const eqIdx = arg.indexOf("=");
12922
- if (eqIdx !== -1) {
12923
- flags[arg.slice(2, eqIdx)] = arg.slice(eqIdx + 1);
12924
- } else if (i + 1 < argv.length && !argv[i + 1].startsWith("--")) {
12925
- flags[arg.slice(2)] = argv[i + 1];
12926
- i++;
12927
- }
12928
- }
12929
- }
12930
- return flags;
12931
- }
12932
13554
  function defaultOpenBrowser(url) {
12933
13555
  const platform = process.platform;
12934
13556
  let cmd;
@@ -13027,7 +13649,7 @@ async function exchangeCodeForApiKey(params) {
13027
13649
  var SUCCESS_HTML = `<html><body style="display:flex;align-items:center;justify-content:center;height:100vh;margin:0;background:rgba(246,246,246,1);font-family:system-ui,sans-serif"><div style="text-align:center;display:flex;flex-direction:column;align-items:center;gap:40px"><h1 style="font-size:45px;font-weight:400;line-height:120%;margin:0">Turn Ideas into Live<br>Investing Playbooks in Minutes</h1><p style="font-size:24px;font-weight:400;margin:0">You're all set for Alva.</p></div></body></html>`;
13028
13650
  async function handleAuthLogin(args, deps) {
13029
13651
  const d = { ...defaultDeps(), ...deps };
13030
- const flags = parseFlags(args.slice(1));
13652
+ const flags = parseCommand(args).flags;
13031
13653
  const profileName = flags.profile || "default";
13032
13654
  const authUrl = flags["auth-url"] || DEFAULT_AUTH_URL;
13033
13655
  const baseUrl = flags["base-url"] || DEFAULT_BASE_URL2;
@@ -13261,7 +13883,7 @@ function defaultNoBrowserDeps() {
13261
13883
  }
13262
13884
  async function handleAuthLoginNoBrowser(args, deps) {
13263
13885
  const d = { ...defaultNoBrowserDeps(), ...deps };
13264
- const flags = parseFlags(args.slice(1));
13886
+ const flags = parseCommand(args).flags;
13265
13887
  const profileName = flags.profile || "default";
13266
13888
  const authUrl = flags["auth-url"] || DEFAULT_AUTH_URL;
13267
13889
  const baseUrl = flags["base-url"] || DEFAULT_BASE_URL2;
@@ -13629,6 +14251,9 @@ function formatAlertList(result) {
13629
14251
  const status = alert.target_status ? ` [${alert.target_status}]` : "";
13630
14252
  lines.push(`\u2022 ${alertTitle(alert)}${status}`);
13631
14253
  lines.push(` target: ${targetType} ${alert.target?.id ?? ""}`.trimEnd());
14254
+ if (alert.channel_id !== void 0) {
14255
+ lines.push(` channel: ${alert.channel_id}`);
14256
+ }
13632
14257
  if (alert.kind) lines.push(` kind: ${alert.kind}`);
13633
14258
  if (alert.feed_status)
13634
14259
  lines.push(` automation status: ${alert.feed_status}`);
@@ -13672,10 +14297,23 @@ import * as fs2 from "fs";
13672
14297
  import * as os2 from "os";
13673
14298
  import * as fsPromises2 from "fs/promises";
13674
14299
  import { Agent, setGlobalDispatcher } from "undici";
13675
- var CLI_VERSION = true ? "0.19.0" : "dev";
14300
+ var CLI_VERSION = true ? "0.20.0" : "dev";
13676
14301
  var DEFAULT_RUN_TIMEOUT_MS = 6e5;
13677
14302
  var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
13678
14303
  var configuredRunFetchTimeoutMs;
14304
+ var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
14305
+ var GLOBAL_VALUE_FLAG_SET = new Set(GLOBAL_VALUE_FLAGS);
14306
+ var BOOLEAN_FLAGS = (() => {
14307
+ const flags = new Set(
14308
+ Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "boolean").map(([name]) => name)
14309
+ );
14310
+ for (const definition of COMMAND_DEFINITIONS) {
14311
+ for (const [name, kind] of Object.entries(definition.flags)) {
14312
+ if (kind === "boolean") flags.add(name);
14313
+ }
14314
+ }
14315
+ return flags;
14316
+ })();
13679
14317
  function isVersionOlderThan(a, b) {
13680
14318
  const parse4 = (v) => {
13681
14319
  if (!v) return null;
@@ -13802,8 +14440,9 @@ Verify that your credentials are valid by calling the Alva API. Shows your
13802
14440
  username, subscription tier, and which profile/endpoint is being used.
13803
14441
  Use this after 'alva configure' to confirm everything works.
13804
14442
 
13805
- Output also includes _meta.arrays_jwt (exists, expires_at, renewal_needed,
13806
- tier) when the backend is reachable; the field is omitted on RPC failure.
14443
+ Output includes active_im_provider (telegram, discord, slack, whatsapp,
14444
+ imessage, or empty) and _meta.arrays_jwt (exists, expires_at, renewal_needed,
14445
+ tier). arrays_jwt is omitted when the backend status call fails.
13807
14446
 
13808
14447
  Examples:
13809
14448
  alva whoami
@@ -13822,7 +14461,7 @@ Response fields:
13822
14461
  slack_username Slack display name if connected, empty otherwise
13823
14462
  whatsapp_username WhatsApp display name if connected, empty otherwise
13824
14463
  imessage_username iMessage display name if connected, empty otherwise
13825
- active_channel Currently selected IM delivery channel
14464
+ active_im_provider Currently selected IM provider
13826
14465
 
13827
14466
  Examples:
13828
14467
  alva user me`,
@@ -13985,6 +14624,7 @@ Subcommands:
13985
14624
  resume Resume a paused cronjob
13986
14625
  trigger Fire the cronjob once, immediately, bypassing the schedule
13987
14626
  (returns workflow_run_id; poll 'run-status' with a timeout)
14627
+ This is not a dry run and may deliver Feed alerts to subscribers.
13988
14628
  runs List runs for a cronjob (cursor-paginated)
13989
14629
  run-status Get one triggered run's pollable status by workflow_run_id
13990
14630
  run-logs Get stdout/stderr logs for a single cronjob run
@@ -13994,8 +14634,8 @@ Create/Update flags:
13994
14634
  --path <path> Path to script on ALFS (required on create, must exist)
13995
14635
  --cron <expression> Cron expression (required on create, e.g. "0 */4 * * *")
13996
14636
  --args <json> JSON object passed to require("env").args
13997
- --push-notify Enable Telegram push notifications on completion
13998
- --no-push-notify Disable push notifications
14637
+ --push-notify Let successful Feed runs deliver declared alert outputs
14638
+ --no-push-notify Disable Feed alert delivery
13999
14639
  --max-heap-size-mb <mb> Override per-cronjob V8 heap limit (1-2046, default uses server config)
14000
14640
  --execution-timeout-seconds <seconds> Wall-clock timeout (1-3600; create default: 1800; update omitted: unchanged)
14001
14641
  --run-as-service-account <id> Run the cronjob under a service-account identity
@@ -14050,6 +14690,8 @@ Examples:
14050
14690
  alva deploy run-logs --id 42 --run-id 123
14051
14691
 
14052
14692
  Build-time verify (fire once, then poll up to 5 minutes):
14693
+ WARNING: trigger uses production delivery semantics. If --push-notify and
14694
+ subscriber alert bindings are enabled, this run may send real notifications.
14053
14695
  WF=$(alva deploy trigger --id 42 | jq -r .workflow_run_id)
14054
14696
  for _ in {1..60}; do
14055
14697
  STATUS_JSON=$(alva deploy run-status --id 42 --workflow-run-id "$WF")
@@ -14064,9 +14706,9 @@ Build-time verify (fire once, then poll up to 5 minutes):
14064
14706
  --run-id "$(echo "$STATUS_JSON" | jq -r .run.id)"`,
14065
14707
  loop: `Usage: alva loop <subcommand> [options]
14066
14708
 
14067
- Create a bounded, self-scheduled in-channel goal loop. Each tick runs one
14068
- fire-and-forget agent turn on a channel's stable main session (via the
14069
- @alva/loop SDK), continuing that channel's conversation toward a goal. Creation
14709
+ Create a bounded, self-scheduled goal loop in an Alva channel. Each tick runs
14710
+ one fire-and-forget agent turn on the Alva channel's stable main
14711
+ session (via the @alva/loop SDK), continuing that conversation toward a goal. Creation
14070
14712
  seeds a shared runner, creates its cronjob, and registers the cronjob as an
14071
14713
  Automation without starting an extra publish-time run.
14072
14714
 
@@ -14076,7 +14718,8 @@ Subcommands:
14076
14718
  Create flags:
14077
14719
  --goal <text> Instruction run each tick (required)
14078
14720
  --cron <expression> Cron schedule (required, e.g. "0 * * * *")
14079
- --channel-id <id> Target channel id. Omit \u21D2 your DM/agent channel
14721
+ --channel-id <id> Target Alva channel ID. Omit \u21D2 your default
14722
+ Alva agent channel
14080
14723
  --start <time> First eligible time: 'now' (default) or RFC3339
14081
14724
  --until <time> Exclusive RFC3339 cutoff
14082
14725
  --runs <count> Maximum admitted runs after --start
@@ -14156,8 +14799,9 @@ Examples:
14156
14799
 
14157
14800
  Manage alerts. Alert subscriptions target automations (feeds) only. Playbook
14158
14801
  follows are independent; delivery history and global preferences live here too.
14159
- Personal alerts may be routed to different Alva delivery channels. Group alerts
14160
- are managed explicitly through "alert group" and target the current group.
14802
+ Personal alerts may be routed to different Alva channels. External IM
14803
+ group alerts are managed explicitly through "alert group" and target the current
14804
+ group.
14161
14805
 
14162
14806
  Subcommands:
14163
14807
  list List the caller's active alerts
@@ -14170,20 +14814,20 @@ Subcommands:
14170
14814
  enable-session-completed
14171
14815
  disable-session-completed
14172
14816
 
14173
- Target flags:
14817
+ Target flags (choose one):
14174
14818
  --automation <owner/name> Automation target
14175
-
14176
- Enable/disable-by-id flags:
14177
14819
  --automation-ids <a,b> Comma-separated automation target ids
14178
- --channel-id <id> Delivery channel for batch enable (optional)
14820
+
14821
+ Enable routing:
14822
+ --channel-id <id> Alva channel ID for name or id targets (optional)
14179
14823
 
14180
14824
  Group subcommands:
14181
14825
  alva alert group list
14182
14826
  alva alert group enable --automation-ids <id>
14183
14827
  alva alert group disable --automation-ids <id>
14184
14828
 
14185
- Group commands must run inside the attached channel-group sandbox. The current
14186
- group is inferred automatically; there is no session-id argument.
14829
+ Group commands must run inside the attached external IM-group sandbox. The
14830
+ current group is inferred automatically; there is no session-id argument.
14187
14831
 
14188
14832
  List flags:
14189
14833
  --first <n> Optional page size
@@ -14195,7 +14839,7 @@ Follows flags:
14195
14839
  --cursor <token> Optional cursor from previous response
14196
14840
 
14197
14841
  History flags:
14198
- --channel <name> Optional delivery channel filter
14842
+ --delivery-provider <name> Optional provider filter (telegram, web, ...)
14199
14843
  --status <status> Optional status filter (sent, failed, filtered)
14200
14844
  --since <seconds> Optional Unix seconds lower bound
14201
14845
 
@@ -14609,7 +15253,7 @@ Subcommands:
14609
15253
  Common flags:
14610
15254
  --username <user> Owner's username (required)
14611
15255
  --name <name> URL-safe feed name (required)
14612
- --channel <name> Optional delivery channel filter (telegram, web, ...)
15256
+ --delivery-provider <name> Optional provider filter (telegram, web, ...)
14613
15257
  --status <status> Optional status filter (sent, failed, filtered)
14614
15258
  --since <seconds> Optional Unix seconds lower bound
14615
15259
  --first <n> Optional page size (default 50, max 200 server-side)
@@ -14681,7 +15325,7 @@ Name-addressed flags:
14681
15325
 
14682
15326
  Batch flags:
14683
15327
  --feed-ids <a,b> Comma-separated feed target ids
14684
- --channel-id <id> Delivery channel for subscribe (optional)
15328
+ --channel-id <id> Alva channel ID for subscribe (optional)
14685
15329
 
14686
15330
  List flags:
14687
15331
  --first <n> Optional page size (response carries total_count \u2014
@@ -14842,7 +15486,7 @@ Examples:
14842
15486
  alva arrays token status`
14843
15487
  };
14844
15488
  async function handleConfigure(args, deps) {
14845
- const flags = parseFlags2(args.slice(1));
15489
+ const flags = parseCommand(args).flags;
14846
15490
  const apiKey = flags["api-key"];
14847
15491
  if (!apiKey) {
14848
15492
  throw new CliUsageError("--api-key is required", "configure");
@@ -14880,36 +15524,17 @@ async function handleConfigure(args, deps) {
14880
15524
  profile: profileName
14881
15525
  };
14882
15526
  }
14883
- var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
14884
- "recursive",
14885
- "mkdir-parents",
14886
- "append",
14887
- "push-notify",
14888
- "help",
14889
- "execute-latest",
14890
- "dry-run",
14891
- "allow-charges",
14892
- "clear-run-as",
14893
- "json",
14894
- "compress",
14895
- "bypass-lint",
14896
- "no-browser",
14897
- "browser",
14898
- "base64",
14899
- "full",
14900
- "today"
14901
- ]);
14902
- function parseFlags2(argv) {
15527
+ function parseFlags(argv) {
14903
15528
  const flags = {};
14904
- for (let i = 0; i < argv.length; i++) {
14905
- const arg = argv[i];
14906
- if (!arg.startsWith("--")) continue;
14907
- const eqIdx = arg.indexOf("=");
14908
- if (eqIdx !== -1) {
14909
- flags[arg.slice(2, eqIdx)] = arg.slice(eqIdx + 1);
15529
+ for (let index = 0; index < argv.length; index++) {
15530
+ const argument = argv[index];
15531
+ if (!argument.startsWith("--")) continue;
15532
+ const equalsIndex = argument.indexOf("=");
15533
+ if (equalsIndex !== -1) {
15534
+ flags[argument.slice(2, equalsIndex)] = argument.slice(equalsIndex + 1);
14910
15535
  continue;
14911
15536
  }
14912
- const name = arg.slice(2);
15537
+ const name = argument.slice(2);
14913
15538
  if (BOOLEAN_FLAGS.has(name)) {
14914
15539
  flags[name] = "true";
14915
15540
  continue;
@@ -14918,18 +15543,12 @@ function parseFlags2(argv) {
14918
15543
  flags[name.slice(3)] = "false";
14919
15544
  continue;
14920
15545
  }
14921
- const next = argv[i + 1];
14922
- if (next === void 0 || next.startsWith("--")) {
14923
- throw new CliUsageError(
14924
- `--${name} requires a value`,
14925
- // Group is best-effort: first non-flag arg of the original
14926
- // argv. parseFlags doesn't track group, so just use the flag
14927
- // name as a fallback hint.
14928
- name
14929
- );
15546
+ const value = argv[index + 1];
15547
+ if (value === void 0 || value.startsWith("--")) {
15548
+ throw new CliUsageError(`--${name} requires a value`, name);
14930
15549
  }
14931
- flags[name] = next;
14932
- i++;
15550
+ flags[name] = value;
15551
+ index++;
14933
15552
  }
14934
15553
  return flags;
14935
15554
  }
@@ -14938,106 +15557,106 @@ function boolFlag(val) {
14938
15557
  if (val === "false") return false;
14939
15558
  return void 0;
14940
15559
  }
14941
- function requireFlag(flags, name, command) {
15560
+ function requireFlag(flags, name, command2) {
14942
15561
  const val = flags[name];
14943
15562
  if (val === void 0) {
14944
- const group = command.split(" ")[0];
14945
- throw new CliUsageError(`--${name} is required for '${command}'`, group);
15563
+ const group = command2.split(" ")[0];
15564
+ throw new CliUsageError(`--${name} is required for '${command2}'`, group);
14946
15565
  }
14947
15566
  return val;
14948
15567
  }
14949
- function requireNumericFlag(flags, name, command) {
14950
- const val = requireFlag(flags, name, command);
15568
+ function requireNumericFlag(flags, name, command2) {
15569
+ const val = requireFlag(flags, name, command2);
14951
15570
  const n = Number(val);
14952
15571
  if (Number.isNaN(n)) {
14953
- const group = command.split(" ")[0];
15572
+ const group = command2.split(" ")[0];
14954
15573
  throw new CliUsageError(
14955
- `--${name} must be a number for '${command}', got '${val}'`,
15574
+ `--${name} must be a number for '${command2}', got '${val}'`,
14956
15575
  group
14957
15576
  );
14958
15577
  }
14959
15578
  return n;
14960
15579
  }
14961
- function requirePositiveIntegerFlag(flags, name, command) {
14962
- const val = requireFlag(flags, name, command);
15580
+ function requirePositiveIntegerFlag(flags, name, command2) {
15581
+ const val = requireFlag(flags, name, command2);
14963
15582
  if (!/^[1-9]\d*$/.test(val)) {
14964
- const group = command.split(" ")[0];
15583
+ const group = command2.split(" ")[0];
14965
15584
  throw new CliUsageError(
14966
- `--${name} must be a positive integer for '${command}', got '${val}'`,
15585
+ `--${name} must be a positive integer for '${command2}', got '${val}'`,
14967
15586
  group
14968
15587
  );
14969
15588
  }
14970
15589
  return Number(val);
14971
15590
  }
14972
- function requirePositiveIntegerStringFlag(flags, name, command) {
14973
- const val = requireFlag(flags, name, command);
15591
+ function requirePositiveIntegerStringFlag(flags, name, command2) {
15592
+ const val = requireFlag(flags, name, command2);
14974
15593
  if (!/^[1-9]\d*$/.test(val)) {
14975
- const group = command.split(" ")[0];
15594
+ const group = command2.split(" ")[0];
14976
15595
  throw new CliUsageError(
14977
- `--${name} must be a positive integer for '${command}', got '${val}'`,
15596
+ `--${name} must be a positive integer for '${command2}', got '${val}'`,
14978
15597
  group
14979
15598
  );
14980
15599
  }
14981
15600
  return val;
14982
15601
  }
14983
- function optionalBoundedIntegerFlag(flags, name, command, min, max) {
15602
+ function optionalBoundedIntegerFlag(flags, name, command2, min, max) {
14984
15603
  const val = flags[name];
14985
15604
  if (val === void 0) return void 0;
14986
15605
  const n = Number(val);
14987
15606
  if (!Number.isInteger(n) || n < min || n > max) {
14988
- const group = command.split(" ")[0];
15607
+ const group = command2.split(" ")[0];
14989
15608
  throw new CliUsageError(
14990
- `--${name} must be an integer between ${min} and ${max} for '${command}', got '${val}'`,
15609
+ `--${name} must be an integer between ${min} and ${max} for '${command2}', got '${val}'`,
14991
15610
  group
14992
15611
  );
14993
15612
  }
14994
15613
  return n;
14995
15614
  }
14996
- function optionalServiceAccountIdFlag(flags, command) {
15615
+ function optionalServiceAccountIdFlag(flags, command2) {
14997
15616
  const raw = flags["run-as-service-account"];
14998
15617
  if (raw === void 0) return void 0;
14999
15618
  if (!/^[1-9]\d*$/.test(raw)) {
15000
15619
  throw new CliUsageError(
15001
- `--run-as-service-account must be a positive service-account id for '${command}', got '${raw}'`,
15002
- command.split(" ")[0]
15620
+ `--run-as-service-account must be a positive service-account id for '${command2}', got '${raw}'`,
15621
+ command2.split(" ")[0]
15003
15622
  );
15004
15623
  }
15005
15624
  return raw;
15006
15625
  }
15007
- function resolveRunAsFlag(flags, command) {
15626
+ function resolveRunAsFlag(flags, command2) {
15008
15627
  const clear = boolFlag(flags["clear-run-as"]) ?? false;
15009
- const setID = optionalServiceAccountIdFlag(flags, command);
15628
+ const setID = optionalServiceAccountIdFlag(flags, command2);
15010
15629
  if (clear && setID !== void 0) {
15011
15630
  throw new CliUsageError(
15012
- `--clear-run-as and --run-as-service-account are mutually exclusive for '${command}'`,
15013
- command.split(" ")[0]
15631
+ `--clear-run-as and --run-as-service-account are mutually exclusive for '${command2}'`,
15632
+ command2.split(" ")[0]
15014
15633
  );
15015
15634
  }
15016
15635
  if (clear) return "0";
15017
15636
  return setID;
15018
15637
  }
15019
- function requireServiceAccountIdFlag(flags, command) {
15638
+ function requireServiceAccountIdFlag(flags, command2) {
15020
15639
  const raw = flags["id"];
15021
15640
  if (raw === void 0 || raw === "") {
15022
15641
  throw new CliUsageError(
15023
- `Missing required flag --id for '${command}'`,
15024
- command.split(" ")[0]
15642
+ `Missing required flag --id for '${command2}'`,
15643
+ command2.split(" ")[0]
15025
15644
  );
15026
15645
  }
15027
15646
  if (!/^[1-9]\d*$/.test(raw)) {
15028
15647
  throw new CliUsageError(
15029
- `--id must be a positive service-account id for '${command}', got '${raw}'`,
15030
- command.split(" ")[0]
15648
+ `--id must be a positive service-account id for '${command2}', got '${raw}'`,
15649
+ command2.split(" ")[0]
15031
15650
  );
15032
15651
  }
15033
15652
  return raw;
15034
15653
  }
15035
- function parsePositiveIntegerValue(val, label, command) {
15654
+ function parsePositiveIntegerValue(val, label, command2) {
15036
15655
  const n = Number(val);
15037
15656
  if (!/^[1-9]\d*$/.test(val) || !Number.isSafeInteger(n)) {
15038
- const group = command.split(" ")[0];
15657
+ const group = command2.split(" ")[0];
15039
15658
  throw new CliUsageError(
15040
- `${label} must be a positive integer for '${command}', got '${val}'`,
15659
+ `${label} must be a positive integer for '${command2}', got '${val}'`,
15041
15660
  group
15042
15661
  );
15043
15662
  }
@@ -15071,50 +15690,80 @@ function configureRunFetchTimeout(timeoutMs, deps) {
15071
15690
  );
15072
15691
  configuredRunFetchTimeoutMs = timeoutMs;
15073
15692
  }
15074
- function requireCurrentGroupAlertSessionID(client, command) {
15693
+ function requireCurrentGroupAlertSessionID(client, command2) {
15075
15694
  if (client.originSessionKind !== "channel_group") {
15076
15695
  throw new CliUsageError(
15077
- `'${command}' is only available inside a channel-group sandbox`,
15696
+ `'${command2}' is only available inside an external IM-group sandbox`,
15078
15697
  "alert"
15079
15698
  );
15080
15699
  }
15081
15700
  const sessionID = client.originSessionId;
15082
15701
  if (sessionID === void 0) {
15083
15702
  throw new CliUsageError(
15084
- `current group session is unavailable for '${command}'`,
15703
+ `current group session is unavailable for '${command2}'`,
15085
15704
  "alert"
15086
15705
  );
15087
15706
  }
15088
15707
  if (!/^[1-9]\d*$/.test(sessionID)) {
15089
15708
  throw new CliUsageError(
15090
- `current group session must be a positive integer for '${command}', got '${sessionID}'`,
15709
+ `current group session must be a positive integer for '${command2}', got '${sessionID}'`,
15091
15710
  "alert"
15092
15711
  );
15093
15712
  }
15094
15713
  return sessionID;
15095
15714
  }
15096
- function requireSingleGroupAlertFeedID(flags, command) {
15715
+ function requireSingleGroupAlertFeedID(flags, command2) {
15097
15716
  if (flags.automation !== void 0) {
15098
15717
  throw new CliUsageError(
15099
- `Group alerts require --automation-ids for '${command}'`,
15718
+ `Group alerts require --automation-ids for '${command2}'`,
15100
15719
  "alert"
15101
15720
  );
15102
15721
  }
15103
15722
  if (flags["channel-id"] !== void 0) {
15104
15723
  throw new CliUsageError(
15105
- `--channel-id selects a personal Alva channel; omit it for '${command}'`,
15724
+ `--channel-id selects an Alva channel; omit it for '${command2}'`,
15106
15725
  "alert"
15107
15726
  );
15108
15727
  }
15109
15728
  const ids = csvList(flags["automation-ids"]) ?? [];
15110
15729
  if (ids.length !== 1 || !/^[1-9]\d*$/.test(ids[0])) {
15111
15730
  throw new CliUsageError(
15112
- `Group alerts require exactly one positive --automation-ids value for '${command}'`,
15731
+ `Group alerts require exactly one positive --automation-ids value for '${command2}'`,
15113
15732
  "alert"
15114
15733
  );
15115
15734
  }
15116
15735
  return ids[0];
15117
15736
  }
15737
+ function deliveryProviderFilter(flags, command2) {
15738
+ if (flags["channel"] !== void 0) {
15739
+ throw new CliUsageError(
15740
+ `--channel is no longer supported for '${command2}'; use --delivery-provider`,
15741
+ command2.split(" ")[0]
15742
+ );
15743
+ }
15744
+ return flags["delivery-provider"];
15745
+ }
15746
+ function projectUserProfileForCLI(record) {
15747
+ const { active_channel: activeIMProvider, ...profile } = record;
15748
+ return { ...profile, active_im_provider: activeIMProvider };
15749
+ }
15750
+ function projectNotificationHistoryForCLI(response) {
15751
+ if (response === null || typeof response !== "object" || Array.isArray(response)) {
15752
+ return response;
15753
+ }
15754
+ const record = response;
15755
+ if (!Array.isArray(record.items)) return response;
15756
+ return {
15757
+ ...record,
15758
+ items: record.items.map((item) => {
15759
+ if (item === null || typeof item !== "object" || Array.isArray(item)) {
15760
+ return item;
15761
+ }
15762
+ const { channel: deliveryProvider, ...event } = item;
15763
+ return { ...event, delivery_provider: deliveryProvider };
15764
+ })
15765
+ };
15766
+ }
15118
15767
  function num(val) {
15119
15768
  if (val === void 0) return void 0;
15120
15769
  const n = Number(val);
@@ -15125,37 +15774,37 @@ function csvList(val) {
15125
15774
  const values = val.split(",").map((item) => item.trim()).filter(Boolean);
15126
15775
  return values.length > 0 ? values : void 0;
15127
15776
  }
15128
- function parseOwnerNameTarget(value, flag, command) {
15777
+ function parseOwnerNameTarget(value, flag, command2) {
15129
15778
  const [username, ...rest] = value.split("/");
15130
15779
  const name = rest.join("/");
15131
15780
  if (!username || !name || name.includes("/")) {
15132
15781
  throw new CliUsageError(
15133
- `--${flag} must be in owner/name form for '${command}', got '${value}'`,
15134
- command.split(" ")[0]
15782
+ `--${flag} must be in owner/name form for '${command2}', got '${value}'`,
15783
+ command2.split(" ")[0]
15135
15784
  );
15136
15785
  }
15137
15786
  return { username, name };
15138
15787
  }
15139
- function rejectPlaybookAlertTarget(flags, command) {
15788
+ function rejectPlaybookAlertTarget(flags, command2) {
15140
15789
  if (flags["playbook"] !== void 0 || flags["playbook-ids"] !== void 0) {
15141
15790
  throw new CliUsageError(
15142
- `Playbook alert targets are unsupported for '${command}'; use --automation or --automation-ids`,
15791
+ `Playbook alert targets are unsupported for '${command2}'; use --automation or --automation-ids`,
15143
15792
  "alert"
15144
15793
  );
15145
15794
  }
15146
15795
  }
15147
- function requireAutomationAlertTarget(flags, command) {
15796
+ function requireAutomationAlertTarget(flags, command2) {
15148
15797
  return parseOwnerNameTarget(
15149
- requireFlag(flags, "automation", command),
15798
+ requireFlag(flags, "automation", command2),
15150
15799
  "automation",
15151
- command
15800
+ command2
15152
15801
  );
15153
15802
  }
15154
- function feedReleaseParams(flags, command) {
15803
+ function feedReleaseParams(flags, command2) {
15155
15804
  return {
15156
- name: requireFlag(flags, "name", command),
15157
- version: requireFlag(flags, "version", command),
15158
- cronjob_id: requireNumericFlag(flags, "cronjob-id", command),
15805
+ name: requireFlag(flags, "name", command2),
15806
+ version: requireFlag(flags, "version", command2),
15807
+ cronjob_id: requireNumericFlag(flags, "cronjob-id", command2),
15159
15808
  view_json: jsonParse(flags["view-json"]),
15160
15809
  description: flags["description"],
15161
15810
  changelog: flags["changelog"],
@@ -15191,7 +15840,7 @@ function feedVisibility(val) {
15191
15840
  "feed"
15192
15841
  );
15193
15842
  }
15194
- function parseCreditsTimestamp(value, flag, command) {
15843
+ function parseCreditsTimestamp(value, flag, command2) {
15195
15844
  const trimmed = value.trim();
15196
15845
  if (/^\d+$/.test(trimmed)) {
15197
15846
  const ms = Number(trimmed);
@@ -15201,8 +15850,8 @@ function parseCreditsTimestamp(value, flag, command) {
15201
15850
  const parsed = Date.parse(normalized);
15202
15851
  if (Number.isNaN(parsed)) {
15203
15852
  throw new CliUsageError(
15204
- `--${flag} must be an ISO time, YYYY-MM-DD, or Unix ms for '${command}', got '${value}'`,
15205
- command.split(" ")[0]
15853
+ `--${flag} must be an ISO time, YYYY-MM-DD, or Unix ms for '${command2}', got '${value}'`,
15854
+ command2.split(" ")[0]
15206
15855
  );
15207
15856
  }
15208
15857
  return parsed;
@@ -15307,7 +15956,7 @@ function loopAutomationDescription(goal) {
15307
15956
  return prefix + Array.from(goal).slice(0, availableGoalRunes).join("");
15308
15957
  }
15309
15958
  function parseCreditsItemsParams(flags) {
15310
- const command = "credits items";
15959
+ const command2 = "credits items";
15311
15960
  const hasToday = boolFlag(flags["today"]) === true;
15312
15961
  const hasLast = flags["last"] !== void 0;
15313
15962
  const hasStart = flags["start"] !== void 0;
@@ -15340,8 +15989,8 @@ function parseCreditsItemsParams(flags) {
15340
15989
  endAtMs = Date.now();
15341
15990
  startAtMs = endAtMs - durationMs;
15342
15991
  } else {
15343
- startAtMs = parseCreditsTimestamp(flags["start"], "start", command);
15344
- endAtMs = parseCreditsTimestamp(flags["end"], "end", command);
15992
+ startAtMs = parseCreditsTimestamp(flags["start"], "start", command2);
15993
+ endAtMs = parseCreditsTimestamp(flags["end"], "end", command2);
15345
15994
  }
15346
15995
  if (endAtMs <= startAtMs) {
15347
15996
  throw new CliUsageError(
@@ -15353,7 +16002,7 @@ function parseCreditsItemsParams(flags) {
15353
16002
  startAtMs,
15354
16003
  endAtMs,
15355
16004
  sessionId: flags["session-id"],
15356
- first: optionalBoundedIntegerFlag(flags, "first", command, 1, 500),
16005
+ first: optionalBoundedIntegerFlag(flags, "first", command2, 1, 500),
15357
16006
  after: flags["after"]
15358
16007
  };
15359
16008
  }
@@ -15365,7 +16014,7 @@ function jsonParse(val) {
15365
16014
  return val;
15366
16015
  }
15367
16016
  }
15368
- function jsonObjectFlag(flags, name, command) {
16017
+ function jsonObjectFlag(flags, name, command2) {
15369
16018
  const raw = flags[name];
15370
16019
  if (raw === void 0) return void 0;
15371
16020
  let parsed;
@@ -15373,68 +16022,68 @@ function jsonObjectFlag(flags, name, command) {
15373
16022
  parsed = JSON.parse(raw);
15374
16023
  } catch {
15375
16024
  throw new CliUsageError(
15376
- `--${name} must be valid JSON for '${command}'`,
15377
- command.split(" ")[0]
16025
+ `--${name} must be valid JSON for '${command2}'`,
16026
+ command2.split(" ")[0]
15378
16027
  );
15379
16028
  }
15380
16029
  if (parsed === null || Array.isArray(parsed) || typeof parsed !== "object") {
15381
16030
  throw new CliUsageError(
15382
- `--${name} must be a JSON object for '${command}'`,
15383
- command.split(" ")[0]
16031
+ `--${name} must be a JSON object for '${command2}'`,
16032
+ command2.split(" ")[0]
15384
16033
  );
15385
16034
  }
15386
16035
  return parsed;
15387
16036
  }
15388
- function jsonRequiredFlag(flags, name, command) {
15389
- const raw = requireFlag(flags, name, command);
16037
+ function jsonRequiredFlag(flags, name, command2) {
16038
+ const raw = requireFlag(flags, name, command2);
15390
16039
  try {
15391
16040
  return JSON.parse(raw);
15392
16041
  } catch {
15393
16042
  throw new CliUsageError(
15394
- `--${name} must be valid JSON for '${command}'`,
15395
- command.split(" ")[0]
16043
+ `--${name} must be valid JSON for '${command2}'`,
16044
+ command2.split(" ")[0]
15396
16045
  );
15397
16046
  }
15398
16047
  }
15399
- function jsonSchemaStringFlag(flags, command, deps) {
16048
+ function jsonSchemaStringFlag(flags, command2, deps) {
15400
16049
  const inlineSchema = flags["params-schema"];
15401
16050
  const schemaFile = flags["params-schema-file"];
15402
16051
  if (inlineSchema !== void 0 && schemaFile !== void 0) {
15403
16052
  throw new CliUsageError(
15404
16053
  "--params-schema and --params-schema-file are mutually exclusive",
15405
- command.split(" ")[0]
16054
+ command2.split(" ")[0]
15406
16055
  );
15407
16056
  }
15408
- const raw = schemaFile !== void 0 ? readLocalTextFile(schemaFile, command, "params-schema-file", deps) : inlineSchema;
16057
+ const raw = schemaFile !== void 0 ? readLocalTextFile(schemaFile, command2, "params-schema-file", deps) : inlineSchema;
15409
16058
  if (raw === void 0) return void 0;
15410
16059
  try {
15411
16060
  JSON.parse(raw);
15412
16061
  } catch {
15413
16062
  const flag = schemaFile !== void 0 ? "params-schema-file" : "params-schema";
15414
16063
  throw new CliUsageError(
15415
- `--${flag} must contain valid JSON for '${command}'`,
15416
- command.split(" ")[0]
16064
+ `--${flag} must contain valid JSON for '${command2}'`,
16065
+ command2.split(" ")[0]
15417
16066
  );
15418
16067
  }
15419
16068
  return raw;
15420
16069
  }
15421
- function localFileUnsupported(command, flag) {
16070
+ function localFileUnsupported(command2, flag) {
15422
16071
  return new CliUsageError(
15423
- `--${flag} reads or writes a local file, which is unavailable in jagent. Use ALFS-native read/write/edit tools first, then pass ALFS paths or inline data to '${command}'.`,
15424
- command.split(" ")[0]
16072
+ `--${flag} reads or writes a local file, which is unavailable in jagent. Use ALFS-native read/write/edit tools first, then pass ALFS paths or inline data to '${command2}'.`,
16073
+ command2.split(" ")[0]
15425
16074
  );
15426
16075
  }
15427
- function assertLocalFileAvailable(command, flag, deps) {
16076
+ function assertLocalFileAvailable(command2, flag, deps) {
15428
16077
  if (deps?.mode === "jagent") {
15429
- throw localFileUnsupported(command, flag);
16078
+ throw localFileUnsupported(command2, flag);
15430
16079
  }
15431
16080
  }
15432
- function readLocalTextFile(path, command, flag, deps) {
15433
- assertLocalFileAvailable(command, flag, deps);
16081
+ function readLocalTextFile(path, command2, flag, deps) {
16082
+ assertLocalFileAvailable(command2, flag, deps);
15434
16083
  return fs2.readFileSync(path, "utf-8");
15435
16084
  }
15436
- function readLocalFileBytes(path, command, flag, deps) {
15437
- assertLocalFileAvailable(command, flag, deps);
16085
+ function readLocalFileBytes(path, command2, flag, deps) {
16086
+ assertLocalFileAvailable(command2, flag, deps);
15438
16087
  return fs2.readFileSync(path);
15439
16088
  }
15440
16089
  function sniffImageMime(bytes) {
@@ -15450,8 +16099,8 @@ function sniffImageMime(bytes) {
15450
16099
  }
15451
16100
  return "image/png";
15452
16101
  }
15453
- function writeLocalFileBytes(path, data, command, flag, deps) {
15454
- assertLocalFileAvailable(command, flag, deps);
16102
+ function writeLocalFileBytes(path, data, command2, flag, deps) {
16103
+ assertLocalFileAvailable(command2, flag, deps);
15455
16104
  fs2.writeFileSync(path, data);
15456
16105
  }
15457
16106
  async function readAllStdin() {
@@ -15526,9 +16175,22 @@ async function dispatch(client, args, meta, deps) {
15526
16175
  if (COMMAND_HELP[group] && (args[1] === "--help" || args[1] === "-h")) {
15527
16176
  return { _help: true, text: COMMAND_HELP[group] };
15528
16177
  }
16178
+ if (group === "broker") {
16179
+ return handleBroker(client, args.slice(1), deps);
16180
+ }
16181
+ const parsedCommand = parseCommand(args);
16182
+ const subcommand = parsedCommand.path[1];
16183
+ const flags = parsedCommand.flags;
16184
+ const positionals = parsedCommand.positionals;
16185
+ if (flags["help"] !== void 0) {
16186
+ const helpText = COMMAND_HELP[group];
16187
+ if (helpText) return { _help: true, text: helpText };
16188
+ }
15529
16189
  if (group === "whoami") {
15530
16190
  const user = await client.user.me();
15531
- const record = user;
16191
+ const record = projectUserProfileForCLI(
16192
+ user
16193
+ );
15532
16194
  const version = meta?.cliVersion ?? CLI_VERSION;
15533
16195
  let arraysJwtStatus;
15534
16196
  try {
@@ -15552,24 +16214,16 @@ async function dispatch(client, args, meta, deps) {
15552
16214
  }
15553
16215
  return result;
15554
16216
  }
15555
- if (group === "broker") {
15556
- return handleBroker(client, args.slice(1), deps);
15557
- }
15558
- const subcommand = args[1];
15559
- const flags = parseFlags2(
15560
- args.slice(
15561
- group === "run" || group === "remix" || group === "screenshot" ? 1 : 2
15562
- )
15563
- );
15564
- if (flags["help"] !== void 0) {
15565
- const helpText = COMMAND_HELP[group];
15566
- if (helpText) return { _help: true, text: helpText };
15567
- }
15568
16217
  switch (group) {
15569
16218
  case "user":
15570
16219
  if (!subcommand)
15571
16220
  throw new CliUsageError("Missing subcommand for user", "user");
15572
- if (subcommand === "me") return client.user.me();
16221
+ if (subcommand === "me") {
16222
+ const user = await client.user.me();
16223
+ return projectUserProfileForCLI(
16224
+ user
16225
+ );
16226
+ }
15573
16227
  throw new CliUsageError(`Unknown subcommand: user ${subcommand}`, "user");
15574
16228
  case "fs": {
15575
16229
  if (!subcommand)
@@ -16090,7 +16744,7 @@ async function dispatch(client, args, meta, deps) {
16090
16744
  );
16091
16745
  switch (subcommand) {
16092
16746
  case "allowance": {
16093
- const leaf = args[2];
16747
+ const leaf = parsedCommand.path[2];
16094
16748
  if (!leaf || leaf === "--help" || leaf === "-h") {
16095
16749
  return { _help: true, text: COMMAND_HELP.functions };
16096
16750
  }
@@ -16267,13 +16921,7 @@ async function dispatch(client, args, meta, deps) {
16267
16921
  "lint"
16268
16922
  );
16269
16923
  }
16270
- const file = args[2];
16271
- if (!file || file.startsWith("--")) {
16272
- throw new CliUsageError(
16273
- "Missing file argument for lint playbook",
16274
- "lint"
16275
- );
16276
- }
16924
+ const file = positionals[0];
16277
16925
  const formatFlag = flags["format"];
16278
16926
  if (formatFlag !== void 0 && formatFlag !== "human" && formatFlag !== "json") {
16279
16927
  throw new CliUsageError(
@@ -16361,31 +17009,13 @@ async function dispatch(client, args, meta, deps) {
16361
17009
  return asJson ? result : formatSkillsList(result);
16362
17010
  }
16363
17011
  case "summary": {
16364
- const name = args[2];
16365
- if (!name || name.startsWith("--")) {
16366
- throw new CliUsageError(
16367
- "Missing skill name for data-skills summary",
16368
- "data-skills"
16369
- );
16370
- }
17012
+ const name = positionals[0];
16371
17013
  const result = await client.dataSkills.summary({ name });
16372
17014
  return asJson ? result : formatSkillSummary(result);
16373
17015
  }
16374
17016
  case "endpoint": {
16375
- const name = args[2];
16376
- if (!name || name.startsWith("--")) {
16377
- throw new CliUsageError(
16378
- "Missing skill name for data-skills endpoint",
16379
- "data-skills"
16380
- );
16381
- }
16382
- const file = args[3];
16383
- if (!file || file.startsWith("--")) {
16384
- throw new CliUsageError(
16385
- "Missing endpoint file for data-skills endpoint",
16386
- "data-skills"
16387
- );
16388
- }
17017
+ const name = positionals[0];
17018
+ const file = positionals[1];
16389
17019
  const result = await client.dataSkills.endpoint({ name, file });
16390
17020
  return asJson ? result : formatSkillEndpoint(result);
16391
17021
  }
@@ -16413,31 +17043,13 @@ async function dispatch(client, args, meta, deps) {
16413
17043
  return asJson ? result : formatPlaybookSkillsTags(result);
16414
17044
  }
16415
17045
  case "get": {
16416
- const id = args[2];
16417
- if (!id || id.startsWith("--")) {
16418
- throw new CliUsageError(
16419
- "Missing playbook skill identifier for skillhub get",
16420
- "skillhub"
16421
- );
16422
- }
17046
+ const id = positionals[0];
16423
17047
  const result = await client.playbookSkills.get(id);
16424
17048
  return asJson ? result : formatPlaybookSkillGet(result);
16425
17049
  }
16426
17050
  case "file": {
16427
- const id = args[2];
16428
- if (!id || id.startsWith("--")) {
16429
- throw new CliUsageError(
16430
- "Missing playbook skill identifier for skillhub file",
16431
- "skillhub"
16432
- );
16433
- }
16434
- const path = args[3];
16435
- if (!path || path.startsWith("--")) {
16436
- throw new CliUsageError(
16437
- "Missing file path for skillhub file",
16438
- "skillhub"
16439
- );
16440
- }
17051
+ const id = positionals[0];
17052
+ const path = positionals[1];
16441
17053
  const result = await client.playbookSkills.file(id, path);
16442
17054
  return asJson ? result : formatPlaybookSkillFile(result);
16443
17055
  }
@@ -16491,15 +17103,20 @@ async function dispatch(client, args, meta, deps) {
16491
17103
  `notification-history ${subcommand}`
16492
17104
  ),
16493
17105
  name: requireFlag(flags, "name", `notification-history ${subcommand}`),
16494
- channel: flags["channel"],
17106
+ channel: deliveryProviderFilter(
17107
+ flags,
17108
+ `notification-history ${subcommand}`
17109
+ ),
16495
17110
  status: flags["status"],
16496
17111
  since_time: num(flags["since"]),
16497
17112
  first: num(flags["first"]),
16498
17113
  cursor: flags["cursor"]
16499
17114
  };
16500
17115
  switch (subcommand) {
16501
- case "list-feed":
16502
- return client.notifications.listFeed(params);
17116
+ case "list-feed": {
17117
+ const response = await client.notifications.listFeed(params);
17118
+ return projectNotificationHistoryForCLI(response);
17119
+ }
16503
17120
  default:
16504
17121
  throw new CliUsageError(
16505
17122
  `Unknown subcommand: notification-history ${subcommand}`,
@@ -16688,8 +17305,14 @@ async function dispatch(client, args, meta, deps) {
16688
17305
  )
16689
17306
  });
16690
17307
  }
17308
+ const target = requireAutomationAlertTarget(flags, "alert enable");
17309
+ const channelId = flags["channel-id"] === void 0 ? void 0 : requirePositiveIntegerStringFlag(
17310
+ flags,
17311
+ "channel-id",
17312
+ "alert enable"
17313
+ );
16691
17314
  return client.alerts.enableAutomation(
16692
- requireAutomationAlertTarget(flags, "alert enable")
17315
+ channelId === void 0 ? target : { ...target, channelId }
16693
17316
  );
16694
17317
  }
16695
17318
  case "disable": {
@@ -16709,18 +17332,18 @@ async function dispatch(client, args, meta, deps) {
16709
17332
  );
16710
17333
  }
16711
17334
  case "group": {
16712
- const leaf = args[2];
17335
+ const leaf = parsedCommand.path[2];
16713
17336
  if (!leaf || leaf === "--help" || leaf === "-h") {
16714
17337
  return { _help: true, text: COMMAND_HELP.alert };
16715
17338
  }
16716
- const command = `alert group ${leaf}`;
17339
+ const command2 = `alert group ${leaf}`;
16717
17340
  if (flags["session-id"] !== void 0) {
16718
17341
  throw new CliUsageError(
16719
- `'${command}' uses the attached group and does not accept --session-id`,
17342
+ `'${command2}' uses the attached group and does not accept --session-id`,
16720
17343
  "alert"
16721
17344
  );
16722
17345
  }
16723
- const sessionID = requireCurrentGroupAlertSessionID(client, command);
17346
+ const sessionID = requireCurrentGroupAlertSessionID(client, command2);
16724
17347
  switch (leaf) {
16725
17348
  case "list": {
16726
17349
  const result = await client.channelGroupSubscriptions.list({
@@ -16732,13 +17355,13 @@ async function dispatch(client, args, meta, deps) {
16732
17355
  return client.channelGroupSubscriptions.subscribe({
16733
17356
  session_id: sessionID,
16734
17357
  target_type: "feed",
16735
- target_id: requireSingleGroupAlertFeedID(flags, command)
17358
+ target_id: requireSingleGroupAlertFeedID(flags, command2)
16736
17359
  });
16737
17360
  case "disable":
16738
17361
  return client.channelGroupSubscriptions.unsubscribe({
16739
17362
  session_id: sessionID,
16740
17363
  target_type: "feed",
16741
- target_id: requireSingleGroupAlertFeedID(flags, command)
17364
+ target_id: requireSingleGroupAlertFeedID(flags, command2)
16742
17365
  });
16743
17366
  default:
16744
17367
  throw new CliUsageError(
@@ -16753,13 +17376,14 @@ async function dispatch(client, args, meta, deps) {
16753
17376
  const params = {
16754
17377
  username: target.username,
16755
17378
  name: target.name,
16756
- channel: flags["channel"],
17379
+ channel: deliveryProviderFilter(flags, "alert history"),
16757
17380
  status: flags["status"],
16758
17381
  since_time: num(flags["since"]),
16759
17382
  first: num(flags["first"]),
16760
17383
  cursor: flags["cursor"]
16761
17384
  };
16762
- return client.alerts.historyAutomation(params);
17385
+ const response = await client.alerts.historyAutomation(params);
17386
+ return projectNotificationHistoryForCLI(response);
16763
17387
  }
16764
17388
  case "preferences":
16765
17389
  return client.alerts.preferences();
@@ -16793,7 +17417,7 @@ async function dispatch(client, args, meta, deps) {
16793
17417
  return { _help: true, text: COMMAND_HELP.arrays };
16794
17418
  }
16795
17419
  if (subcommand === "token") {
16796
- const leaf = args[2];
17420
+ const leaf = parsedCommand.path[2];
16797
17421
  if (!leaf || leaf === "--help" || leaf === "-h") {
16798
17422
  return { _help: true, text: COMMAND_HELP.arrays };
16799
17423
  }
@@ -17033,8 +17657,8 @@ async function dispatch(client, args, meta, deps) {
17033
17657
  }
17034
17658
  }
17035
17659
  case "auth": {
17036
- const authSub = args[1];
17037
- if (!authSub || authSub === "--help" || authSub === "-h" || args[2] === "--help" || args[2] === "-h") {
17660
+ const authSub = parsedCommand.path[1];
17661
+ if (!authSub) {
17038
17662
  return { _help: true, text: COMMAND_HELP.auth };
17039
17663
  }
17040
17664
  throw new CliUsageError(`Unknown auth subcommand: '${authSub}'`, "auth");
@@ -17044,12 +17668,6 @@ async function dispatch(client, args, meta, deps) {
17044
17668
  }
17045
17669
  }
17046
17670
  function stripGlobalFlags(argv) {
17047
- const GLOBAL_FLAGS = [
17048
- "--api-key",
17049
- "--base-url",
17050
- "--profile",
17051
- "--arrays-endpoint"
17052
- ];
17053
17671
  const result = [];
17054
17672
  for (let i = 0; i < argv.length; i++) {
17055
17673
  const a = argv[i];
@@ -17057,11 +17675,15 @@ function stripGlobalFlags(argv) {
17057
17675
  result.push(...argv.slice(i));
17058
17676
  break;
17059
17677
  }
17060
- if (GLOBAL_FLAGS.includes(a)) {
17678
+ if (GLOBAL_VALUE_FLAG_SET.has(a)) {
17679
+ const value = argv[i + 1];
17680
+ if (value === void 0 || value.startsWith("--")) {
17681
+ throw new CliUsageError(`${a} requires a value`);
17682
+ }
17061
17683
  i++;
17062
17684
  continue;
17063
17685
  }
17064
- if (GLOBAL_FLAGS.some((f) => a.startsWith(`${f}=`))) {
17686
+ if (GLOBAL_VALUE_FLAGS.some((flag) => a.startsWith(`${flag}=`))) {
17065
17687
  continue;
17066
17688
  }
17067
17689
  result.push(a);
@@ -17086,14 +17708,15 @@ async function main() {
17086
17708
  return;
17087
17709
  }
17088
17710
  if (rawArgs[0] === "auth") {
17089
- const authSub = rawArgs[1];
17090
- if (!authSub || authSub === "--help" || authSub === "-h" || rawArgs[2] === "--help" || rawArgs[2] === "-h") {
17711
+ const parsedAuth = parseCommand(rawArgs);
17712
+ const authSub = parsedAuth.path[1];
17713
+ if (!authSub || parsedAuth.flags.help !== void 0) {
17091
17714
  process.stdout.write(`${COMMAND_HELP.auth}
17092
17715
  `);
17093
17716
  return;
17094
17717
  }
17095
17718
  if (authSub === "login") {
17096
- const loginFlags = parseFlags2(rawArgs.slice(1));
17719
+ const loginFlags = parsedAuth.flags;
17097
17720
  const mode = selectMode(
17098
17721
  process.env,
17099
17722
  {
@@ -17203,7 +17826,7 @@ export {
17203
17826
  dispatch,
17204
17827
  handleConfigure,
17205
17828
  isVersionOlderThan,
17206
- parseFlags2 as parseFlags,
17829
+ parseFlags,
17207
17830
  stripGlobalFlags
17208
17831
  };
17209
17832
  /*! Bundled license information: