@alva-ai/toolkit 0.24.0 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -16
- package/dist/browser.global.js +6 -6
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.d.ts +13 -11
- package/dist/cli.js +53 -28
- package/dist/cli.js.map +1 -1
- package/dist/dispatch.d.ts +16 -34
- package/dist/dispatch.js +1389 -485
- package/dist/dispatch.js.map +1 -1
- package/dist/index.cjs +10 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -8
- package/dist/index.d.ts +10 -8
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.d.ts
CHANGED
|
@@ -372,8 +372,8 @@ interface FeedReleaseResponse {
|
|
|
372
372
|
feed_path: string;
|
|
373
373
|
}
|
|
374
374
|
interface FeedDeleteRequest {
|
|
375
|
-
/**
|
|
376
|
-
id: number;
|
|
375
|
+
/** Positive decimal feed id. String form preserves int64 precision. */
|
|
376
|
+
id: number | string;
|
|
377
377
|
}
|
|
378
378
|
type FeedListStatus = 'active' | 'paused' | 'all';
|
|
379
379
|
interface FeedListParams {
|
|
@@ -400,14 +400,16 @@ interface FeedListResponse {
|
|
|
400
400
|
has_more: boolean;
|
|
401
401
|
}
|
|
402
402
|
interface AutomationInspectRequest {
|
|
403
|
-
/**
|
|
404
|
-
id: number;
|
|
403
|
+
/** Positive decimal automation id. String form preserves int64 precision. */
|
|
404
|
+
id: number | string;
|
|
405
405
|
}
|
|
406
406
|
interface AutomationInspectResponse {
|
|
407
407
|
/** Numeric automation id encoded as a string, matching the gateway response. */
|
|
408
408
|
id: string;
|
|
409
409
|
/** Backing feed id encoded as a string. */
|
|
410
410
|
feed_id: string;
|
|
411
|
+
/** Backing producer cronjob id used by lifecycle and run operations. */
|
|
412
|
+
cronjob_id?: number;
|
|
411
413
|
name: string;
|
|
412
414
|
description?: string;
|
|
413
415
|
/** Automation runtime status. */
|
|
@@ -486,8 +488,8 @@ interface AutomationAlertDeliveryUpdateResponse {
|
|
|
486
488
|
};
|
|
487
489
|
}
|
|
488
490
|
interface FeedStatusUpdateRequest {
|
|
489
|
-
/**
|
|
490
|
-
id: number;
|
|
491
|
+
/** Positive decimal feed id. String form preserves int64 precision. */
|
|
492
|
+
id: number | string;
|
|
491
493
|
}
|
|
492
494
|
interface FeedStatusUpdateResponse {
|
|
493
495
|
/** Echoed feed id (string form, matching gateway response). */
|
|
@@ -502,8 +504,8 @@ interface FeedDeleteResponse {
|
|
|
502
504
|
/** Feed visibility: 'public' publishes the feed, 'private' unpublishes it. */
|
|
503
505
|
type FeedVisibility = 'public' | 'private';
|
|
504
506
|
interface FeedSetVisibilityRequest {
|
|
505
|
-
/**
|
|
506
|
-
id: number;
|
|
507
|
+
/** Positive decimal feed id. String form preserves int64 precision. */
|
|
508
|
+
id: number | string;
|
|
507
509
|
/** Target visibility. */
|
|
508
510
|
visibility: FeedVisibility;
|
|
509
511
|
}
|
|
@@ -2156,14 +2158,14 @@ declare const BOOLEAN_FLAGS: Set<string>;
|
|
|
2156
2158
|
* Compares major.minor.patch as integers. Returns false on malformed input.
|
|
2157
2159
|
*/
|
|
2158
2160
|
declare function isVersionOlderThan(a: string, b: string): boolean;
|
|
2159
|
-
type
|
|
2161
|
+
type DispatchRuntime = 'nodejs' | 'jagent';
|
|
2160
2162
|
interface DispatchLocalFiles {
|
|
2161
2163
|
readText(path: string): string;
|
|
2162
2164
|
readBytes(path: string): BodyInit;
|
|
2163
2165
|
writeBytes(path: string, data: Uint8Array): void;
|
|
2164
2166
|
}
|
|
2165
2167
|
interface DispatchRuntimeDeps {
|
|
2166
|
-
|
|
2168
|
+
runtime?: DispatchRuntime;
|
|
2167
2169
|
env?: Record<string, string | undefined>;
|
|
2168
2170
|
stderr?: {
|
|
2169
2171
|
write(value: string): unknown;
|
|
@@ -2210,4 +2212,4 @@ declare function handleConfigure(args: string[], deps?: WriteConfigDeps): Promis
|
|
|
2210
2212
|
profile: string;
|
|
2211
2213
|
}>;
|
|
2212
2214
|
|
|
2213
|
-
export {
|
|
2215
|
+
export { BOOLEAN_FLAGS, CLI_VERSION, CliUsageError, DEFAULT_RUN_TIMEOUT_MS, type DispatchLocalFiles, type DispatchRuntime, type DispatchRuntimeDeps, dispatch, handleConfigure, isVersionOlderThan, parseFlags, stripGlobalFlags };
|
package/dist/cli.js
CHANGED
|
@@ -6614,7 +6614,13 @@ var FeedResource = class {
|
|
|
6614
6614
|
}
|
|
6615
6615
|
};
|
|
6616
6616
|
function requireFeedID(id) {
|
|
6617
|
-
if (
|
|
6617
|
+
if (typeof id === "string") {
|
|
6618
|
+
if (!/^[1-9]\d*$/.test(id)) {
|
|
6619
|
+
throw new Error("feed id must be a positive integer");
|
|
6620
|
+
}
|
|
6621
|
+
return id;
|
|
6622
|
+
}
|
|
6623
|
+
if (!Number.isSafeInteger(id) || id <= 0) {
|
|
6618
6624
|
throw new Error("feed id must be a positive integer");
|
|
6619
6625
|
}
|
|
6620
6626
|
return id;
|
|
@@ -6791,7 +6797,8 @@ var AutomationAlertDeliveryResource = class {
|
|
|
6791
6797
|
}
|
|
6792
6798
|
};
|
|
6793
6799
|
function requireAutomationID(id) {
|
|
6794
|
-
if (
|
|
6800
|
+
if (typeof id === "string") return requireAutomationIDString(id);
|
|
6801
|
+
if (!Number.isSafeInteger(id) || id <= 0) {
|
|
6795
6802
|
throw new Error("automation id must be a positive integer");
|
|
6796
6803
|
}
|
|
6797
6804
|
return id;
|
|
@@ -10024,7 +10031,7 @@ var COMMAND_DEFINITIONS = [
|
|
|
10024
10031
|
command("broker", { passthrough: true })
|
|
10025
10032
|
];
|
|
10026
10033
|
|
|
10027
|
-
// src/cli/
|
|
10034
|
+
// src/cli/commandParser.ts
|
|
10028
10035
|
function buildCommandTree(definitions) {
|
|
10029
10036
|
const root = { children: /* @__PURE__ */ new Map() };
|
|
10030
10037
|
for (const definition of definitions) {
|
|
@@ -10054,7 +10061,6 @@ function buildCommandTree(definitions) {
|
|
|
10054
10061
|
}
|
|
10055
10062
|
return root;
|
|
10056
10063
|
}
|
|
10057
|
-
var COMMAND_TREE = buildCommandTree(COMMAND_DEFINITIONS);
|
|
10058
10064
|
function editDistance(a, b) {
|
|
10059
10065
|
let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
|
|
10060
10066
|
for (let row = 1; row <= a.length; row++) {
|
|
@@ -10083,11 +10089,11 @@ function closestFlag(input, available) {
|
|
|
10083
10089
|
const threshold = input.length <= 4 ? 1 : 2;
|
|
10084
10090
|
return distance <= threshold ? closest : void 0;
|
|
10085
10091
|
}
|
|
10086
|
-
function mergeFlags(definition) {
|
|
10087
|
-
return { ...
|
|
10092
|
+
function mergeFlags(definition, globalFlags) {
|
|
10093
|
+
return { ...globalFlags, ...definition.flags };
|
|
10088
10094
|
}
|
|
10089
|
-
function resolveCommand(args) {
|
|
10090
|
-
let node =
|
|
10095
|
+
function resolveCommand(args, tree) {
|
|
10096
|
+
let node = tree;
|
|
10091
10097
|
let consumed = 0;
|
|
10092
10098
|
while (consumed < args.length) {
|
|
10093
10099
|
const input = args[consumed];
|
|
@@ -10127,8 +10133,8 @@ function unsupportedFlag(name, definition, available) {
|
|
|
10127
10133
|
definition.path[0]
|
|
10128
10134
|
);
|
|
10129
10135
|
}
|
|
10130
|
-
function
|
|
10131
|
-
const { definition, consumed } = resolveCommand(args);
|
|
10136
|
+
function parseWithTree(args, tree, globalFlags) {
|
|
10137
|
+
const { definition, consumed } = resolveCommand(args, tree);
|
|
10132
10138
|
if (definition.passthrough === true) {
|
|
10133
10139
|
return {
|
|
10134
10140
|
path: definition.path,
|
|
@@ -10137,7 +10143,7 @@ function parseCommand(args) {
|
|
|
10137
10143
|
passthrough: args.slice(consumed)
|
|
10138
10144
|
};
|
|
10139
10145
|
}
|
|
10140
|
-
const available = mergeFlags(definition);
|
|
10146
|
+
const available = mergeFlags(definition, globalFlags);
|
|
10141
10147
|
const flags = {};
|
|
10142
10148
|
const positionals = [];
|
|
10143
10149
|
for (let index = consumed; index < args.length; index++) {
|
|
@@ -10219,6 +10225,16 @@ function parseCommand(args) {
|
|
|
10219
10225
|
positionals
|
|
10220
10226
|
};
|
|
10221
10227
|
}
|
|
10228
|
+
function createCommandParser(definitions, globalFlags) {
|
|
10229
|
+
const tree = buildCommandTree(definitions);
|
|
10230
|
+
return (args) => parseWithTree(args, tree, globalFlags);
|
|
10231
|
+
}
|
|
10232
|
+
|
|
10233
|
+
// src/cli/commandSchema.ts
|
|
10234
|
+
var parseCommand = createCommandParser(
|
|
10235
|
+
COMMAND_DEFINITIONS,
|
|
10236
|
+
GLOBAL_FLAG_DEFINITIONS
|
|
10237
|
+
);
|
|
10222
10238
|
|
|
10223
10239
|
// src/cli/pkce.ts
|
|
10224
10240
|
import * as crypto from "crypto";
|
|
@@ -14272,7 +14288,7 @@ ${formatReport(report, "human")}
|
|
|
14272
14288
|
}
|
|
14273
14289
|
|
|
14274
14290
|
// src/cli/dispatch.ts
|
|
14275
|
-
var CLI_VERSION = true ? "0.
|
|
14291
|
+
var CLI_VERSION = true ? "0.25.1" : "dev";
|
|
14276
14292
|
var DEFAULT_RUN_TIMEOUT_MS = 6e5;
|
|
14277
14293
|
var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
|
|
14278
14294
|
var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
|
|
@@ -15724,7 +15740,7 @@ function runTimeoutMs(flags, deps) {
|
|
|
15724
15740
|
return DEFAULT_RUN_TIMEOUT_MS;
|
|
15725
15741
|
}
|
|
15726
15742
|
function configureRunFetchTimeout(timeoutMs, deps) {
|
|
15727
|
-
if (deps?.
|
|
15743
|
+
if (deps?.runtime === "jagent") return;
|
|
15728
15744
|
deps?.configureFetchTimeout?.(timeoutMs);
|
|
15729
15745
|
}
|
|
15730
15746
|
function requireCurrentGroupAlertSessionID(client, command2) {
|
|
@@ -16167,7 +16183,7 @@ function localFileUnsupported(command2, flag) {
|
|
|
16167
16183
|
);
|
|
16168
16184
|
}
|
|
16169
16185
|
function assertLocalFileAvailable(command2, flag, deps) {
|
|
16170
|
-
if (deps?.
|
|
16186
|
+
if (deps?.runtime === "jagent") {
|
|
16171
16187
|
throw localFileUnsupported(command2, flag);
|
|
16172
16188
|
}
|
|
16173
16189
|
}
|
|
@@ -16236,7 +16252,7 @@ function brokerStdinNeedsIntentId(stdin) {
|
|
|
16236
16252
|
return input.dryRun === false;
|
|
16237
16253
|
}
|
|
16238
16254
|
async function handleBroker(client, brokerArgv, deps) {
|
|
16239
|
-
let argv = brokerArgv;
|
|
16255
|
+
let argv = [...brokerArgv];
|
|
16240
16256
|
const isOrderPlace = brokerArgv[0] === "order" && brokerArgv[1] === "place";
|
|
16241
16257
|
const hasFlag = (name) => brokerArgv.some((a) => a === name || a.startsWith(`${name}=`));
|
|
16242
16258
|
const hasHandle = hasFlag("--intent-id") || hasFlag("--client-order-id");
|
|
@@ -16254,7 +16270,8 @@ async function handleBroker(client, brokerArgv, deps) {
|
|
|
16254
16270
|
throw new Error("Broker live orders require a runtime UUID provider.");
|
|
16255
16271
|
}
|
|
16256
16272
|
const intentId = randomUUID2();
|
|
16257
|
-
deps?.
|
|
16273
|
+
const brokerLabel = deps?.runtime === "jagent" ? "alva trading broker" : "alva broker";
|
|
16274
|
+
deps?.stderr?.write(`${brokerLabel}: intent-id ${intentId}
|
|
16258
16275
|
`);
|
|
16259
16276
|
argv = [...brokerArgv, "--intent-id", intentId];
|
|
16260
16277
|
}
|
|
@@ -16275,7 +16292,7 @@ async function handleBroker(client, brokerArgv, deps) {
|
|
|
16275
16292
|
};
|
|
16276
16293
|
exit = 2;
|
|
16277
16294
|
}
|
|
16278
|
-
if (deps?.
|
|
16295
|
+
if (deps?.runtime === "jagent") {
|
|
16279
16296
|
return envelope;
|
|
16280
16297
|
}
|
|
16281
16298
|
if (!deps?.writeBrokerResult) {
|
|
@@ -16284,7 +16301,10 @@ async function handleBroker(client, brokerArgv, deps) {
|
|
|
16284
16301
|
await deps.writeBrokerResult(envelope, exit);
|
|
16285
16302
|
return void 0;
|
|
16286
16303
|
}
|
|
16287
|
-
async function
|
|
16304
|
+
async function dispatchCli(client, args, meta, deps) {
|
|
16305
|
+
return dispatchTerminal(client, args, meta, deps);
|
|
16306
|
+
}
|
|
16307
|
+
async function dispatchTerminal(client, args, meta, deps) {
|
|
16288
16308
|
const group = args[0];
|
|
16289
16309
|
if (group === "-v" || group === "--version") {
|
|
16290
16310
|
return `alva version ${CLI_VERSION}`;
|
|
@@ -16299,13 +16319,18 @@ async function dispatch(client, args, meta, deps) {
|
|
|
16299
16319
|
return handleBroker(client, args.slice(1), deps);
|
|
16300
16320
|
}
|
|
16301
16321
|
const parsedCommand = parseCommand(args);
|
|
16302
|
-
const subcommand = parsedCommand.path[1];
|
|
16303
16322
|
const flags = parsedCommand.flags;
|
|
16304
|
-
const positionals = parsedCommand.positionals;
|
|
16305
16323
|
if (flags["help"] !== void 0) {
|
|
16306
16324
|
const helpText = COMMAND_HELP[group];
|
|
16307
16325
|
if (helpText) return { _help: true, text: helpText };
|
|
16308
16326
|
}
|
|
16327
|
+
return executeParsedCommand(client, parsedCommand, meta, deps);
|
|
16328
|
+
}
|
|
16329
|
+
async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
16330
|
+
const group = parsedCommand.path[0];
|
|
16331
|
+
const subcommand = parsedCommand.path[1];
|
|
16332
|
+
const flags = parsedCommand.flags;
|
|
16333
|
+
const positionals = parsedCommand.positionals;
|
|
16309
16334
|
if (group === "whoami") {
|
|
16310
16335
|
const user = await client.user.me();
|
|
16311
16336
|
const record = projectUserProfileForCLI(
|
|
@@ -17146,10 +17171,10 @@ async function dispatch(client, args, meta, deps) {
|
|
|
17146
17171
|
const { exitCode, output } = await handleLintPlaybook({
|
|
17147
17172
|
file,
|
|
17148
17173
|
format,
|
|
17149
|
-
client: deps?.
|
|
17174
|
+
client: deps?.runtime === "jagent" ? client : void 0,
|
|
17150
17175
|
readFile: deps?.localFiles?.readText
|
|
17151
17176
|
});
|
|
17152
|
-
if (deps?.
|
|
17177
|
+
if (deps?.runtime === "jagent") {
|
|
17153
17178
|
if (exitCode !== 0) throw new Error(output);
|
|
17154
17179
|
return output;
|
|
17155
17180
|
}
|
|
@@ -17937,7 +17962,7 @@ function stripGlobalFlags(argv) {
|
|
|
17937
17962
|
const result = [];
|
|
17938
17963
|
for (let i = 0; i < argv.length; i++) {
|
|
17939
17964
|
const a = argv[i];
|
|
17940
|
-
if (a === "broker") {
|
|
17965
|
+
if (a === "broker" || a === "trading" && argv[i + 1] === "broker") {
|
|
17941
17966
|
result.push(...argv.slice(i));
|
|
17942
17967
|
break;
|
|
17943
17968
|
}
|
|
@@ -18025,7 +18050,7 @@ async function readAllStdin() {
|
|
|
18025
18050
|
return Buffer.concat(chunks).toString("utf8");
|
|
18026
18051
|
}
|
|
18027
18052
|
var nodeRuntimeDeps = {
|
|
18028
|
-
|
|
18053
|
+
runtime: "nodejs",
|
|
18029
18054
|
env: process.env,
|
|
18030
18055
|
stderr: process.stderr,
|
|
18031
18056
|
localFiles: {
|
|
@@ -18043,8 +18068,8 @@ var nodeRuntimeDeps = {
|
|
|
18043
18068
|
process.exitCode = exitCode;
|
|
18044
18069
|
}
|
|
18045
18070
|
};
|
|
18046
|
-
async function
|
|
18047
|
-
return
|
|
18071
|
+
async function dispatch(client, args, meta, deps) {
|
|
18072
|
+
return dispatchCli(client, args, meta, {
|
|
18048
18073
|
...nodeRuntimeDeps,
|
|
18049
18074
|
...deps,
|
|
18050
18075
|
localFiles: deps?.localFiles ?? nodeRuntimeDeps.localFiles
|
|
@@ -18156,7 +18181,7 @@ async function main() {
|
|
|
18156
18181
|
originSessionId: config.originSessionId,
|
|
18157
18182
|
originSessionKind: config.originSessionKind
|
|
18158
18183
|
});
|
|
18159
|
-
const result = await
|
|
18184
|
+
const result = await dispatch(client, stripGlobalFlags(rawArgs), {
|
|
18160
18185
|
profile: config.profile,
|
|
18161
18186
|
baseUrl: config.baseUrl,
|
|
18162
18187
|
cliVersion: CLI_VERSION
|
|
@@ -18227,7 +18252,7 @@ export {
|
|
|
18227
18252
|
CLI_VERSION,
|
|
18228
18253
|
CliUsageError,
|
|
18229
18254
|
DEFAULT_RUN_TIMEOUT_MS,
|
|
18230
|
-
|
|
18255
|
+
dispatch,
|
|
18231
18256
|
handleConfigure,
|
|
18232
18257
|
isVersionOlderThan,
|
|
18233
18258
|
parseFlags,
|