@alva-ai/toolkit 0.23.1 → 0.25.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/README.md +19 -16
- package/dist/browser.global.js +31 -6
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.d.ts +68 -12
- package/dist/cli.js +464 -63
- package/dist/cli.js.map +1 -1
- package/dist/dispatch.d.ts +71 -35
- package/dist/dispatch.js +1456 -390
- package/dist/dispatch.js.map +1 -1
- package/dist/index.cjs +325 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -10
- package/dist/index.d.ts +66 -10
- package/dist/index.js +324 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/dispatch.js
CHANGED
|
@@ -2909,11 +2909,11 @@ function parseSelector(subselects, selector, selectorIndex) {
|
|
|
2909
2909
|
ensureNotTraversal();
|
|
2910
2910
|
tokens.push({ type });
|
|
2911
2911
|
}
|
|
2912
|
-
function addSpecialAttribute(name,
|
|
2912
|
+
function addSpecialAttribute(name, action2) {
|
|
2913
2913
|
tokens.push({
|
|
2914
2914
|
type: SelectorType.Attribute,
|
|
2915
2915
|
name,
|
|
2916
|
-
action,
|
|
2916
|
+
action: action2,
|
|
2917
2917
|
value: getName(1),
|
|
2918
2918
|
namespace: null,
|
|
2919
2919
|
ignoreCase: "quirks"
|
|
@@ -2995,21 +2995,21 @@ function parseSelector(subselects, selector, selectorIndex) {
|
|
|
2995
2995
|
}
|
|
2996
2996
|
}
|
|
2997
2997
|
stripWhitespace(0);
|
|
2998
|
-
let
|
|
2998
|
+
let action2 = AttributeAction.Exists;
|
|
2999
2999
|
const possibleAction = actionTypes.get(selector.charCodeAt(selectorIndex));
|
|
3000
3000
|
if (possibleAction) {
|
|
3001
|
-
|
|
3001
|
+
action2 = possibleAction;
|
|
3002
3002
|
if (selector.charCodeAt(selectorIndex + 1) !== 61) {
|
|
3003
3003
|
throw new Error("Expected `=`");
|
|
3004
3004
|
}
|
|
3005
3005
|
stripWhitespace(2);
|
|
3006
3006
|
} else if (selector.charCodeAt(selectorIndex) === 61) {
|
|
3007
|
-
|
|
3007
|
+
action2 = AttributeAction.Equals;
|
|
3008
3008
|
stripWhitespace(1);
|
|
3009
3009
|
}
|
|
3010
3010
|
let value = "";
|
|
3011
3011
|
let ignoreCase = null;
|
|
3012
|
-
if (
|
|
3012
|
+
if (action2 !== "exists") {
|
|
3013
3013
|
if (isQuote(selector.charCodeAt(selectorIndex))) {
|
|
3014
3014
|
const quote = selector.charCodeAt(selectorIndex);
|
|
3015
3015
|
let sectionEnd = selectorIndex + 1;
|
|
@@ -3045,7 +3045,7 @@ function parseSelector(subselects, selector, selectorIndex) {
|
|
|
3045
3045
|
const attributeSelector = {
|
|
3046
3046
|
type: SelectorType.Attribute,
|
|
3047
3047
|
name,
|
|
3048
|
-
action,
|
|
3048
|
+
action: action2,
|
|
3049
3049
|
value,
|
|
3050
3050
|
namespace,
|
|
3051
3051
|
ignoreCase
|
|
@@ -3210,8 +3210,8 @@ function stringifyToken(token, index, arr) {
|
|
|
3210
3210
|
}
|
|
3211
3211
|
}
|
|
3212
3212
|
}
|
|
3213
|
-
function getActionValue(
|
|
3214
|
-
switch (
|
|
3213
|
+
function getActionValue(action2) {
|
|
3214
|
+
switch (action2) {
|
|
3215
3215
|
case AttributeAction.Equals:
|
|
3216
3216
|
return "";
|
|
3217
3217
|
case AttributeAction.Element:
|
|
@@ -5953,6 +5953,788 @@ var CliUsageError = class extends Error {
|
|
|
5953
5953
|
}
|
|
5954
5954
|
};
|
|
5955
5955
|
|
|
5956
|
+
// src/cli/embeddedCommandDefinitions.ts
|
|
5957
|
+
function embeddedCommand(path, {
|
|
5958
|
+
values = [],
|
|
5959
|
+
booleans = [],
|
|
5960
|
+
positionals = [],
|
|
5961
|
+
optionalPositionals = 0,
|
|
5962
|
+
passthrough = false
|
|
5963
|
+
} = {}) {
|
|
5964
|
+
const flags = {};
|
|
5965
|
+
for (const name of values) flags[name] = "value";
|
|
5966
|
+
for (const name of booleans) {
|
|
5967
|
+
if (flags[name] !== void 0) {
|
|
5968
|
+
throw new Error(
|
|
5969
|
+
`Embedded CLI flag --${name} has conflicting definitions`
|
|
5970
|
+
);
|
|
5971
|
+
}
|
|
5972
|
+
flags[name] = "boolean";
|
|
5973
|
+
}
|
|
5974
|
+
return {
|
|
5975
|
+
path: path.split(" "),
|
|
5976
|
+
flags,
|
|
5977
|
+
positionals: {
|
|
5978
|
+
names: positionals,
|
|
5979
|
+
min: positionals.length - optionalPositionals,
|
|
5980
|
+
max: positionals.length
|
|
5981
|
+
},
|
|
5982
|
+
passthrough
|
|
5983
|
+
};
|
|
5984
|
+
}
|
|
5985
|
+
function route(path, target, options = {}) {
|
|
5986
|
+
return {
|
|
5987
|
+
...embeddedCommand(path, options),
|
|
5988
|
+
targetPath: target.split(" ")
|
|
5989
|
+
};
|
|
5990
|
+
}
|
|
5991
|
+
function action(path, options, actionName) {
|
|
5992
|
+
return { ...embeddedCommand(path, options), action: actionName };
|
|
5993
|
+
}
|
|
5994
|
+
var EMBEDDED_COMMAND_DEFINITIONS = [
|
|
5995
|
+
route("account whoami", "whoami"),
|
|
5996
|
+
route("account credits wallet", "credits wallet"),
|
|
5997
|
+
route("account credits items", "credits items", {
|
|
5998
|
+
values: ["last", "start", "end", "session-id", "first", "after"],
|
|
5999
|
+
booleans: ["today"]
|
|
6000
|
+
}),
|
|
6001
|
+
route("account secrets create", "secrets create", {
|
|
6002
|
+
values: ["name", "value"]
|
|
6003
|
+
}),
|
|
6004
|
+
route("account secrets list", "secrets list"),
|
|
6005
|
+
route("account secrets get", "secrets get", { values: ["name"] }),
|
|
6006
|
+
route("account secrets update", "secrets update", {
|
|
6007
|
+
values: ["name", "value"]
|
|
6008
|
+
}),
|
|
6009
|
+
route("account secrets delete", "secrets delete", { values: ["name"] }),
|
|
6010
|
+
route("account notifications preferences", "notification-preferences list"),
|
|
6011
|
+
action(
|
|
6012
|
+
"account notifications set-preference",
|
|
6013
|
+
{ values: ["session-completed"] },
|
|
6014
|
+
"notification-set-preference"
|
|
6015
|
+
),
|
|
6016
|
+
route("account service-accounts create", "service-account create", {
|
|
6017
|
+
values: ["name"]
|
|
6018
|
+
}),
|
|
6019
|
+
route("account service-accounts list", "service-account list"),
|
|
6020
|
+
route("account service-accounts delete", "service-account delete", {
|
|
6021
|
+
values: ["id"]
|
|
6022
|
+
}),
|
|
6023
|
+
route("account service-accounts grant", "service-account grant", {
|
|
6024
|
+
values: ["id", "path", "permission"]
|
|
6025
|
+
}),
|
|
6026
|
+
route("account service-accounts revoke", "service-account revoke", {
|
|
6027
|
+
values: ["id", "path", "permission"]
|
|
6028
|
+
}),
|
|
6029
|
+
route("fs read", "fs read", { values: ["path", "offset", "size"] }),
|
|
6030
|
+
route("fs write", "fs write", {
|
|
6031
|
+
values: ["path", "data"],
|
|
6032
|
+
booleans: ["mkdir-parents", "append"]
|
|
6033
|
+
}),
|
|
6034
|
+
route("fs stat", "fs stat", { values: ["path"] }),
|
|
6035
|
+
route("fs readdir", "fs readdir", {
|
|
6036
|
+
values: ["path"],
|
|
6037
|
+
booleans: ["recursive"]
|
|
6038
|
+
}),
|
|
6039
|
+
route("fs mkdir", "fs mkdir", { values: ["path"] }),
|
|
6040
|
+
route("fs remove", "fs remove", {
|
|
6041
|
+
values: ["path"],
|
|
6042
|
+
booleans: ["recursive"]
|
|
6043
|
+
}),
|
|
6044
|
+
route("fs rename", "fs rename", { values: ["old-path", "new-path"] }),
|
|
6045
|
+
route("fs copy", "fs copy", { values: ["src-path", "dst-path"] }),
|
|
6046
|
+
route("fs symlink", "fs symlink", { values: ["target-path", "link-path"] }),
|
|
6047
|
+
route("fs readlink", "fs readlink", { values: ["path"] }),
|
|
6048
|
+
route("fs chmod", "fs chmod", { values: ["path", "mode"] }),
|
|
6049
|
+
route("fs grant", "fs grant", {
|
|
6050
|
+
values: ["path", "subject", "permission"]
|
|
6051
|
+
}),
|
|
6052
|
+
route("fs revoke", "fs revoke", {
|
|
6053
|
+
values: ["path", "subject", "permission"]
|
|
6054
|
+
}),
|
|
6055
|
+
route("run", "run", {
|
|
6056
|
+
values: [
|
|
6057
|
+
"code",
|
|
6058
|
+
"entry-path",
|
|
6059
|
+
"working-dir",
|
|
6060
|
+
"args",
|
|
6061
|
+
"max-heap-size-mb",
|
|
6062
|
+
"timeout-ms"
|
|
6063
|
+
]
|
|
6064
|
+
}),
|
|
6065
|
+
route("data-skills list", "data-skills list", { booleans: ["json"] }),
|
|
6066
|
+
route("data-skills summary", "data-skills summary", {
|
|
6067
|
+
booleans: ["json"],
|
|
6068
|
+
positionals: ["skill name"]
|
|
6069
|
+
}),
|
|
6070
|
+
route("data-skills endpoint", "data-skills endpoint", {
|
|
6071
|
+
booleans: ["json"],
|
|
6072
|
+
positionals: ["skill name", "endpoint file"]
|
|
6073
|
+
}),
|
|
6074
|
+
route("skillhub list", "skillhub list", {
|
|
6075
|
+
values: ["tag", "username"],
|
|
6076
|
+
booleans: ["json"]
|
|
6077
|
+
}),
|
|
6078
|
+
route("skillhub tags", "skillhub tags", { booleans: ["json"] }),
|
|
6079
|
+
route("skillhub get", "skillhub get", {
|
|
6080
|
+
booleans: ["json"],
|
|
6081
|
+
positionals: ["playbook skill identifier"]
|
|
6082
|
+
}),
|
|
6083
|
+
route("skillhub file", "skillhub file", {
|
|
6084
|
+
booleans: ["json"],
|
|
6085
|
+
positionals: ["playbook skill identifier", "file path"]
|
|
6086
|
+
}),
|
|
6087
|
+
route("markets narrative", "markets narrative", { values: ["ticker"] }),
|
|
6088
|
+
route("markets earnings", "markets earnings", {
|
|
6089
|
+
values: ["ticker", "event", "fiscal-year", "fiscal-quarter"]
|
|
6090
|
+
}),
|
|
6091
|
+
action(
|
|
6092
|
+
"automation create",
|
|
6093
|
+
{
|
|
6094
|
+
values: [
|
|
6095
|
+
"name",
|
|
6096
|
+
"path",
|
|
6097
|
+
"cron",
|
|
6098
|
+
"version",
|
|
6099
|
+
"args",
|
|
6100
|
+
"view-json",
|
|
6101
|
+
"description",
|
|
6102
|
+
"changelog",
|
|
6103
|
+
"agent-type",
|
|
6104
|
+
"max-heap-size-mb",
|
|
6105
|
+
"execution-timeout-seconds",
|
|
6106
|
+
"run-as-service-account"
|
|
6107
|
+
],
|
|
6108
|
+
booleans: ["push-notify", "skip-auto-trigger"]
|
|
6109
|
+
},
|
|
6110
|
+
"automation-create"
|
|
6111
|
+
),
|
|
6112
|
+
route("automation list", "automation list", {
|
|
6113
|
+
values: ["limit", "cursor", "status"],
|
|
6114
|
+
booleans: ["json"]
|
|
6115
|
+
}),
|
|
6116
|
+
action(
|
|
6117
|
+
"automation inspect",
|
|
6118
|
+
{ values: ["id"], booleans: ["json"] },
|
|
6119
|
+
"automation-inspect"
|
|
6120
|
+
),
|
|
6121
|
+
action(
|
|
6122
|
+
"automation update",
|
|
6123
|
+
{
|
|
6124
|
+
values: [
|
|
6125
|
+
"id",
|
|
6126
|
+
"name",
|
|
6127
|
+
"cron",
|
|
6128
|
+
"version",
|
|
6129
|
+
"args",
|
|
6130
|
+
"description",
|
|
6131
|
+
"changelog",
|
|
6132
|
+
"agent-type",
|
|
6133
|
+
"max-heap-size-mb",
|
|
6134
|
+
"execution-timeout-seconds",
|
|
6135
|
+
"run-as-service-account"
|
|
6136
|
+
],
|
|
6137
|
+
booleans: ["push-notify", "clear-run-as"]
|
|
6138
|
+
},
|
|
6139
|
+
"automation-update"
|
|
6140
|
+
),
|
|
6141
|
+
route("automation delivery get", "automation delivery get", {
|
|
6142
|
+
values: ["id"]
|
|
6143
|
+
}),
|
|
6144
|
+
route("automation delivery update", "automation delivery update", {
|
|
6145
|
+
values: ["id", "alva-channel-ids"],
|
|
6146
|
+
booleans: ["email-enabled"]
|
|
6147
|
+
}),
|
|
6148
|
+
action("automation delete", { values: ["id"] }, "automation-delete"),
|
|
6149
|
+
action("automation pause", { values: ["id"] }, "automation-pause"),
|
|
6150
|
+
action("automation resume", { values: ["id"] }, "automation-resume"),
|
|
6151
|
+
action("automation trigger", { values: ["id"] }, "automation-trigger"),
|
|
6152
|
+
action(
|
|
6153
|
+
"automation set-visibility",
|
|
6154
|
+
{ values: ["id", "visibility"] },
|
|
6155
|
+
"automation-set-visibility"
|
|
6156
|
+
),
|
|
6157
|
+
action(
|
|
6158
|
+
"automation runs list",
|
|
6159
|
+
{ values: ["id", "first", "cursor"] },
|
|
6160
|
+
"automation-runs-list"
|
|
6161
|
+
),
|
|
6162
|
+
action(
|
|
6163
|
+
"automation runs status",
|
|
6164
|
+
{ values: ["id", "workflow-run-id"] },
|
|
6165
|
+
"automation-runs-status"
|
|
6166
|
+
),
|
|
6167
|
+
action(
|
|
6168
|
+
"automation runs logs",
|
|
6169
|
+
{ values: ["id", "run-id"] },
|
|
6170
|
+
"automation-runs-logs"
|
|
6171
|
+
),
|
|
6172
|
+
route("playbooks trending", "playbooks trending", {
|
|
6173
|
+
values: ["keyword", "tags", "tag", "sort", "limit", "cursor", "current"],
|
|
6174
|
+
booleans: ["json"]
|
|
6175
|
+
}),
|
|
6176
|
+
route("playbooks list", "playbooks list", {
|
|
6177
|
+
values: ["owner", "limit", "cursor"],
|
|
6178
|
+
booleans: ["json", "all"]
|
|
6179
|
+
}),
|
|
6180
|
+
route("playbooks mine", "playbooks mine", {
|
|
6181
|
+
values: ["filter", "limit", "cursor"],
|
|
6182
|
+
booleans: ["json", "all"]
|
|
6183
|
+
}),
|
|
6184
|
+
route("playbooks get", "playbooks get", {
|
|
6185
|
+
values: ["ids", "id", "ref"],
|
|
6186
|
+
booleans: ["json"]
|
|
6187
|
+
}),
|
|
6188
|
+
route("playbooks set-visibility", "playbooks set-visibility", {
|
|
6189
|
+
values: ["name", "visibility"]
|
|
6190
|
+
}),
|
|
6191
|
+
route("playbooks draft", "release playbook-draft", {
|
|
6192
|
+
values: [
|
|
6193
|
+
"name",
|
|
6194
|
+
"display-name",
|
|
6195
|
+
"description",
|
|
6196
|
+
"feeds",
|
|
6197
|
+
"trading-symbols",
|
|
6198
|
+
"skill-id",
|
|
6199
|
+
"tags"
|
|
6200
|
+
]
|
|
6201
|
+
}),
|
|
6202
|
+
route("playbooks release", "release playbook", {
|
|
6203
|
+
values: ["name", "version", "feeds", "changelog", "readme-url"],
|
|
6204
|
+
booleans: ["bypass-lint"]
|
|
6205
|
+
}),
|
|
6206
|
+
route("playbooks lint", "lint playbook", {
|
|
6207
|
+
values: ["format"],
|
|
6208
|
+
positionals: ["file argument"]
|
|
6209
|
+
}),
|
|
6210
|
+
action(
|
|
6211
|
+
"playbooks screenshot",
|
|
6212
|
+
{
|
|
6213
|
+
values: [
|
|
6214
|
+
"url",
|
|
6215
|
+
"selector",
|
|
6216
|
+
"xpath",
|
|
6217
|
+
"compress-quality",
|
|
6218
|
+
"compress-max-width"
|
|
6219
|
+
],
|
|
6220
|
+
booleans: ["full", "compress"]
|
|
6221
|
+
},
|
|
6222
|
+
"screenshot"
|
|
6223
|
+
),
|
|
6224
|
+
route("playbooks remix", "remix", {
|
|
6225
|
+
values: ["child-username", "child-name", "parents"]
|
|
6226
|
+
}),
|
|
6227
|
+
route("playbooks comments create", "comments create", {
|
|
6228
|
+
values: ["username", "name", "content", "parent-id"]
|
|
6229
|
+
}),
|
|
6230
|
+
route("playbooks comments pin", "comments pin", { values: ["comment-id"] }),
|
|
6231
|
+
route("playbooks comments unpin", "comments unpin", {
|
|
6232
|
+
values: ["comment-id"]
|
|
6233
|
+
}),
|
|
6234
|
+
route("playbooks follows list", "subscriptions follows", {
|
|
6235
|
+
values: ["limit", "cursor"]
|
|
6236
|
+
}),
|
|
6237
|
+
route("playbooks follows follow", "subscriptions follow-playbook", {
|
|
6238
|
+
values: ["username", "name"]
|
|
6239
|
+
}),
|
|
6240
|
+
route("playbooks follows unfollow", "subscriptions unfollow-playbook", {
|
|
6241
|
+
values: ["username", "name"]
|
|
6242
|
+
}),
|
|
6243
|
+
route("playbooks functions allowance", "functions allowance"),
|
|
6244
|
+
route("playbooks functions allowance get", "functions allowance get", {
|
|
6245
|
+
values: ["playbook-id"]
|
|
6246
|
+
}),
|
|
6247
|
+
route("playbooks functions allowance list", "functions allowance list"),
|
|
6248
|
+
route(
|
|
6249
|
+
"playbooks functions allowance create",
|
|
6250
|
+
"functions allowance create",
|
|
6251
|
+
{ values: ["playbook-id", "amount"] }
|
|
6252
|
+
),
|
|
6253
|
+
route(
|
|
6254
|
+
"playbooks functions allowance revoke",
|
|
6255
|
+
"functions allowance revoke",
|
|
6256
|
+
{ values: ["playbook-id"] }
|
|
6257
|
+
),
|
|
6258
|
+
route("playbooks functions register", "functions register", {
|
|
6259
|
+
values: [
|
|
6260
|
+
"playbook-id",
|
|
6261
|
+
"function-name",
|
|
6262
|
+
"entry-script-path",
|
|
6263
|
+
"params-schema",
|
|
6264
|
+
"run-as-service-account"
|
|
6265
|
+
],
|
|
6266
|
+
booleans: ["allow-charges", "clear-run-as"]
|
|
6267
|
+
}),
|
|
6268
|
+
route("playbooks functions list", "functions list", {
|
|
6269
|
+
values: ["playbook-id"]
|
|
6270
|
+
}),
|
|
6271
|
+
route("playbooks functions delete", "functions delete", {
|
|
6272
|
+
values: ["playbook-id", "function-name"]
|
|
6273
|
+
}),
|
|
6274
|
+
route("playbooks functions invoke", "functions invoke", {
|
|
6275
|
+
values: ["playbook-id", "function-name", "params"]
|
|
6276
|
+
}),
|
|
6277
|
+
route("alert list", "alert list", {
|
|
6278
|
+
values: ["first", "cursor"],
|
|
6279
|
+
booleans: ["json"]
|
|
6280
|
+
}),
|
|
6281
|
+
route("alert enable", "alert enable", {
|
|
6282
|
+
values: ["automation", "automation-ids", "channel-id"]
|
|
6283
|
+
}),
|
|
6284
|
+
route("alert disable", "alert disable", {
|
|
6285
|
+
values: ["automation", "automation-ids"]
|
|
6286
|
+
}),
|
|
6287
|
+
route("alert history", "alert history", {
|
|
6288
|
+
values: [
|
|
6289
|
+
"automation",
|
|
6290
|
+
"delivery-provider",
|
|
6291
|
+
"status",
|
|
6292
|
+
"since",
|
|
6293
|
+
"first",
|
|
6294
|
+
"cursor"
|
|
6295
|
+
]
|
|
6296
|
+
}),
|
|
6297
|
+
route("portfolio accounts", "portfolio accounts"),
|
|
6298
|
+
route("portfolio summary", "portfolio summary", { values: ["account-id"] }),
|
|
6299
|
+
route("portfolio activities", "portfolio activities", {
|
|
6300
|
+
values: ["account-id", "limit", "page-token"]
|
|
6301
|
+
}),
|
|
6302
|
+
route("portfolio orders", "trading orders", {
|
|
6303
|
+
values: ["account-id", "source", "since", "limit"]
|
|
6304
|
+
}),
|
|
6305
|
+
route("portfolio equity-history", "trading equity-history", {
|
|
6306
|
+
values: ["account-id", "timeframe", "since-ms", "until-ms"]
|
|
6307
|
+
}),
|
|
6308
|
+
route("trading accounts", "broker accounts"),
|
|
6309
|
+
route("trading risk-rules", "broker risk-rules"),
|
|
6310
|
+
route("trading signals subscriptions list", "trading subscriptions", {
|
|
6311
|
+
values: ["account-id"]
|
|
6312
|
+
}),
|
|
6313
|
+
route("trading signals subscriptions subscribe", "trading subscribe", {
|
|
6314
|
+
values: [
|
|
6315
|
+
"account-id",
|
|
6316
|
+
"source-username",
|
|
6317
|
+
"source-feed",
|
|
6318
|
+
"playbook-id",
|
|
6319
|
+
"playbook-version"
|
|
6320
|
+
]
|
|
6321
|
+
}),
|
|
6322
|
+
route("trading signals subscriptions unsubscribe", "trading unsubscribe", {
|
|
6323
|
+
values: ["subscription-id"]
|
|
6324
|
+
}),
|
|
6325
|
+
action(
|
|
6326
|
+
"trading signals execute",
|
|
6327
|
+
{
|
|
6328
|
+
values: ["account-id", "signal", "source-username", "source-feed"],
|
|
6329
|
+
booleans: ["live"]
|
|
6330
|
+
},
|
|
6331
|
+
"signal-execute"
|
|
6332
|
+
),
|
|
6333
|
+
route("trading broker", "broker", { passthrough: true })
|
|
6334
|
+
];
|
|
6335
|
+
|
|
6336
|
+
// src/cli/agentCommandDefinitions.ts
|
|
6337
|
+
var EMBEDDED_GLOBAL_FLAG_DEFINITIONS = {
|
|
6338
|
+
help: "boolean"
|
|
6339
|
+
};
|
|
6340
|
+
var embeddedDefinitions = new Map(
|
|
6341
|
+
EMBEDDED_COMMAND_DEFINITIONS.map((definition) => [
|
|
6342
|
+
definition.path.join(" "),
|
|
6343
|
+
definition
|
|
6344
|
+
])
|
|
6345
|
+
);
|
|
6346
|
+
function embeddedCommandDefinition(path) {
|
|
6347
|
+
const definition = embeddedDefinitions.get(path.join(" "));
|
|
6348
|
+
if (definition === void 0) {
|
|
6349
|
+
throw new Error(`Embedded CLI route '${path.join(" ")}' is not registered`);
|
|
6350
|
+
}
|
|
6351
|
+
return definition;
|
|
6352
|
+
}
|
|
6353
|
+
|
|
6354
|
+
// src/cli/agentHelp.ts
|
|
6355
|
+
var AGENT_HELP_TEXT = `Usage: alva <command> [options]
|
|
6356
|
+
|
|
6357
|
+
Slim Alva Agent CLI. Authentication and endpoints are owned by Jagent.
|
|
6358
|
+
|
|
6359
|
+
Commands:
|
|
6360
|
+
account Identity, credits, secrets, notifications, service accounts
|
|
6361
|
+
fs Read and manage ALFS paths
|
|
6362
|
+
run Execute Jagent JavaScript
|
|
6363
|
+
data-skills Discover structured Arrays data endpoints
|
|
6364
|
+
skillhub Discover curated methodology blueprints
|
|
6365
|
+
markets Read market narrative and earnings context
|
|
6366
|
+
automation Create and operate scheduled automations
|
|
6367
|
+
playbooks Discover, build, release, and manage Playbooks
|
|
6368
|
+
alert Manage personal automation alert bindings
|
|
6369
|
+
portfolio Read connected accounts, assets, activity, and history
|
|
6370
|
+
trading Inspect controls and use Signal or Broker execution
|
|
6371
|
+
|
|
6372
|
+
Run 'alva <command> --help' for a command tree.`;
|
|
6373
|
+
var AGENT_COMMAND_HELP = {
|
|
6374
|
+
account: `Usage: alva account <subcommand>
|
|
6375
|
+
|
|
6376
|
+
Subcommands:
|
|
6377
|
+
whoami
|
|
6378
|
+
credits wallet|items
|
|
6379
|
+
secrets create|list|get|update|delete
|
|
6380
|
+
notifications preferences|set-preference
|
|
6381
|
+
service-accounts create|list|delete|grant|revoke`,
|
|
6382
|
+
fs: `Usage: alva fs <subcommand>
|
|
6383
|
+
|
|
6384
|
+
Subcommands:
|
|
6385
|
+
read write stat readdir mkdir remove
|
|
6386
|
+
rename copy symlink readlink chmod grant revoke`,
|
|
6387
|
+
run: `Usage: alva run (--code <js> | --entry-path <alfs-path>) [options]
|
|
6388
|
+
|
|
6389
|
+
Execute JavaScript in the Jagent runtime. Local-file flags are unavailable in
|
|
6390
|
+
the embedded Agent; use ALFS paths or inline code.`,
|
|
6391
|
+
"data-skills": `Usage: alva data-skills <subcommand>
|
|
6392
|
+
|
|
6393
|
+
Subcommands:
|
|
6394
|
+
list
|
|
6395
|
+
summary <skill-name>
|
|
6396
|
+
endpoint <skill-name> <endpoint-file>`,
|
|
6397
|
+
skillhub: `Usage: alva skillhub <subcommand>
|
|
6398
|
+
|
|
6399
|
+
Subcommands:
|
|
6400
|
+
list tags get file`,
|
|
6401
|
+
markets: `Usage: alva markets <subcommand>
|
|
6402
|
+
|
|
6403
|
+
Subcommands:
|
|
6404
|
+
narrative
|
|
6405
|
+
earnings`,
|
|
6406
|
+
automation: `Usage: alva automation <subcommand>
|
|
6407
|
+
|
|
6408
|
+
Subcommands:
|
|
6409
|
+
create Create a producer and register its automation
|
|
6410
|
+
list List product automations
|
|
6411
|
+
inspect Inspect one automation
|
|
6412
|
+
update Update producer and/or product metadata
|
|
6413
|
+
delivery Read or update Alva channel and verified-email destinations
|
|
6414
|
+
delete Delete an automation and its producer
|
|
6415
|
+
pause Pause product delivery and its producer
|
|
6416
|
+
resume Resume product delivery and its producer
|
|
6417
|
+
trigger Trigger the effective producer once
|
|
6418
|
+
set-visibility Set automation visibility
|
|
6419
|
+
runs Run history, status, and logs`,
|
|
6420
|
+
"automation delivery": `Usage: alva automation delivery <subcommand> --id <automation-id>
|
|
6421
|
+
|
|
6422
|
+
Subcommands:
|
|
6423
|
+
get
|
|
6424
|
+
update`,
|
|
6425
|
+
"automation runs": `Usage: alva automation runs <subcommand> --id <automation-id>
|
|
6426
|
+
|
|
6427
|
+
Subcommands:
|
|
6428
|
+
list
|
|
6429
|
+
status
|
|
6430
|
+
logs`,
|
|
6431
|
+
playbooks: `Usage: alva playbooks <subcommand>
|
|
6432
|
+
|
|
6433
|
+
Subcommands:
|
|
6434
|
+
trending list mine get set-visibility
|
|
6435
|
+
draft release lint screenshot remix
|
|
6436
|
+
comments follows functions`,
|
|
6437
|
+
"playbooks comments": `Usage: alva playbooks comments <subcommand>
|
|
6438
|
+
|
|
6439
|
+
Subcommands:
|
|
6440
|
+
create pin unpin`,
|
|
6441
|
+
"playbooks follows": `Usage: alva playbooks follows <subcommand>
|
|
6442
|
+
|
|
6443
|
+
Subcommands:
|
|
6444
|
+
list follow unfollow`,
|
|
6445
|
+
"playbooks functions": `Usage: alva playbooks functions <subcommand>
|
|
6446
|
+
|
|
6447
|
+
Subcommands:
|
|
6448
|
+
register list delete invoke allowance`,
|
|
6449
|
+
"playbooks functions allowance": `Usage: alva playbooks functions allowance <subcommand>
|
|
6450
|
+
|
|
6451
|
+
Subcommands:
|
|
6452
|
+
get list create revoke`,
|
|
6453
|
+
alert: `Usage: alva alert <subcommand>
|
|
6454
|
+
|
|
6455
|
+
Subcommands:
|
|
6456
|
+
list enable disable history`,
|
|
6457
|
+
portfolio: `Usage: alva portfolio <subcommand>
|
|
6458
|
+
|
|
6459
|
+
Subcommands:
|
|
6460
|
+
accounts List TREX and SnapTrade connected accounts
|
|
6461
|
+
summary Read one account's holdings and balances
|
|
6462
|
+
activities Read normalized account activity
|
|
6463
|
+
orders Read detailed TREX order history
|
|
6464
|
+
equity-history Read TREX account equity history`,
|
|
6465
|
+
trading: `Usage: alva trading <subcommand>
|
|
6466
|
+
|
|
6467
|
+
Subcommands:
|
|
6468
|
+
accounts List execution-capable TREX accounts
|
|
6469
|
+
risk-rules Read the admission limits enforced by Broker and Signal
|
|
6470
|
+
signals Legacy Signal subscriptions and execution
|
|
6471
|
+
broker Venue-native reads and order execution`,
|
|
6472
|
+
"trading signals": `Usage: alva trading signals <subcommand>
|
|
6473
|
+
|
|
6474
|
+
Legacy Signal/copy-trading surface. It is separate from Broker.
|
|
6475
|
+
|
|
6476
|
+
Subcommands:
|
|
6477
|
+
subscriptions list|subscribe|unsubscribe
|
|
6478
|
+
execute Interpret one Signal; dry-run unless --live is explicit`,
|
|
6479
|
+
"trading signals subscriptions": `Usage: alva trading signals subscriptions <subcommand>
|
|
6480
|
+
|
|
6481
|
+
Subcommands:
|
|
6482
|
+
list subscribe unsubscribe
|
|
6483
|
+
|
|
6484
|
+
Subscriptions never execute the latest stored Signal implicitly.`,
|
|
6485
|
+
"trading broker": `Usage: alva trading broker <broker-command> [venue flags]
|
|
6486
|
+
|
|
6487
|
+
Subcommands:
|
|
6488
|
+
describe balance positions quote ohlcv funding-rate raw
|
|
6489
|
+
order place|cancel|get|list
|
|
6490
|
+
|
|
6491
|
+
Run 'alva trading broker describe' for the live venue contract.`
|
|
6492
|
+
};
|
|
6493
|
+
var AGENT_LEAF_DEFINITIONS = new Map(
|
|
6494
|
+
EMBEDDED_COMMAND_DEFINITIONS.map((definition) => [
|
|
6495
|
+
definition.path.join(" "),
|
|
6496
|
+
definition
|
|
6497
|
+
])
|
|
6498
|
+
);
|
|
6499
|
+
function formatAgentLeafHelp(definition) {
|
|
6500
|
+
const positionals = definition.positionals.names.map(
|
|
6501
|
+
(name, index) => index < definition.positionals.min ? `<${name}>` : `[<${name}>]`
|
|
6502
|
+
);
|
|
6503
|
+
const usageSuffix = [
|
|
6504
|
+
...positionals,
|
|
6505
|
+
definition.passthrough === true ? "[arguments...]" : "[options]"
|
|
6506
|
+
].join(" ");
|
|
6507
|
+
const options = Object.entries(definition.flags).map(
|
|
6508
|
+
([name, kind]) => kind === "value" ? ` --${name} <value>` : ` --${name} | --no-${name}`
|
|
6509
|
+
);
|
|
6510
|
+
options.push(" --help");
|
|
6511
|
+
return `Usage: alva ${definition.path.join(" ")} ${usageSuffix}
|
|
6512
|
+
|
|
6513
|
+
Options:
|
|
6514
|
+
${options.join("\n")}`;
|
|
6515
|
+
}
|
|
6516
|
+
function agentHelpFor(args) {
|
|
6517
|
+
const helpIndex = args.findIndex(
|
|
6518
|
+
(argument) => argument === "--help" || argument === "-h"
|
|
6519
|
+
);
|
|
6520
|
+
const path = (helpIndex === -1 ? args : args.slice(0, helpIndex)).filter(
|
|
6521
|
+
(argument) => !argument.startsWith("-")
|
|
6522
|
+
);
|
|
6523
|
+
for (let length = path.length; length > 0; length--) {
|
|
6524
|
+
const command2 = path.slice(0, length).join(" ");
|
|
6525
|
+
const help = AGENT_COMMAND_HELP[command2];
|
|
6526
|
+
if (help !== void 0) return help;
|
|
6527
|
+
const definition = AGENT_LEAF_DEFINITIONS.get(command2);
|
|
6528
|
+
if (definition !== void 0) return formatAgentLeafHelp(definition);
|
|
6529
|
+
}
|
|
6530
|
+
return void 0;
|
|
6531
|
+
}
|
|
6532
|
+
|
|
6533
|
+
// src/cli/commandParser.ts
|
|
6534
|
+
function buildCommandTree(definitions) {
|
|
6535
|
+
const root = { children: /* @__PURE__ */ new Map() };
|
|
6536
|
+
for (const definition of definitions) {
|
|
6537
|
+
if (definition.path.length === 0) {
|
|
6538
|
+
throw new Error("CLI command path cannot be empty");
|
|
6539
|
+
}
|
|
6540
|
+
if (definition.positionals.min < 0 || definition.positionals.max < definition.positionals.min || definition.positionals.max !== definition.positionals.names.length) {
|
|
6541
|
+
throw new Error(
|
|
6542
|
+
`Invalid positional definition for '${definition.path.join(" ")}'`
|
|
6543
|
+
);
|
|
6544
|
+
}
|
|
6545
|
+
let node = root;
|
|
6546
|
+
for (const segment of definition.path) {
|
|
6547
|
+
let child = node.children.get(segment);
|
|
6548
|
+
if (child === void 0) {
|
|
6549
|
+
child = { children: /* @__PURE__ */ new Map() };
|
|
6550
|
+
node.children.set(segment, child);
|
|
6551
|
+
}
|
|
6552
|
+
node = child;
|
|
6553
|
+
}
|
|
6554
|
+
if (node.definition !== void 0) {
|
|
6555
|
+
throw new Error(
|
|
6556
|
+
`Duplicate CLI command definition '${definition.path.join(" ")}'`
|
|
6557
|
+
);
|
|
6558
|
+
}
|
|
6559
|
+
node.definition = definition;
|
|
6560
|
+
}
|
|
6561
|
+
return root;
|
|
6562
|
+
}
|
|
6563
|
+
function editDistance(a, b) {
|
|
6564
|
+
let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
|
|
6565
|
+
for (let row = 1; row <= a.length; row++) {
|
|
6566
|
+
const current = [row];
|
|
6567
|
+
for (let column = 1; column <= b.length; column++) {
|
|
6568
|
+
current[column] = Math.min(
|
|
6569
|
+
current[column - 1] + 1,
|
|
6570
|
+
previous[column] + 1,
|
|
6571
|
+
previous[column - 1] + (a[row - 1] === b[column - 1] ? 0 : 1)
|
|
6572
|
+
);
|
|
6573
|
+
}
|
|
6574
|
+
previous = current;
|
|
6575
|
+
}
|
|
6576
|
+
return previous[b.length];
|
|
6577
|
+
}
|
|
6578
|
+
function closestFlag(input, available) {
|
|
6579
|
+
let closest;
|
|
6580
|
+
let distance = Number.POSITIVE_INFINITY;
|
|
6581
|
+
for (const candidate of Object.keys(available)) {
|
|
6582
|
+
const candidateDistance = editDistance(input, candidate);
|
|
6583
|
+
if (candidateDistance < distance) {
|
|
6584
|
+
closest = candidate;
|
|
6585
|
+
distance = candidateDistance;
|
|
6586
|
+
}
|
|
6587
|
+
}
|
|
6588
|
+
const threshold = input.length <= 4 ? 1 : 2;
|
|
6589
|
+
return distance <= threshold ? closest : void 0;
|
|
6590
|
+
}
|
|
6591
|
+
function mergeFlags(definition, globalFlags) {
|
|
6592
|
+
return { ...globalFlags, ...definition.flags };
|
|
6593
|
+
}
|
|
6594
|
+
function resolveCommand(args, tree) {
|
|
6595
|
+
let node = tree;
|
|
6596
|
+
let consumed = 0;
|
|
6597
|
+
while (consumed < args.length) {
|
|
6598
|
+
const input = args[consumed];
|
|
6599
|
+
if (input.startsWith("-")) break;
|
|
6600
|
+
const child = node.children.get(input);
|
|
6601
|
+
if (child !== void 0) {
|
|
6602
|
+
node = child;
|
|
6603
|
+
consumed++;
|
|
6604
|
+
continue;
|
|
6605
|
+
}
|
|
6606
|
+
if (node.definition !== void 0 && node.children.size === 0) break;
|
|
6607
|
+
if (consumed === 0) {
|
|
6608
|
+
throw new CliUsageError(`Unknown command: '${input}'`);
|
|
6609
|
+
}
|
|
6610
|
+
const group2 = args[0];
|
|
6611
|
+
const command2 = args.slice(0, consumed).join(" ");
|
|
6612
|
+
throw new CliUsageError(
|
|
6613
|
+
`Unknown subcommand: ${command2} ${input}. Use 'alva ${group2} --help' for usage.`,
|
|
6614
|
+
group2
|
|
6615
|
+
);
|
|
6616
|
+
}
|
|
6617
|
+
if (node.definition !== void 0) {
|
|
6618
|
+
return { definition: node.definition, consumed };
|
|
6619
|
+
}
|
|
6620
|
+
const group = args[0];
|
|
6621
|
+
if (group === void 0) {
|
|
6622
|
+
throw new CliUsageError("Missing command");
|
|
6623
|
+
}
|
|
6624
|
+
throw new CliUsageError(`Missing subcommand for ${group}`, group);
|
|
6625
|
+
}
|
|
6626
|
+
function unsupportedFlag(name, definition, available) {
|
|
6627
|
+
const command2 = definition.path.join(" ");
|
|
6628
|
+
const suggestion = closestFlag(name, available);
|
|
6629
|
+
const suffix = suggestion === void 0 ? "" : ` Did you mean '--${suggestion}'?`;
|
|
6630
|
+
return new CliUsageError(
|
|
6631
|
+
`--${name} is not supported for '${command2}'.${suffix}`,
|
|
6632
|
+
definition.path[0]
|
|
6633
|
+
);
|
|
6634
|
+
}
|
|
6635
|
+
function parseWithTree(args, tree, globalFlags) {
|
|
6636
|
+
const { definition, consumed } = resolveCommand(args, tree);
|
|
6637
|
+
if (definition.passthrough === true) {
|
|
6638
|
+
return {
|
|
6639
|
+
path: definition.path,
|
|
6640
|
+
flags: {},
|
|
6641
|
+
positionals: [],
|
|
6642
|
+
passthrough: args.slice(consumed)
|
|
6643
|
+
};
|
|
6644
|
+
}
|
|
6645
|
+
const available = mergeFlags(definition, globalFlags);
|
|
6646
|
+
const flags = {};
|
|
6647
|
+
const positionals = [];
|
|
6648
|
+
for (let index = consumed; index < args.length; index++) {
|
|
6649
|
+
const input = args[index];
|
|
6650
|
+
if (input === "-h") {
|
|
6651
|
+
flags.help = "true";
|
|
6652
|
+
continue;
|
|
6653
|
+
}
|
|
6654
|
+
if (!input.startsWith("--")) {
|
|
6655
|
+
positionals.push(input);
|
|
6656
|
+
continue;
|
|
6657
|
+
}
|
|
6658
|
+
const equalsIndex = input.indexOf("=");
|
|
6659
|
+
const externalName = equalsIndex === -1 ? input.slice(2) : input.slice(2, equalsIndex);
|
|
6660
|
+
let name = externalName;
|
|
6661
|
+
let kind = available[name];
|
|
6662
|
+
let negated = false;
|
|
6663
|
+
if (kind === void 0 && name.startsWith("no-") && available[name.slice(3)] === "boolean") {
|
|
6664
|
+
name = name.slice(3);
|
|
6665
|
+
kind = "boolean";
|
|
6666
|
+
negated = true;
|
|
6667
|
+
}
|
|
6668
|
+
if (kind === void 0) {
|
|
6669
|
+
throw unsupportedFlag(externalName, definition, available);
|
|
6670
|
+
}
|
|
6671
|
+
if (equalsIndex !== -1) {
|
|
6672
|
+
const value2 = input.slice(equalsIndex + 1);
|
|
6673
|
+
if (kind === "boolean") {
|
|
6674
|
+
if (value2 !== "true" && value2 !== "false") {
|
|
6675
|
+
throw new CliUsageError(
|
|
6676
|
+
`--${externalName} must be true or false`,
|
|
6677
|
+
definition.path[0]
|
|
6678
|
+
);
|
|
6679
|
+
}
|
|
6680
|
+
flags[name] = negated === true ? value2 === "true" ? "false" : "true" : value2;
|
|
6681
|
+
} else {
|
|
6682
|
+
flags[name] = value2;
|
|
6683
|
+
}
|
|
6684
|
+
continue;
|
|
6685
|
+
}
|
|
6686
|
+
if (kind === "boolean") {
|
|
6687
|
+
flags[name] = negated ? "false" : "true";
|
|
6688
|
+
continue;
|
|
6689
|
+
}
|
|
6690
|
+
const value = args[index + 1];
|
|
6691
|
+
if (value === void 0 || value.startsWith("--")) {
|
|
6692
|
+
throw new CliUsageError(
|
|
6693
|
+
`--${externalName} requires a value`,
|
|
6694
|
+
definition.path[0]
|
|
6695
|
+
);
|
|
6696
|
+
}
|
|
6697
|
+
flags[name] = value;
|
|
6698
|
+
index++;
|
|
6699
|
+
}
|
|
6700
|
+
const command2 = definition.path.join(" ");
|
|
6701
|
+
if (flags.help !== void 0) {
|
|
6702
|
+
return {
|
|
6703
|
+
path: definition.path,
|
|
6704
|
+
flags,
|
|
6705
|
+
positionals
|
|
6706
|
+
};
|
|
6707
|
+
}
|
|
6708
|
+
if (positionals.length < definition.positionals.min) {
|
|
6709
|
+
const missingName = definition.positionals.names[positionals.length] ?? "argument";
|
|
6710
|
+
throw new CliUsageError(
|
|
6711
|
+
`Missing ${missingName} for '${command2}'`,
|
|
6712
|
+
definition.path[0]
|
|
6713
|
+
);
|
|
6714
|
+
}
|
|
6715
|
+
if (positionals.length > definition.positionals.max) {
|
|
6716
|
+
throw new CliUsageError(
|
|
6717
|
+
`Unexpected argument '${positionals[definition.positionals.max]}' for '${command2}'`,
|
|
6718
|
+
definition.path[0]
|
|
6719
|
+
);
|
|
6720
|
+
}
|
|
6721
|
+
return {
|
|
6722
|
+
path: definition.path,
|
|
6723
|
+
flags,
|
|
6724
|
+
positionals
|
|
6725
|
+
};
|
|
6726
|
+
}
|
|
6727
|
+
function createCommandParser(definitions, globalFlags) {
|
|
6728
|
+
const tree = buildCommandTree(definitions);
|
|
6729
|
+
return (args) => parseWithTree(args, tree, globalFlags);
|
|
6730
|
+
}
|
|
6731
|
+
|
|
6732
|
+
// src/cli/embeddedCommandSchema.ts
|
|
6733
|
+
var parseEmbeddedCommand = createCommandParser(
|
|
6734
|
+
EMBEDDED_COMMAND_DEFINITIONS,
|
|
6735
|
+
EMBEDDED_GLOBAL_FLAG_DEFINITIONS
|
|
6736
|
+
);
|
|
6737
|
+
|
|
5956
6738
|
// src/cli/commandDefinitions.ts
|
|
5957
6739
|
function command(path, {
|
|
5958
6740
|
values = [],
|
|
@@ -6129,6 +6911,12 @@ var COMMAND_DEFINITIONS = [
|
|
|
6129
6911
|
],
|
|
6130
6912
|
booleans: ["trigger"]
|
|
6131
6913
|
}),
|
|
6914
|
+
command("automation delivery"),
|
|
6915
|
+
command("automation delivery get", { values: ["id"] }),
|
|
6916
|
+
command("automation delivery update", {
|
|
6917
|
+
values: ["id", "alva-channel-ids"],
|
|
6918
|
+
booleans: ["email-enabled"]
|
|
6919
|
+
}),
|
|
6132
6920
|
command("automation stop", { values: ["id"] }),
|
|
6133
6921
|
command("automation resume", { values: ["id"] }),
|
|
6134
6922
|
command("automation delete", { values: ["id"] }),
|
|
@@ -6362,245 +7150,55 @@ var COMMAND_DEFINITIONS = [
|
|
|
6362
7150
|
command("portfolio accounts"),
|
|
6363
7151
|
command("portfolio summary", { values: ["account-id"] }),
|
|
6364
7152
|
command("portfolio activities", {
|
|
6365
|
-
values: ["account-id", "limit", "page-token"]
|
|
6366
|
-
}),
|
|
6367
|
-
command("markets narrative", { values: ["ticker"] }),
|
|
6368
|
-
command("markets earnings", {
|
|
6369
|
-
values: ["ticker", "event", "fiscal-year", "fiscal-quarter"]
|
|
6370
|
-
}),
|
|
6371
|
-
command("trading accounts"),
|
|
6372
|
-
command("trading portfolio", { values: ["account-id"] }),
|
|
6373
|
-
command("trading orders", {
|
|
6374
|
-
values: ["account-id", "source", "since", "limit"]
|
|
6375
|
-
}),
|
|
6376
|
-
command("trading subscriptions", { values: ["account-id"] }),
|
|
6377
|
-
command("trading equity-history", {
|
|
6378
|
-
values: ["account-id", "timeframe", "since-ms", "until-ms"]
|
|
6379
|
-
}),
|
|
6380
|
-
command("trading risk-rules"),
|
|
6381
|
-
command("trading subscribe", {
|
|
6382
|
-
values: [
|
|
6383
|
-
"account-id",
|
|
6384
|
-
"source-username",
|
|
6385
|
-
"source-feed",
|
|
6386
|
-
"playbook-id",
|
|
6387
|
-
"playbook-version"
|
|
6388
|
-
],
|
|
6389
|
-
booleans: ["execute-latest"]
|
|
6390
|
-
}),
|
|
6391
|
-
command("trading unsubscribe", { values: ["subscription-id"] }),
|
|
6392
|
-
command("trading execute", {
|
|
6393
|
-
values: ["account-id", "signal", "source-username", "source-feed"],
|
|
6394
|
-
booleans: ["dry-run"]
|
|
6395
|
-
}),
|
|
6396
|
-
command("trading update-risk-rules", {
|
|
6397
|
-
values: [
|
|
6398
|
-
"max-single-order-value",
|
|
6399
|
-
"max-single-order-enabled",
|
|
6400
|
-
"max-daily-turnover-value",
|
|
6401
|
-
"max-daily-turnover-enabled",
|
|
6402
|
-
"max-daily-orders-value",
|
|
6403
|
-
"max-daily-orders-enabled"
|
|
6404
|
-
]
|
|
6405
|
-
}),
|
|
6406
|
-
command("broker", { passthrough: true })
|
|
6407
|
-
];
|
|
6408
|
-
|
|
6409
|
-
// src/cli/commandSchema.ts
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
throw new Error("CLI command path cannot be empty");
|
|
6415
|
-
}
|
|
6416
|
-
if (definition.positionals.min < 0 || definition.positionals.max < definition.positionals.min || definition.positionals.max !== definition.positionals.names.length) {
|
|
6417
|
-
throw new Error(
|
|
6418
|
-
`Invalid positional definition for '${definition.path.join(" ")}'`
|
|
6419
|
-
);
|
|
6420
|
-
}
|
|
6421
|
-
let node = root;
|
|
6422
|
-
for (const segment of definition.path) {
|
|
6423
|
-
let child = node.children.get(segment);
|
|
6424
|
-
if (child === void 0) {
|
|
6425
|
-
child = { children: /* @__PURE__ */ new Map() };
|
|
6426
|
-
node.children.set(segment, child);
|
|
6427
|
-
}
|
|
6428
|
-
node = child;
|
|
6429
|
-
}
|
|
6430
|
-
if (node.definition !== void 0) {
|
|
6431
|
-
throw new Error(
|
|
6432
|
-
`Duplicate CLI command definition '${definition.path.join(" ")}'`
|
|
6433
|
-
);
|
|
6434
|
-
}
|
|
6435
|
-
node.definition = definition;
|
|
6436
|
-
}
|
|
6437
|
-
return root;
|
|
6438
|
-
}
|
|
6439
|
-
var COMMAND_TREE = buildCommandTree(COMMAND_DEFINITIONS);
|
|
6440
|
-
function editDistance(a, b) {
|
|
6441
|
-
let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
|
|
6442
|
-
for (let row = 1; row <= a.length; row++) {
|
|
6443
|
-
const current = [row];
|
|
6444
|
-
for (let column = 1; column <= b.length; column++) {
|
|
6445
|
-
current[column] = Math.min(
|
|
6446
|
-
current[column - 1] + 1,
|
|
6447
|
-
previous[column] + 1,
|
|
6448
|
-
previous[column - 1] + (a[row - 1] === b[column - 1] ? 0 : 1)
|
|
6449
|
-
);
|
|
6450
|
-
}
|
|
6451
|
-
previous = current;
|
|
6452
|
-
}
|
|
6453
|
-
return previous[b.length];
|
|
6454
|
-
}
|
|
6455
|
-
function closestFlag(input, available) {
|
|
6456
|
-
let closest;
|
|
6457
|
-
let distance = Number.POSITIVE_INFINITY;
|
|
6458
|
-
for (const candidate of Object.keys(available)) {
|
|
6459
|
-
const candidateDistance = editDistance(input, candidate);
|
|
6460
|
-
if (candidateDistance < distance) {
|
|
6461
|
-
closest = candidate;
|
|
6462
|
-
distance = candidateDistance;
|
|
6463
|
-
}
|
|
6464
|
-
}
|
|
6465
|
-
const threshold = input.length <= 4 ? 1 : 2;
|
|
6466
|
-
return distance <= threshold ? closest : void 0;
|
|
6467
|
-
}
|
|
6468
|
-
function mergeFlags(definition) {
|
|
6469
|
-
return { ...GLOBAL_FLAG_DEFINITIONS, ...definition.flags };
|
|
6470
|
-
}
|
|
6471
|
-
function resolveCommand(args) {
|
|
6472
|
-
let node = COMMAND_TREE;
|
|
6473
|
-
let consumed = 0;
|
|
6474
|
-
while (consumed < args.length) {
|
|
6475
|
-
const input = args[consumed];
|
|
6476
|
-
if (input.startsWith("-")) break;
|
|
6477
|
-
const child = node.children.get(input);
|
|
6478
|
-
if (child !== void 0) {
|
|
6479
|
-
node = child;
|
|
6480
|
-
consumed++;
|
|
6481
|
-
continue;
|
|
6482
|
-
}
|
|
6483
|
-
if (node.definition !== void 0 && node.children.size === 0) break;
|
|
6484
|
-
if (consumed === 0) {
|
|
6485
|
-
throw new CliUsageError(`Unknown command: '${input}'`);
|
|
6486
|
-
}
|
|
6487
|
-
const group2 = args[0];
|
|
6488
|
-
const command2 = args.slice(0, consumed).join(" ");
|
|
6489
|
-
throw new CliUsageError(
|
|
6490
|
-
`Unknown subcommand: ${command2} ${input}. Use 'alva ${group2} --help' for usage.`,
|
|
6491
|
-
group2
|
|
6492
|
-
);
|
|
6493
|
-
}
|
|
6494
|
-
if (node.definition !== void 0) {
|
|
6495
|
-
return { definition: node.definition, consumed };
|
|
6496
|
-
}
|
|
6497
|
-
const group = args[0];
|
|
6498
|
-
if (group === void 0) {
|
|
6499
|
-
throw new CliUsageError("Missing command");
|
|
6500
|
-
}
|
|
6501
|
-
throw new CliUsageError(`Missing subcommand for ${group}`, group);
|
|
6502
|
-
}
|
|
6503
|
-
function unsupportedFlag(name, definition, available) {
|
|
6504
|
-
const command2 = definition.path.join(" ");
|
|
6505
|
-
const suggestion = closestFlag(name, available);
|
|
6506
|
-
const suffix = suggestion === void 0 ? "" : ` Did you mean '--${suggestion}'?`;
|
|
6507
|
-
return new CliUsageError(
|
|
6508
|
-
`--${name} is not supported for '${command2}'.${suffix}`,
|
|
6509
|
-
definition.path[0]
|
|
6510
|
-
);
|
|
6511
|
-
}
|
|
6512
|
-
function parseCommand(args) {
|
|
6513
|
-
const { definition, consumed } = resolveCommand(args);
|
|
6514
|
-
if (definition.passthrough === true) {
|
|
6515
|
-
return {
|
|
6516
|
-
path: definition.path,
|
|
6517
|
-
flags: {},
|
|
6518
|
-
positionals: [],
|
|
6519
|
-
passthrough: args.slice(consumed)
|
|
6520
|
-
};
|
|
6521
|
-
}
|
|
6522
|
-
const available = mergeFlags(definition);
|
|
6523
|
-
const flags = {};
|
|
6524
|
-
const positionals = [];
|
|
6525
|
-
for (let index = consumed; index < args.length; index++) {
|
|
6526
|
-
const input = args[index];
|
|
6527
|
-
if (input === "-h") {
|
|
6528
|
-
flags.help = "true";
|
|
6529
|
-
continue;
|
|
6530
|
-
}
|
|
6531
|
-
if (!input.startsWith("--")) {
|
|
6532
|
-
positionals.push(input);
|
|
6533
|
-
continue;
|
|
6534
|
-
}
|
|
6535
|
-
const equalsIndex = input.indexOf("=");
|
|
6536
|
-
const externalName = equalsIndex === -1 ? input.slice(2) : input.slice(2, equalsIndex);
|
|
6537
|
-
let name = externalName;
|
|
6538
|
-
let kind = available[name];
|
|
6539
|
-
let negated = false;
|
|
6540
|
-
if (kind === void 0 && name.startsWith("no-") && available[name.slice(3)] === "boolean") {
|
|
6541
|
-
name = name.slice(3);
|
|
6542
|
-
kind = "boolean";
|
|
6543
|
-
negated = true;
|
|
6544
|
-
}
|
|
6545
|
-
if (kind === void 0) {
|
|
6546
|
-
throw unsupportedFlag(externalName, definition, available);
|
|
6547
|
-
}
|
|
6548
|
-
if (equalsIndex !== -1) {
|
|
6549
|
-
const value2 = input.slice(equalsIndex + 1);
|
|
6550
|
-
if (kind === "boolean") {
|
|
6551
|
-
if (value2 !== "true" && value2 !== "false") {
|
|
6552
|
-
throw new CliUsageError(
|
|
6553
|
-
`--${externalName} must be true or false`,
|
|
6554
|
-
definition.path[0]
|
|
6555
|
-
);
|
|
6556
|
-
}
|
|
6557
|
-
flags[name] = negated === true ? value2 === "true" ? "false" : "true" : value2;
|
|
6558
|
-
} else {
|
|
6559
|
-
flags[name] = value2;
|
|
6560
|
-
}
|
|
6561
|
-
continue;
|
|
6562
|
-
}
|
|
6563
|
-
if (kind === "boolean") {
|
|
6564
|
-
flags[name] = negated ? "false" : "true";
|
|
6565
|
-
continue;
|
|
6566
|
-
}
|
|
6567
|
-
const value = args[index + 1];
|
|
6568
|
-
if (value === void 0 || value.startsWith("--")) {
|
|
6569
|
-
throw new CliUsageError(
|
|
6570
|
-
`--${externalName} requires a value`,
|
|
6571
|
-
definition.path[0]
|
|
6572
|
-
);
|
|
6573
|
-
}
|
|
6574
|
-
flags[name] = value;
|
|
6575
|
-
index++;
|
|
6576
|
-
}
|
|
6577
|
-
const command2 = definition.path.join(" ");
|
|
6578
|
-
if (flags.help !== void 0) {
|
|
6579
|
-
return {
|
|
6580
|
-
path: definition.path,
|
|
6581
|
-
flags,
|
|
6582
|
-
positionals
|
|
6583
|
-
};
|
|
6584
|
-
}
|
|
6585
|
-
if (positionals.length < definition.positionals.min) {
|
|
6586
|
-
const missingName = definition.positionals.names[positionals.length] ?? "argument";
|
|
6587
|
-
throw new CliUsageError(
|
|
6588
|
-
`Missing ${missingName} for '${command2}'`,
|
|
6589
|
-
definition.path[0]
|
|
6590
|
-
);
|
|
6591
|
-
}
|
|
6592
|
-
if (positionals.length > definition.positionals.max) {
|
|
6593
|
-
throw new CliUsageError(
|
|
6594
|
-
`Unexpected argument '${positionals[definition.positionals.max]}' for '${command2}'`,
|
|
6595
|
-
definition.path[0]
|
|
6596
|
-
);
|
|
6597
|
-
}
|
|
6598
|
-
return {
|
|
6599
|
-
path: definition.path,
|
|
6600
|
-
flags,
|
|
6601
|
-
positionals
|
|
6602
|
-
};
|
|
6603
|
-
}
|
|
7153
|
+
values: ["account-id", "limit", "page-token"]
|
|
7154
|
+
}),
|
|
7155
|
+
command("markets narrative", { values: ["ticker"] }),
|
|
7156
|
+
command("markets earnings", {
|
|
7157
|
+
values: ["ticker", "event", "fiscal-year", "fiscal-quarter"]
|
|
7158
|
+
}),
|
|
7159
|
+
command("trading accounts"),
|
|
7160
|
+
command("trading portfolio", { values: ["account-id"] }),
|
|
7161
|
+
command("trading orders", {
|
|
7162
|
+
values: ["account-id", "source", "since", "limit"]
|
|
7163
|
+
}),
|
|
7164
|
+
command("trading subscriptions", { values: ["account-id"] }),
|
|
7165
|
+
command("trading equity-history", {
|
|
7166
|
+
values: ["account-id", "timeframe", "since-ms", "until-ms"]
|
|
7167
|
+
}),
|
|
7168
|
+
command("trading risk-rules"),
|
|
7169
|
+
command("trading subscribe", {
|
|
7170
|
+
values: [
|
|
7171
|
+
"account-id",
|
|
7172
|
+
"source-username",
|
|
7173
|
+
"source-feed",
|
|
7174
|
+
"playbook-id",
|
|
7175
|
+
"playbook-version"
|
|
7176
|
+
],
|
|
7177
|
+
booleans: ["execute-latest"]
|
|
7178
|
+
}),
|
|
7179
|
+
command("trading unsubscribe", { values: ["subscription-id"] }),
|
|
7180
|
+
command("trading execute", {
|
|
7181
|
+
values: ["account-id", "signal", "source-username", "source-feed"],
|
|
7182
|
+
booleans: ["dry-run"]
|
|
7183
|
+
}),
|
|
7184
|
+
command("trading update-risk-rules", {
|
|
7185
|
+
values: [
|
|
7186
|
+
"max-single-order-value",
|
|
7187
|
+
"max-single-order-enabled",
|
|
7188
|
+
"max-daily-turnover-value",
|
|
7189
|
+
"max-daily-turnover-enabled",
|
|
7190
|
+
"max-daily-orders-value",
|
|
7191
|
+
"max-daily-orders-enabled"
|
|
7192
|
+
]
|
|
7193
|
+
}),
|
|
7194
|
+
command("broker", { passthrough: true })
|
|
7195
|
+
];
|
|
7196
|
+
|
|
7197
|
+
// src/cli/commandSchema.ts
|
|
7198
|
+
var parseCommand = createCommandParser(
|
|
7199
|
+
COMMAND_DEFINITIONS,
|
|
7200
|
+
GLOBAL_FLAG_DEFINITIONS
|
|
7201
|
+
);
|
|
6604
7202
|
|
|
6605
7203
|
// src/cli/dataSkillsFormat.ts
|
|
6606
7204
|
function formatSkillsList(payload) {
|
|
@@ -10267,8 +10865,72 @@ ${formatReport(report, "human")}
|
|
|
10267
10865
|
return report;
|
|
10268
10866
|
}
|
|
10269
10867
|
|
|
10868
|
+
// src/jsonPayload.ts
|
|
10869
|
+
var MAX_SAFE_INTEGER_DIGITS = "9007199254740991";
|
|
10870
|
+
function scaledIntegerGreater(left, leftTrailingZeros, right, rightTrailingZeros) {
|
|
10871
|
+
const leftLength = left.length + leftTrailingZeros;
|
|
10872
|
+
const rightLength = right.length + rightTrailingZeros;
|
|
10873
|
+
if (leftLength !== rightLength) return leftLength > rightLength;
|
|
10874
|
+
for (let index = 0; index < leftLength; index++) {
|
|
10875
|
+
const leftDigit = index < left.length ? left[index] : "0";
|
|
10876
|
+
const rightDigit = index < right.length ? right[index] : "0";
|
|
10877
|
+
if (leftDigit !== rightDigit) return leftDigit > rightDigit;
|
|
10878
|
+
}
|
|
10879
|
+
return false;
|
|
10880
|
+
}
|
|
10881
|
+
function numberOutsideSafeRange(token) {
|
|
10882
|
+
const match = token.match(
|
|
10883
|
+
/^-?(?<whole>\d+)(?:\.(?<fraction>\d+))?(?:[eE](?<exponent>[+-]?\d+))?$/
|
|
10884
|
+
);
|
|
10885
|
+
if (!match?.groups) return true;
|
|
10886
|
+
const whole = match.groups.whole;
|
|
10887
|
+
const fraction = match.groups.fraction ?? "";
|
|
10888
|
+
const exponent = Number(match.groups.exponent ?? "0");
|
|
10889
|
+
if (!Number.isSafeInteger(exponent)) return true;
|
|
10890
|
+
const digits = (whole + fraction).replace(/^0+/, "") || "0";
|
|
10891
|
+
if (digits === "0") return false;
|
|
10892
|
+
const scale = exponent - fraction.length;
|
|
10893
|
+
return scale >= 0 ? scaledIntegerGreater(digits, scale, MAX_SAFE_INTEGER_DIGITS, 0) : scaledIntegerGreater(digits, 0, MAX_SAFE_INTEGER_DIGITS, -scale);
|
|
10894
|
+
}
|
|
10895
|
+
function validateJSONNumberTokens(raw) {
|
|
10896
|
+
let index = 0;
|
|
10897
|
+
while (index < raw.length) {
|
|
10898
|
+
if (raw[index] === '"') {
|
|
10899
|
+
index++;
|
|
10900
|
+
while (index < raw.length) {
|
|
10901
|
+
if (raw[index] === "\\") {
|
|
10902
|
+
index += 2;
|
|
10903
|
+
} else if (raw[index++] === '"') {
|
|
10904
|
+
break;
|
|
10905
|
+
}
|
|
10906
|
+
}
|
|
10907
|
+
continue;
|
|
10908
|
+
}
|
|
10909
|
+
if (raw[index] === "-" || /\d/.test(raw[index] ?? "")) {
|
|
10910
|
+
const match = raw.slice(index).match(/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/);
|
|
10911
|
+
if (match) {
|
|
10912
|
+
if (numberOutsideSafeRange(match[0])) {
|
|
10913
|
+
throw new TypeError(
|
|
10914
|
+
"args contains a number outside JavaScript's safe range; use a string for int64 and identifier values"
|
|
10915
|
+
);
|
|
10916
|
+
}
|
|
10917
|
+
index += match[0].length;
|
|
10918
|
+
continue;
|
|
10919
|
+
}
|
|
10920
|
+
}
|
|
10921
|
+
index++;
|
|
10922
|
+
}
|
|
10923
|
+
}
|
|
10924
|
+
function validateSerializedArgs(raw) {
|
|
10925
|
+
const value = JSON.parse(raw);
|
|
10926
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
10927
|
+
throw new TypeError("args must be a JSON object");
|
|
10928
|
+
}
|
|
10929
|
+
validateJSONNumberTokens(raw);
|
|
10930
|
+
}
|
|
10931
|
+
|
|
10270
10932
|
// src/cli/dispatch.ts
|
|
10271
|
-
var CLI_VERSION = true ? "0.
|
|
10933
|
+
var CLI_VERSION = true ? "0.25.0" : "dev";
|
|
10272
10934
|
var DEFAULT_RUN_TIMEOUT_MS = 6e5;
|
|
10273
10935
|
var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
|
|
10274
10936
|
var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
|
|
@@ -10301,58 +10963,6 @@ function isVersionOlderThan(a, b) {
|
|
|
10301
10963
|
}
|
|
10302
10964
|
return false;
|
|
10303
10965
|
}
|
|
10304
|
-
var HELP_TEXT = `Usage: alva <command> [options]
|
|
10305
|
-
|
|
10306
|
-
Commands:
|
|
10307
|
-
configure Save API key and endpoint to a named profile
|
|
10308
|
-
whoami Verify credentials and show current identity
|
|
10309
|
-
user User profile operations (me)
|
|
10310
|
-
fs Filesystem operations (read, write, stat, readdir, mkdir, remove, rename, copy, symlink, readlink, chmod, grant, revoke)
|
|
10311
|
-
run Execute code in the Alva runtime
|
|
10312
|
-
deploy Cronjob management (create, list, get, update, delete, pause, resume, runs, run-logs)
|
|
10313
|
-
loop Self-scheduled in-channel goal loops (create)
|
|
10314
|
-
service-account Restricted run-as identities (create, list, delete, grant, revoke)
|
|
10315
|
-
release Feed and playbook releases (feed, playbook-draft, playbook)
|
|
10316
|
-
lint Design-system lint (playbook)
|
|
10317
|
-
automation Automation management (list, inspect, publish, update, stop, resume, delete)
|
|
10318
|
-
alert Alert management (list, follows, enable, disable, history, preferences, enable-session-completed, disable-session-completed)
|
|
10319
|
-
feed Legacy automation alias (list, stop, resume, delete, set-visibility)
|
|
10320
|
-
playbooks Playbook discovery (trending, get, list) and visibility
|
|
10321
|
-
functions Playbook UDF function management (register, list, delete, invoke, allowance)
|
|
10322
|
-
credits Credit wallet and self-scoped usage history (wallet, items)
|
|
10323
|
-
secrets Secret management (create, list, get, update, delete)
|
|
10324
|
-
sdk SDK documentation (doc, partitions, partition-summary)
|
|
10325
|
-
skillhub Playbook skills (list, tags, get, file)
|
|
10326
|
-
data-skills Data-skill documentation from the Arrays backend (list, summary, endpoint)
|
|
10327
|
-
comments Playbook comments (create, pin, unpin)
|
|
10328
|
-
notification-history Feed notification delivery history (list-feed)
|
|
10329
|
-
notification-preferences Notification preferences (list, enable-session-completed, disable-session-completed)
|
|
10330
|
-
feedback Submit user-confirmed Alva platform feedback (submit)
|
|
10331
|
-
subscriptions Playbook follows and feed alert subscriptions
|
|
10332
|
-
remix Save playbook remix lineage
|
|
10333
|
-
portfolio Connected-account portfolio (accounts, summary, activities)
|
|
10334
|
-
markets Company narrative and earnings context (narrative, earnings)
|
|
10335
|
-
trading Trading operations (accounts, portfolio, orders, subscriptions, equity-history, risk-rules, subscribe, unsubscribe, execute, update-risk-rules)
|
|
10336
|
-
broker Agentic order execution \u2014 venue-native passthrough to trex (accounts, quote, order, balance, positions, ...; run 'alva broker describe')
|
|
10337
|
-
auth Authentication (login)
|
|
10338
|
-
screenshot Capture a web screenshot as PNG
|
|
10339
|
-
arrays Arrays backend operations (token ensure, token status)
|
|
10340
|
-
|
|
10341
|
-
Global options:
|
|
10342
|
-
--api-key <key> API key (overrides env and config file)
|
|
10343
|
-
--base-url <url> API base URL (overrides env and config file)
|
|
10344
|
-
--profile <name> Named profile to use (default: "default")
|
|
10345
|
-
--arrays-endpoint <url> Arrays backend URL (or ARRAYS_ENDPOINT env; default: https://data-tools.prd.space.id)
|
|
10346
|
-
-v, --version Show CLI version
|
|
10347
|
-
--help Show help (use 'alva <command> --help' for command details)
|
|
10348
|
-
|
|
10349
|
-
Config resolution: --api-key flag > ALVA_API_KEY env > profile in ~/.config/alva/config.json
|
|
10350
|
-
Profile resolution: --profile flag > ALVA_PROFILE env > "default"
|
|
10351
|
-
|
|
10352
|
-
Quick start:
|
|
10353
|
-
npm install -g @alva-ai/toolkit
|
|
10354
|
-
alva configure --api-key alva_your_key_here
|
|
10355
|
-
alva whoami`;
|
|
10356
10966
|
var COMMAND_HELP = {
|
|
10357
10967
|
configure: `Usage: alva configure --api-key <key> [--base-url <url>] [--profile <name>]
|
|
10358
10968
|
|
|
@@ -10742,6 +11352,7 @@ Subcommands:
|
|
|
10742
11352
|
inspect Inspect one automation and show its flow config path when available
|
|
10743
11353
|
publish First-publish/register a new automation after deploying its cronjob
|
|
10744
11354
|
update Partially update an existing automation by numeric id
|
|
11355
|
+
delivery Get or partially update per-automation alert destinations
|
|
10745
11356
|
stop Stop an automation's producer cronjob
|
|
10746
11357
|
resume Resume a stopped automation's producer cronjob
|
|
10747
11358
|
delete Soft-delete an automation
|
|
@@ -10777,6 +11388,16 @@ Update flags:
|
|
|
10777
11388
|
--agent-type <type> Replace agent kind; explicit empty clears it
|
|
10778
11389
|
--trigger Trigger one run after the update commits
|
|
10779
11390
|
|
|
11391
|
+
Delivery subcommands:
|
|
11392
|
+
delivery get Read Alva channel and verified-email destinations
|
|
11393
|
+
delivery update Update only the destination fields explicitly provided
|
|
11394
|
+
|
|
11395
|
+
Delivery flags:
|
|
11396
|
+
--id <automation_id> Existing automation id (required)
|
|
11397
|
+
--alva-channel-ids <a,b> Replace Alva destinations; empty clears them
|
|
11398
|
+
--email-enabled Enable verified-account email delivery
|
|
11399
|
+
--no-email-enabled Disable email delivery
|
|
11400
|
+
|
|
10780
11401
|
Lifecycle flags:
|
|
10781
11402
|
--id <automation_id> Numeric automation id (required for inspect/update/stop/resume/delete)
|
|
10782
11403
|
|
|
@@ -10787,6 +11408,10 @@ Examples:
|
|
|
10787
11408
|
alva automation publish --name btc-ema --version 1.0.0 --cronjob-id 42
|
|
10788
11409
|
alva automation update --id 42 --description "Updated BTC EMA"
|
|
10789
11410
|
alva automation update --id 42 --version 2.0.0 --trigger
|
|
11411
|
+
alva automation delivery get --id 42
|
|
11412
|
+
alva automation delivery update --id 42 --email-enabled
|
|
11413
|
+
alva automation delivery update --id 42 --no-email-enabled
|
|
11414
|
+
alva automation delivery update --id 42 --alva-channel-ids 0,123
|
|
10790
11415
|
alva automation stop --id 42
|
|
10791
11416
|
alva automation resume --id 42
|
|
10792
11417
|
alva automation delete --id 42`,
|
|
@@ -11537,39 +12162,23 @@ Examples:
|
|
|
11537
12162
|
alva arrays token ensure
|
|
11538
12163
|
alva arrays token status`
|
|
11539
12164
|
};
|
|
11540
|
-
function parseFlags(argv) {
|
|
11541
|
-
const flags = {};
|
|
11542
|
-
for (let index = 0; index < argv.length; index++) {
|
|
11543
|
-
const argument = argv[index];
|
|
11544
|
-
if (!argument.startsWith("--")) continue;
|
|
11545
|
-
const equalsIndex = argument.indexOf("=");
|
|
11546
|
-
if (equalsIndex !== -1) {
|
|
11547
|
-
flags[argument.slice(2, equalsIndex)] = argument.slice(equalsIndex + 1);
|
|
11548
|
-
continue;
|
|
11549
|
-
}
|
|
11550
|
-
const name = argument.slice(2);
|
|
11551
|
-
if (BOOLEAN_FLAGS.has(name)) {
|
|
11552
|
-
flags[name] = "true";
|
|
11553
|
-
continue;
|
|
11554
|
-
}
|
|
11555
|
-
if (name.startsWith("no-") && BOOLEAN_FLAGS.has(name.slice(3))) {
|
|
11556
|
-
flags[name.slice(3)] = "false";
|
|
11557
|
-
continue;
|
|
11558
|
-
}
|
|
11559
|
-
const value = argv[index + 1];
|
|
11560
|
-
if (value === void 0 || value.startsWith("--")) {
|
|
11561
|
-
throw new CliUsageError(`--${name} requires a value`, name);
|
|
11562
|
-
}
|
|
11563
|
-
flags[name] = value;
|
|
11564
|
-
index++;
|
|
11565
|
-
}
|
|
11566
|
-
return flags;
|
|
11567
|
-
}
|
|
11568
12165
|
function boolFlag(val) {
|
|
11569
12166
|
if (val === "true") return true;
|
|
11570
12167
|
if (val === "false") return false;
|
|
11571
12168
|
return void 0;
|
|
11572
12169
|
}
|
|
12170
|
+
function serializedJSONFlag(value, command2) {
|
|
12171
|
+
if (value === void 0) return void 0;
|
|
12172
|
+
try {
|
|
12173
|
+
validateSerializedArgs(value);
|
|
12174
|
+
} catch (error) {
|
|
12175
|
+
throw new CliUsageError(
|
|
12176
|
+
`--args must contain valid JSON for '${command2}': ${error instanceof Error ? error.message : String(error)}`,
|
|
12177
|
+
command2.split(" ")[0]
|
|
12178
|
+
);
|
|
12179
|
+
}
|
|
12180
|
+
return value;
|
|
12181
|
+
}
|
|
11573
12182
|
function requireFlag(flags, name, command2) {
|
|
11574
12183
|
const val = flags[name];
|
|
11575
12184
|
if (val === void 0) {
|
|
@@ -11693,7 +12302,7 @@ function runTimeoutMs(flags, deps) {
|
|
|
11693
12302
|
return DEFAULT_RUN_TIMEOUT_MS;
|
|
11694
12303
|
}
|
|
11695
12304
|
function configureRunFetchTimeout(timeoutMs, deps) {
|
|
11696
|
-
if (deps?.
|
|
12305
|
+
if (deps?.runtime === "jagent") return;
|
|
11697
12306
|
deps?.configureFetchTimeout?.(timeoutMs);
|
|
11698
12307
|
}
|
|
11699
12308
|
function requireCurrentGroupAlertSessionID(client, command2) {
|
|
@@ -11845,6 +12454,23 @@ function automationUpdateParams(flags) {
|
|
|
11845
12454
|
}
|
|
11846
12455
|
return params;
|
|
11847
12456
|
}
|
|
12457
|
+
function automationDeliveryUpdateParams(flags) {
|
|
12458
|
+
const command2 = "automation delivery update";
|
|
12459
|
+
const id = requirePositiveIntegerStringFlag(flags, "id", command2);
|
|
12460
|
+
const alvaChannelIds = flags["alva-channel-ids"] === void 0 ? void 0 : csvList(flags["alva-channel-ids"]) ?? [];
|
|
12461
|
+
const emailEnabled = boolFlag(flags["email-enabled"]);
|
|
12462
|
+
if (alvaChannelIds === void 0 && emailEnabled === void 0) {
|
|
12463
|
+
throw new CliUsageError(
|
|
12464
|
+
"automation delivery update requires --alva-channel-ids or --email-enabled/--no-email-enabled",
|
|
12465
|
+
"automation"
|
|
12466
|
+
);
|
|
12467
|
+
}
|
|
12468
|
+
return {
|
|
12469
|
+
id,
|
|
12470
|
+
alvaChannelIds,
|
|
12471
|
+
emailEnabled
|
|
12472
|
+
};
|
|
12473
|
+
}
|
|
11848
12474
|
function trendingPlaybooksSort(val) {
|
|
11849
12475
|
if (val === void 0) return void 0;
|
|
11850
12476
|
const normalized = val.trim().toUpperCase();
|
|
@@ -12119,7 +12745,7 @@ function localFileUnsupported(command2, flag) {
|
|
|
12119
12745
|
);
|
|
12120
12746
|
}
|
|
12121
12747
|
function assertLocalFileAvailable(command2, flag, deps) {
|
|
12122
|
-
if (deps?.
|
|
12748
|
+
if (deps?.runtime === "jagent") {
|
|
12123
12749
|
throw localFileUnsupported(command2, flag);
|
|
12124
12750
|
}
|
|
12125
12751
|
}
|
|
@@ -12188,7 +12814,7 @@ function brokerStdinNeedsIntentId(stdin) {
|
|
|
12188
12814
|
return input.dryRun === false;
|
|
12189
12815
|
}
|
|
12190
12816
|
async function handleBroker(client, brokerArgv, deps) {
|
|
12191
|
-
let argv = brokerArgv;
|
|
12817
|
+
let argv = [...brokerArgv];
|
|
12192
12818
|
const isOrderPlace = brokerArgv[0] === "order" && brokerArgv[1] === "place";
|
|
12193
12819
|
const hasFlag = (name) => brokerArgv.some((a) => a === name || a.startsWith(`${name}=`));
|
|
12194
12820
|
const hasHandle = hasFlag("--intent-id") || hasFlag("--client-order-id");
|
|
@@ -12206,7 +12832,8 @@ async function handleBroker(client, brokerArgv, deps) {
|
|
|
12206
12832
|
throw new Error("Broker live orders require a runtime UUID provider.");
|
|
12207
12833
|
}
|
|
12208
12834
|
const intentId = randomUUID();
|
|
12209
|
-
deps?.
|
|
12835
|
+
const brokerLabel = deps?.runtime === "jagent" ? "alva trading broker" : "alva broker";
|
|
12836
|
+
deps?.stderr?.write(`${brokerLabel}: intent-id ${intentId}
|
|
12210
12837
|
`);
|
|
12211
12838
|
argv = [...brokerArgv, "--intent-id", intentId];
|
|
12212
12839
|
}
|
|
@@ -12227,7 +12854,7 @@ async function handleBroker(client, brokerArgv, deps) {
|
|
|
12227
12854
|
};
|
|
12228
12855
|
exit = 2;
|
|
12229
12856
|
}
|
|
12230
|
-
if (deps?.
|
|
12857
|
+
if (deps?.runtime === "jagent") {
|
|
12231
12858
|
return envelope;
|
|
12232
12859
|
}
|
|
12233
12860
|
if (!deps?.writeBrokerResult) {
|
|
@@ -12236,28 +12863,11 @@ async function handleBroker(client, brokerArgv, deps) {
|
|
|
12236
12863
|
await deps.writeBrokerResult(envelope, exit);
|
|
12237
12864
|
return void 0;
|
|
12238
12865
|
}
|
|
12239
|
-
async function
|
|
12240
|
-
const group =
|
|
12241
|
-
if (group === "-v" || group === "--version") {
|
|
12242
|
-
return `alva version ${CLI_VERSION}`;
|
|
12243
|
-
}
|
|
12244
|
-
if (!group || group === "--help" || group === "-h") {
|
|
12245
|
-
return { _help: true, text: HELP_TEXT };
|
|
12246
|
-
}
|
|
12247
|
-
if (COMMAND_HELP[group] && (args[1] === "--help" || args[1] === "-h")) {
|
|
12248
|
-
return { _help: true, text: COMMAND_HELP[group] };
|
|
12249
|
-
}
|
|
12250
|
-
if (group === "broker") {
|
|
12251
|
-
return handleBroker(client, args.slice(1), deps);
|
|
12252
|
-
}
|
|
12253
|
-
const parsedCommand = parseCommand(args);
|
|
12866
|
+
async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
12867
|
+
const group = parsedCommand.path[0];
|
|
12254
12868
|
const subcommand = parsedCommand.path[1];
|
|
12255
12869
|
const flags = parsedCommand.flags;
|
|
12256
12870
|
const positionals = parsedCommand.positionals;
|
|
12257
|
-
if (flags["help"] !== void 0) {
|
|
12258
|
-
const helpText = COMMAND_HELP[group];
|
|
12259
|
-
if (helpText) return { _help: true, text: helpText };
|
|
12260
|
-
}
|
|
12261
12871
|
if (group === "whoami") {
|
|
12262
12872
|
const user = await client.user.me();
|
|
12263
12873
|
const record = projectUserProfileForCLI(
|
|
@@ -12407,11 +13017,10 @@ async function dispatch(client, args, meta, deps) {
|
|
|
12407
13017
|
}
|
|
12408
13018
|
const timeout_ms = runTimeoutMs(flags, deps);
|
|
12409
13019
|
configureRunFetchTimeout(timeout_ms, deps);
|
|
12410
|
-
|
|
13020
|
+
const params = {
|
|
12411
13021
|
code,
|
|
12412
13022
|
entry_path: flags["entry-path"],
|
|
12413
13023
|
working_dir: flags["working-dir"],
|
|
12414
|
-
args: jsonParse(flags["args"]),
|
|
12415
13024
|
max_heap_size_mb: optionalBoundedIntegerFlag(
|
|
12416
13025
|
flags,
|
|
12417
13026
|
"max-heap-size-mb",
|
|
@@ -12420,18 +13029,19 @@ async function dispatch(client, args, meta, deps) {
|
|
|
12420
13029
|
2048
|
|
12421
13030
|
),
|
|
12422
13031
|
timeout_ms
|
|
12423
|
-
}
|
|
13032
|
+
};
|
|
13033
|
+
const serializedArgs = serializedJSONFlag(flags["args"], "run");
|
|
13034
|
+
return serializedArgs === void 0 ? client.run.execute(params) : client.run._executeSerializedArgs(params, serializedArgs);
|
|
12424
13035
|
}
|
|
12425
13036
|
case "deploy": {
|
|
12426
13037
|
if (!subcommand)
|
|
12427
13038
|
throw new CliUsageError("Missing subcommand for deploy", "deploy");
|
|
12428
13039
|
switch (subcommand) {
|
|
12429
|
-
case "create":
|
|
12430
|
-
|
|
13040
|
+
case "create": {
|
|
13041
|
+
const params = {
|
|
12431
13042
|
name: requireFlag(flags, "name", "deploy create"),
|
|
12432
13043
|
path: requireFlag(flags, "path", "deploy create"),
|
|
12433
13044
|
cron_expression: requireFlag(flags, "cron", "deploy create"),
|
|
12434
|
-
args: jsonParse(flags["args"]),
|
|
12435
13045
|
push_notify: boolFlag(flags["push-notify"]),
|
|
12436
13046
|
max_heap_size_mb: optionalBoundedIntegerFlag(
|
|
12437
13047
|
flags,
|
|
@@ -12451,7 +13061,13 @@ async function dispatch(client, args, meta, deps) {
|
|
|
12451
13061
|
flags,
|
|
12452
13062
|
"deploy create"
|
|
12453
13063
|
)
|
|
12454
|
-
}
|
|
13064
|
+
};
|
|
13065
|
+
const serializedArgs = serializedJSONFlag(
|
|
13066
|
+
flags["args"],
|
|
13067
|
+
"deploy create"
|
|
13068
|
+
);
|
|
13069
|
+
return serializedArgs === void 0 ? client.deploy.create(params) : client.deploy._createSerializedArgs(params, serializedArgs);
|
|
13070
|
+
}
|
|
12455
13071
|
case "list":
|
|
12456
13072
|
return client.deploy.list({
|
|
12457
13073
|
limit: num(flags["limit"]),
|
|
@@ -12461,12 +13077,11 @@ async function dispatch(client, args, meta, deps) {
|
|
|
12461
13077
|
return client.deploy.get({
|
|
12462
13078
|
id: requireNumericFlag(flags, "id", "deploy get")
|
|
12463
13079
|
});
|
|
12464
|
-
case "update":
|
|
12465
|
-
|
|
13080
|
+
case "update": {
|
|
13081
|
+
const params = {
|
|
12466
13082
|
id: requireNumericFlag(flags, "id", "deploy update"),
|
|
12467
13083
|
name: flags["name"],
|
|
12468
13084
|
cron_expression: flags["cron"],
|
|
12469
|
-
args: jsonParse(flags["args"]),
|
|
12470
13085
|
push_notify: boolFlag(flags["push-notify"]),
|
|
12471
13086
|
max_heap_size_mb: optionalBoundedIntegerFlag(
|
|
12472
13087
|
flags,
|
|
@@ -12483,7 +13098,13 @@ async function dispatch(client, args, meta, deps) {
|
|
|
12483
13098
|
3600
|
|
12484
13099
|
),
|
|
12485
13100
|
run_as_user_id: resolveRunAsFlag(flags, "deploy update")
|
|
12486
|
-
}
|
|
13101
|
+
};
|
|
13102
|
+
const serializedArgs = serializedJSONFlag(
|
|
13103
|
+
flags["args"],
|
|
13104
|
+
"deploy update"
|
|
13105
|
+
);
|
|
13106
|
+
return serializedArgs === void 0 ? client.deploy.update(params) : client.deploy._updateSerializedArgs(params, serializedArgs);
|
|
13107
|
+
}
|
|
12487
13108
|
case "delete":
|
|
12488
13109
|
return client.deploy.delete({
|
|
12489
13110
|
id: requireNumericFlag(flags, "id", "deploy delete")
|
|
@@ -12714,6 +13335,31 @@ async function dispatch(client, args, meta, deps) {
|
|
|
12714
13335
|
);
|
|
12715
13336
|
case "update":
|
|
12716
13337
|
return client.automation.update(automationUpdateParams(flags));
|
|
13338
|
+
case "delivery": {
|
|
13339
|
+
const leaf = parsedCommand.path[2];
|
|
13340
|
+
if (!leaf || leaf === "--help" || leaf === "-h") {
|
|
13341
|
+
return { _help: true, text: COMMAND_HELP.automation };
|
|
13342
|
+
}
|
|
13343
|
+
switch (leaf) {
|
|
13344
|
+
case "get":
|
|
13345
|
+
return client.automation.delivery.get({
|
|
13346
|
+
id: requirePositiveIntegerStringFlag(
|
|
13347
|
+
flags,
|
|
13348
|
+
"id",
|
|
13349
|
+
"automation delivery get"
|
|
13350
|
+
)
|
|
13351
|
+
});
|
|
13352
|
+
case "update":
|
|
13353
|
+
return client.automation.delivery.update(
|
|
13354
|
+
automationDeliveryUpdateParams(flags)
|
|
13355
|
+
);
|
|
13356
|
+
default:
|
|
13357
|
+
throw new CliUsageError(
|
|
13358
|
+
`Unknown subcommand: automation delivery ${leaf}`,
|
|
13359
|
+
"automation"
|
|
13360
|
+
);
|
|
13361
|
+
}
|
|
13362
|
+
}
|
|
12717
13363
|
case "stop":
|
|
12718
13364
|
return client.automation.stop({
|
|
12719
13365
|
id: requireNumericFlag(flags, "id", "automation stop")
|
|
@@ -13062,10 +13708,10 @@ async function dispatch(client, args, meta, deps) {
|
|
|
13062
13708
|
const { exitCode, output } = await handleLintPlaybook({
|
|
13063
13709
|
file,
|
|
13064
13710
|
format,
|
|
13065
|
-
client: deps?.
|
|
13711
|
+
client: deps?.runtime === "jagent" ? client : void 0,
|
|
13066
13712
|
readFile: deps?.localFiles?.readText
|
|
13067
13713
|
});
|
|
13068
|
-
if (deps?.
|
|
13714
|
+
if (deps?.runtime === "jagent") {
|
|
13069
13715
|
if (exitCode !== 0) throw new Error(output);
|
|
13070
13716
|
return output;
|
|
13071
13717
|
}
|
|
@@ -13849,40 +14495,460 @@ async function dispatch(client, args, meta, deps) {
|
|
|
13849
14495
|
throw new CliUsageError(`Unknown command: '${group}'`);
|
|
13850
14496
|
}
|
|
13851
14497
|
}
|
|
13852
|
-
|
|
13853
|
-
|
|
13854
|
-
|
|
13855
|
-
|
|
13856
|
-
|
|
13857
|
-
|
|
13858
|
-
|
|
14498
|
+
|
|
14499
|
+
// src/cli/embeddedDispatch.ts
|
|
14500
|
+
var ALPI_ALVA_COMMAND_PATHS = Object.freeze(
|
|
14501
|
+
EMBEDDED_COMMAND_DEFINITIONS.map((definition) => definition.path.join(" "))
|
|
14502
|
+
);
|
|
14503
|
+
var ALPI_ALVA_COMMAND_PATH_SET = new Set(ALPI_ALVA_COMMAND_PATHS);
|
|
14504
|
+
var HIDDEN_BROKER_COMMANDS = /* @__PURE__ */ new Set([
|
|
14505
|
+
"accounts",
|
|
14506
|
+
"risk-rules",
|
|
14507
|
+
"venues",
|
|
14508
|
+
"help"
|
|
14509
|
+
]);
|
|
14510
|
+
function selectedEmbeddedFlagValues(parsed, names) {
|
|
14511
|
+
return Object.fromEntries(
|
|
14512
|
+
names.flatMap((name) => {
|
|
14513
|
+
const value = parsed.flags[name];
|
|
14514
|
+
return value === void 0 ? [] : [[name, value]];
|
|
14515
|
+
})
|
|
14516
|
+
);
|
|
14517
|
+
}
|
|
14518
|
+
function internalCommand(path, flags = {}) {
|
|
14519
|
+
return { path, flags, positionals: [] };
|
|
14520
|
+
}
|
|
14521
|
+
function automationID(parsed, command2) {
|
|
14522
|
+
return requirePositiveIntegerStringFlag(parsed.flags, "id", command2);
|
|
14523
|
+
}
|
|
14524
|
+
function producerIDFromAutomationDetail(detail, automationId) {
|
|
14525
|
+
if (typeof detail !== "object" || detail === null || Array.isArray(detail)) {
|
|
14526
|
+
throw new Error(`Automation ${automationId} returned an invalid detail`);
|
|
14527
|
+
}
|
|
14528
|
+
const raw = detail.cronjob_id;
|
|
14529
|
+
if (raw === void 0 || raw === null) return void 0;
|
|
14530
|
+
if (typeof raw !== "number" || !Number.isSafeInteger(raw) || raw <= 0) {
|
|
14531
|
+
throw new Error(`Automation ${automationId} returned an invalid producer`);
|
|
14532
|
+
}
|
|
14533
|
+
return raw;
|
|
14534
|
+
}
|
|
14535
|
+
function producerIDFromCreate(result) {
|
|
14536
|
+
if (typeof result !== "object" || result === null) {
|
|
14537
|
+
throw new Error("Automation producer creation returned an invalid result");
|
|
14538
|
+
}
|
|
14539
|
+
const raw = result.id;
|
|
14540
|
+
if (typeof raw !== "number" || !Number.isSafeInteger(raw) || raw <= 0) {
|
|
14541
|
+
throw new Error("Automation producer creation returned an invalid id");
|
|
14542
|
+
}
|
|
14543
|
+
return raw;
|
|
14544
|
+
}
|
|
14545
|
+
async function resolveAutomationProducer(client, automationId) {
|
|
14546
|
+
const detail = await client.automation.inspect({ id: automationId });
|
|
14547
|
+
const producerId = producerIDFromAutomationDetail(detail, automationId);
|
|
14548
|
+
if (producerId === void 0) {
|
|
14549
|
+
throw new Error(`Automation ${automationId} has no active producer`);
|
|
14550
|
+
}
|
|
14551
|
+
return producerId;
|
|
14552
|
+
}
|
|
14553
|
+
async function findAutomationProducer(client, automationId) {
|
|
14554
|
+
const detail = await client.automation.inspect({ id: automationId });
|
|
14555
|
+
return producerIDFromAutomationDetail(detail, automationId);
|
|
14556
|
+
}
|
|
14557
|
+
async function dispatchEmbeddedAutomation(client, parsed, meta, deps) {
|
|
14558
|
+
const definition = embeddedCommandDefinition(parsed.path);
|
|
14559
|
+
switch (definition.action) {
|
|
14560
|
+
case "automation-inspect": {
|
|
14561
|
+
const id = automationID(parsed, "automation inspect");
|
|
14562
|
+
const result = await client.automation.inspect({ id });
|
|
14563
|
+
return parsed.flags.json === "true" ? result : formatAutomationDetail(result);
|
|
14564
|
+
}
|
|
14565
|
+
case "automation-set-visibility": {
|
|
14566
|
+
const id = automationID(parsed, "automation set-visibility");
|
|
14567
|
+
const visibility = requireFlag(
|
|
14568
|
+
parsed.flags,
|
|
14569
|
+
"visibility",
|
|
14570
|
+
"automation set-visibility"
|
|
14571
|
+
);
|
|
14572
|
+
if (visibility !== "public" && visibility !== "private") {
|
|
14573
|
+
throw new CliUsageError(
|
|
14574
|
+
`--visibility must be one of public, private for 'automation set-visibility', got '${visibility}'`,
|
|
14575
|
+
"automation"
|
|
14576
|
+
);
|
|
14577
|
+
}
|
|
14578
|
+
return client.feed.setVisibility({ id, visibility });
|
|
14579
|
+
}
|
|
14580
|
+
case "automation-create": {
|
|
14581
|
+
const name = requireFlag(parsed.flags, "name", "automation create");
|
|
14582
|
+
requireFlag(parsed.flags, "path", "automation create");
|
|
14583
|
+
requireFlag(parsed.flags, "cron", "automation create");
|
|
14584
|
+
const version = requireFlag(parsed.flags, "version", "automation create");
|
|
14585
|
+
const producer = await executeParsedCommand(
|
|
14586
|
+
client,
|
|
14587
|
+
internalCommand(
|
|
14588
|
+
["deploy", "create"],
|
|
14589
|
+
selectedEmbeddedFlagValues(parsed, [
|
|
14590
|
+
"name",
|
|
14591
|
+
"path",
|
|
14592
|
+
"cron",
|
|
14593
|
+
"args",
|
|
14594
|
+
"max-heap-size-mb",
|
|
14595
|
+
"execution-timeout-seconds",
|
|
14596
|
+
"run-as-service-account",
|
|
14597
|
+
"push-notify"
|
|
14598
|
+
])
|
|
14599
|
+
),
|
|
14600
|
+
meta,
|
|
14601
|
+
deps
|
|
14602
|
+
);
|
|
14603
|
+
const cronjobId = producerIDFromCreate(producer);
|
|
14604
|
+
try {
|
|
14605
|
+
const automation = await executeParsedCommand(
|
|
14606
|
+
client,
|
|
14607
|
+
internalCommand(["automation", "publish"], {
|
|
14608
|
+
name,
|
|
14609
|
+
version,
|
|
14610
|
+
"cronjob-id": String(cronjobId),
|
|
14611
|
+
...selectedEmbeddedFlagValues(parsed, [
|
|
14612
|
+
"view-json",
|
|
14613
|
+
"description",
|
|
14614
|
+
"changelog",
|
|
14615
|
+
"agent-type",
|
|
14616
|
+
"skip-auto-trigger"
|
|
14617
|
+
])
|
|
14618
|
+
}),
|
|
14619
|
+
meta,
|
|
14620
|
+
deps
|
|
14621
|
+
);
|
|
14622
|
+
return { automation, producer };
|
|
14623
|
+
} catch (error) {
|
|
14624
|
+
throw new Error(
|
|
14625
|
+
`Automation registration failed after producer ${cronjobId} was created; the producer was left intact for recovery: ${error instanceof Error ? error.message : String(error)}`
|
|
14626
|
+
);
|
|
14627
|
+
}
|
|
13859
14628
|
}
|
|
13860
|
-
|
|
13861
|
-
const
|
|
13862
|
-
|
|
13863
|
-
|
|
14629
|
+
case "automation-update": {
|
|
14630
|
+
const id = automationID(parsed, "automation update");
|
|
14631
|
+
const producerFlags = selectedEmbeddedFlagValues(parsed, [
|
|
14632
|
+
"name",
|
|
14633
|
+
"cron",
|
|
14634
|
+
"args",
|
|
14635
|
+
"max-heap-size-mb",
|
|
14636
|
+
"execution-timeout-seconds",
|
|
14637
|
+
"run-as-service-account",
|
|
14638
|
+
"push-notify",
|
|
14639
|
+
"clear-run-as"
|
|
14640
|
+
]);
|
|
14641
|
+
const productFlags = selectedEmbeddedFlagValues(parsed, [
|
|
14642
|
+
"version",
|
|
14643
|
+
"description",
|
|
14644
|
+
"changelog",
|
|
14645
|
+
"agent-type"
|
|
14646
|
+
]);
|
|
14647
|
+
if (Object.keys(producerFlags).length === 0 && Object.keys(productFlags).length === 0) {
|
|
14648
|
+
throw new CliUsageError(
|
|
14649
|
+
"'automation update' requires at least one update field",
|
|
14650
|
+
"automation"
|
|
14651
|
+
);
|
|
13864
14652
|
}
|
|
13865
|
-
|
|
13866
|
-
|
|
14653
|
+
let cronjobId;
|
|
14654
|
+
let producer;
|
|
14655
|
+
if (Object.keys(producerFlags).length > 0) {
|
|
14656
|
+
cronjobId = await resolveAutomationProducer(client, id);
|
|
14657
|
+
producer = await executeParsedCommand(
|
|
14658
|
+
client,
|
|
14659
|
+
internalCommand(["deploy", "update"], {
|
|
14660
|
+
id: String(cronjobId),
|
|
14661
|
+
...producerFlags
|
|
14662
|
+
}),
|
|
14663
|
+
meta,
|
|
14664
|
+
deps
|
|
14665
|
+
);
|
|
14666
|
+
}
|
|
14667
|
+
let automation;
|
|
14668
|
+
if (Object.keys(productFlags).length > 0) {
|
|
14669
|
+
try {
|
|
14670
|
+
automation = await executeParsedCommand(
|
|
14671
|
+
client,
|
|
14672
|
+
internalCommand(["automation", "update"], {
|
|
14673
|
+
id: String(id),
|
|
14674
|
+
...productFlags
|
|
14675
|
+
}),
|
|
14676
|
+
meta,
|
|
14677
|
+
deps
|
|
14678
|
+
);
|
|
14679
|
+
} catch (error) {
|
|
14680
|
+
const suffix = Object.keys(producerFlags).length === 0 ? "" : ` after producer ${cronjobId} was updated`;
|
|
14681
|
+
throw new Error(
|
|
14682
|
+
`Automation ${id} metadata update failed${suffix}: ${error instanceof Error ? error.message : String(error)}`
|
|
14683
|
+
);
|
|
14684
|
+
}
|
|
14685
|
+
}
|
|
14686
|
+
return {
|
|
14687
|
+
automation_id: String(id),
|
|
14688
|
+
cronjob_id: cronjobId,
|
|
14689
|
+
automation,
|
|
14690
|
+
producer
|
|
14691
|
+
};
|
|
13867
14692
|
}
|
|
13868
|
-
|
|
13869
|
-
|
|
14693
|
+
case "automation-pause": {
|
|
14694
|
+
const id = automationID(parsed, "automation pause");
|
|
14695
|
+
const cronjobId = await resolveAutomationProducer(client, id);
|
|
14696
|
+
await executeParsedCommand(
|
|
14697
|
+
client,
|
|
14698
|
+
internalCommand(["deploy", "pause"], { id: String(cronjobId) }),
|
|
14699
|
+
meta,
|
|
14700
|
+
deps
|
|
14701
|
+
);
|
|
14702
|
+
try {
|
|
14703
|
+
await client.automation.stop({ id });
|
|
14704
|
+
} catch (error) {
|
|
14705
|
+
throw new Error(
|
|
14706
|
+
`Automation ${id} delivery pause failed after producer ${cronjobId} was paused: ${error instanceof Error ? error.message : String(error)}`
|
|
14707
|
+
);
|
|
14708
|
+
}
|
|
14709
|
+
return {
|
|
14710
|
+
automation_id: String(id),
|
|
14711
|
+
cronjob_id: cronjobId,
|
|
14712
|
+
status: "paused"
|
|
14713
|
+
};
|
|
14714
|
+
}
|
|
14715
|
+
case "automation-resume": {
|
|
14716
|
+
const id = automationID(parsed, "automation resume");
|
|
14717
|
+
const cronjobId = await resolveAutomationProducer(client, id);
|
|
14718
|
+
await client.automation.resume({ id });
|
|
14719
|
+
try {
|
|
14720
|
+
await executeParsedCommand(
|
|
14721
|
+
client,
|
|
14722
|
+
internalCommand(["deploy", "resume"], { id: String(cronjobId) }),
|
|
14723
|
+
meta,
|
|
14724
|
+
deps
|
|
14725
|
+
);
|
|
14726
|
+
} catch (error) {
|
|
14727
|
+
throw new Error(
|
|
14728
|
+
`Producer ${cronjobId} resume failed after automation ${id} delivery was resumed: ${error instanceof Error ? error.message : String(error)}`
|
|
14729
|
+
);
|
|
14730
|
+
}
|
|
14731
|
+
return {
|
|
14732
|
+
automation_id: String(id),
|
|
14733
|
+
cronjob_id: cronjobId,
|
|
14734
|
+
status: "active"
|
|
14735
|
+
};
|
|
14736
|
+
}
|
|
14737
|
+
case "automation-delete": {
|
|
14738
|
+
const id = automationID(parsed, "automation delete");
|
|
14739
|
+
const cronjobId = await findAutomationProducer(client, id);
|
|
14740
|
+
if (cronjobId === void 0) {
|
|
14741
|
+
await client.automation.delete({ id });
|
|
14742
|
+
return {
|
|
14743
|
+
automation_id: id,
|
|
14744
|
+
status: "deleted"
|
|
14745
|
+
};
|
|
14746
|
+
}
|
|
14747
|
+
await executeParsedCommand(
|
|
14748
|
+
client,
|
|
14749
|
+
internalCommand(["deploy", "pause"], { id: String(cronjobId) }),
|
|
14750
|
+
meta,
|
|
14751
|
+
deps
|
|
14752
|
+
);
|
|
14753
|
+
try {
|
|
14754
|
+
await client.automation.delete({ id });
|
|
14755
|
+
} catch (error) {
|
|
14756
|
+
throw new Error(
|
|
14757
|
+
`Automation ${id} delete failed after producer ${cronjobId} was paused; the producer remains paused: ${error instanceof Error ? error.message : String(error)}`
|
|
14758
|
+
);
|
|
14759
|
+
}
|
|
14760
|
+
try {
|
|
14761
|
+
await executeParsedCommand(
|
|
14762
|
+
client,
|
|
14763
|
+
internalCommand(["deploy", "delete"], { id: String(cronjobId) }),
|
|
14764
|
+
meta,
|
|
14765
|
+
deps
|
|
14766
|
+
);
|
|
14767
|
+
} catch (error) {
|
|
14768
|
+
throw new Error(
|
|
14769
|
+
`Automation ${id} was deleted but paused producer ${cronjobId} could not be removed: ${error instanceof Error ? error.message : String(error)}`
|
|
14770
|
+
);
|
|
14771
|
+
}
|
|
14772
|
+
return {
|
|
14773
|
+
automation_id: String(id),
|
|
14774
|
+
cronjob_id: cronjobId,
|
|
14775
|
+
status: "deleted"
|
|
14776
|
+
};
|
|
14777
|
+
}
|
|
14778
|
+
case "automation-trigger": {
|
|
14779
|
+
const id = automationID(parsed, "automation trigger");
|
|
14780
|
+
const cronjobId = await resolveAutomationProducer(client, id);
|
|
14781
|
+
return executeParsedCommand(
|
|
14782
|
+
client,
|
|
14783
|
+
internalCommand(["deploy", "trigger"], { id: String(cronjobId) }),
|
|
14784
|
+
meta,
|
|
14785
|
+
deps
|
|
14786
|
+
);
|
|
14787
|
+
}
|
|
14788
|
+
case "automation-runs-list":
|
|
14789
|
+
case "automation-runs-status":
|
|
14790
|
+
case "automation-runs-logs": {
|
|
14791
|
+
const command2 = parsed.path.join(" ");
|
|
14792
|
+
const id = automationID(parsed, command2);
|
|
14793
|
+
const cronjobId = await resolveAutomationProducer(client, id);
|
|
14794
|
+
const target = definition.action === "automation-runs-list" ? "runs" : definition.action === "automation-runs-status" ? "run-status" : "run-logs";
|
|
14795
|
+
const extra = definition.action === "automation-runs-list" ? selectedEmbeddedFlagValues(parsed, ["first", "cursor"]) : definition.action === "automation-runs-status" ? selectedEmbeddedFlagValues(parsed, ["workflow-run-id"]) : selectedEmbeddedFlagValues(parsed, ["run-id"]);
|
|
14796
|
+
return executeParsedCommand(
|
|
14797
|
+
client,
|
|
14798
|
+
internalCommand(["deploy", target], {
|
|
14799
|
+
id: String(cronjobId),
|
|
14800
|
+
...extra
|
|
14801
|
+
}),
|
|
14802
|
+
meta,
|
|
14803
|
+
deps
|
|
14804
|
+
);
|
|
14805
|
+
}
|
|
14806
|
+
default:
|
|
14807
|
+
throw new Error(
|
|
14808
|
+
`Agent automation route '${parsed.path.join(" ")}' has no handler`
|
|
14809
|
+
);
|
|
14810
|
+
}
|
|
14811
|
+
}
|
|
14812
|
+
async function dispatchEmbedded(client, args, meta, deps) {
|
|
14813
|
+
const group = args[0];
|
|
14814
|
+
if (group === "-v" || group === "--version") {
|
|
14815
|
+
return `alva version ${CLI_VERSION}`;
|
|
14816
|
+
}
|
|
14817
|
+
if (!group || group === "--help" || group === "-h") {
|
|
14818
|
+
return { _help: true, text: AGENT_HELP_TEXT };
|
|
14819
|
+
}
|
|
14820
|
+
const requestedHelpIndex = args.findIndex(
|
|
14821
|
+
(argument) => argument === "--help" || argument === "-h"
|
|
14822
|
+
);
|
|
14823
|
+
const requestedHelp = requestedHelpIndex !== -1;
|
|
14824
|
+
const brokerNativeHelp = args[0] === "trading" && args[1] === "broker" && requestedHelpIndex > 2;
|
|
14825
|
+
const bareHelp = args.every((argument) => !argument.startsWith("-")) ? AGENT_COMMAND_HELP[args.join(" ")] : void 0;
|
|
14826
|
+
if (bareHelp !== void 0) {
|
|
14827
|
+
return { _help: true, text: bareHelp };
|
|
14828
|
+
}
|
|
14829
|
+
if (requestedHelp && !brokerNativeHelp) {
|
|
14830
|
+
const helpIndex = requestedHelpIndex;
|
|
14831
|
+
const helpPath = args.slice(0, helpIndex);
|
|
14832
|
+
const treeHelp = helpIndex === args.length - 1 && helpPath.every((argument) => !argument.startsWith("-")) ? AGENT_COMMAND_HELP[helpPath.join(" ")] : void 0;
|
|
14833
|
+
if (treeHelp !== void 0 && !ALPI_ALVA_COMMAND_PATH_SET.has(helpPath.join(" "))) {
|
|
14834
|
+
return { _help: true, text: treeHelp };
|
|
14835
|
+
}
|
|
14836
|
+
}
|
|
14837
|
+
const parsed = parseEmbeddedCommand(args);
|
|
14838
|
+
if (requestedHelp && !brokerNativeHelp || parsed.flags.help !== void 0) {
|
|
14839
|
+
return {
|
|
14840
|
+
_help: true,
|
|
14841
|
+
text: agentHelpFor(args) ?? AGENT_HELP_TEXT
|
|
14842
|
+
};
|
|
14843
|
+
}
|
|
14844
|
+
const action2 = embeddedCommandDefinition(parsed.path).action;
|
|
14845
|
+
if (action2?.startsWith("automation-")) {
|
|
14846
|
+
return dispatchEmbeddedAutomation(client, parsed, meta, deps);
|
|
14847
|
+
}
|
|
14848
|
+
if (parsed.path.join(" ") === "trading broker") {
|
|
14849
|
+
const brokerArgv = parsed.passthrough ?? [];
|
|
14850
|
+
const command2 = brokerArgv[0];
|
|
14851
|
+
if (HIDDEN_BROKER_COMMANDS.has(command2)) {
|
|
14852
|
+
const replacement = command2 === "accounts" || command2 === "risk-rules" ? `alva trading ${command2}` : "alva trading broker describe";
|
|
14853
|
+
throw new CliUsageError(
|
|
14854
|
+
`'trading broker ${command2}' is not part of the Slim Broker tree; use '${replacement}'`,
|
|
14855
|
+
"trading"
|
|
14856
|
+
);
|
|
13870
14857
|
}
|
|
13871
|
-
|
|
14858
|
+
const commandSelector = brokerArgv.findIndex(
|
|
14859
|
+
(argument) => argument === "--command"
|
|
14860
|
+
);
|
|
14861
|
+
const describedCommand = brokerArgv[commandSelector + 1];
|
|
14862
|
+
if (command2 === "describe" && commandSelector !== -1 && HIDDEN_BROKER_COMMANDS.has(describedCommand)) {
|
|
14863
|
+
const message = describedCommand === "accounts" || describedCommand === "risk-rules" ? `Shared trading prerequisites are described by 'alva trading ${describedCommand}'` : `'trading broker describe --command ${describedCommand}' is not part of the Slim Broker tree`;
|
|
14864
|
+
throw new CliUsageError(message, "trading");
|
|
14865
|
+
}
|
|
14866
|
+
const result = await handleBroker(client, brokerArgv, deps);
|
|
14867
|
+
return command2 === "describe" ? adaptEmbeddedBrokerDescription(result) : result;
|
|
14868
|
+
}
|
|
14869
|
+
return dispatchEmbeddedTarget(client, parsed, meta, deps);
|
|
14870
|
+
}
|
|
14871
|
+
async function dispatchEmbeddedTarget(client, parsed, meta, deps) {
|
|
14872
|
+
const definition = embeddedCommandDefinition(parsed.path);
|
|
14873
|
+
let target;
|
|
14874
|
+
if (definition.action === "notification-set-preference") {
|
|
14875
|
+
const value = parsed.flags["session-completed"];
|
|
14876
|
+
if (value !== "enabled" && value !== "disabled") {
|
|
14877
|
+
throw new CliUsageError(
|
|
14878
|
+
"--session-completed must be 'enabled' or 'disabled' for 'account notifications set-preference'",
|
|
14879
|
+
"account"
|
|
14880
|
+
);
|
|
14881
|
+
}
|
|
14882
|
+
target = internalCommand([
|
|
14883
|
+
"notification-preferences",
|
|
14884
|
+
value === "enabled" ? "enable-session-completed" : "disable-session-completed"
|
|
14885
|
+
]);
|
|
14886
|
+
} else if (definition.action === "signal-execute") {
|
|
14887
|
+
const { live, ...flags } = parsed.flags;
|
|
14888
|
+
target = {
|
|
14889
|
+
...parsed,
|
|
14890
|
+
path: ["trading", "execute"],
|
|
14891
|
+
flags: live === "true" ? flags : { ...flags, "dry-run": "true" }
|
|
14892
|
+
};
|
|
14893
|
+
} else if (definition.action === "screenshot") {
|
|
14894
|
+
target = {
|
|
14895
|
+
...parsed,
|
|
14896
|
+
path: ["screenshot"],
|
|
14897
|
+
flags: { ...parsed.flags, base64: "true" }
|
|
14898
|
+
};
|
|
14899
|
+
} else if (definition.targetPath !== void 0) {
|
|
14900
|
+
target = { ...parsed, path: definition.targetPath };
|
|
14901
|
+
} else {
|
|
14902
|
+
throw new Error(
|
|
14903
|
+
`Embedded command '${parsed.path.join(" ")}' has no execution path`
|
|
14904
|
+
);
|
|
13872
14905
|
}
|
|
13873
|
-
|
|
14906
|
+
try {
|
|
14907
|
+
if (target.path[0] === "broker") {
|
|
14908
|
+
return await handleBroker(
|
|
14909
|
+
client,
|
|
14910
|
+
[...target.path.slice(1), ...target.passthrough ?? []],
|
|
14911
|
+
deps
|
|
14912
|
+
);
|
|
14913
|
+
}
|
|
14914
|
+
return await executeParsedCommand(client, target, meta, deps);
|
|
14915
|
+
} catch (error) {
|
|
14916
|
+
if (!(error instanceof CliUsageError)) throw error;
|
|
14917
|
+
const targetName = target.path.join(" ");
|
|
14918
|
+
const command2 = parsed.path.join(" ");
|
|
14919
|
+
const message = error.message.replaceAll(targetName, command2);
|
|
14920
|
+
throw new CliUsageError(message, parsed.path[0]);
|
|
14921
|
+
}
|
|
14922
|
+
}
|
|
14923
|
+
function adaptEmbeddedBrokerDescription(value, key) {
|
|
14924
|
+
if (typeof value === "string") {
|
|
14925
|
+
return value.replaceAll("alva broker accounts", "alva trading accounts").replaceAll("alva broker risk-rules", "alva trading risk-rules").replaceAll("alva broker", "alva trading broker");
|
|
14926
|
+
}
|
|
14927
|
+
if (Array.isArray(value)) {
|
|
14928
|
+
const items = key === "commands" ? value.filter((item) => {
|
|
14929
|
+
if (typeof item !== "object" || item === null) return true;
|
|
14930
|
+
const name = item.name;
|
|
14931
|
+
return name !== "accounts" && name !== "risk-rules" && name !== "venues" && name !== "help";
|
|
14932
|
+
}) : value;
|
|
14933
|
+
return items.map((item) => adaptEmbeddedBrokerDescription(item));
|
|
14934
|
+
}
|
|
14935
|
+
if (typeof value !== "object" || value === null) return value;
|
|
14936
|
+
return Object.fromEntries(
|
|
14937
|
+
Object.entries(value).map(([field, item]) => [
|
|
14938
|
+
field,
|
|
14939
|
+
adaptEmbeddedBrokerDescription(item, field)
|
|
14940
|
+
])
|
|
14941
|
+
);
|
|
14942
|
+
}
|
|
14943
|
+
async function dispatch(client, args, meta, deps) {
|
|
14944
|
+
return dispatchEmbedded(client, args, meta, { ...deps, runtime: "jagent" });
|
|
13874
14945
|
}
|
|
13875
14946
|
export {
|
|
13876
|
-
|
|
14947
|
+
ALPI_ALVA_COMMAND_PATHS,
|
|
13877
14948
|
CLI_VERSION,
|
|
13878
|
-
COMMAND_HELP,
|
|
13879
14949
|
CliUsageError,
|
|
13880
14950
|
DEFAULT_RUN_TIMEOUT_MS,
|
|
13881
|
-
|
|
13882
|
-
dispatch,
|
|
13883
|
-
isVersionOlderThan,
|
|
13884
|
-
parseFlags,
|
|
13885
|
-
stripGlobalFlags
|
|
14951
|
+
dispatch
|
|
13886
14952
|
};
|
|
13887
14953
|
/*! Bundled license information:
|
|
13888
14954
|
|