@alva-ai/toolkit 0.12.1-beta.0 → 0.13.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 +4 -2
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.d.ts +6 -1
- package/dist/cli.js +97 -17
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +11 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.d.ts
CHANGED
|
@@ -1559,6 +1559,11 @@ declare class AlvaClient {
|
|
|
1559
1559
|
_request(method: string, path: string, options?: RequestOptions): Promise<unknown>;
|
|
1560
1560
|
}
|
|
1561
1561
|
|
|
1562
|
+
declare class CliUsageError extends Error {
|
|
1563
|
+
readonly command?: string;
|
|
1564
|
+
constructor(message: string, command?: string);
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1562
1567
|
declare const CLI_VERSION: string;
|
|
1563
1568
|
declare const DEFAULT_RUN_TIMEOUT_MS = 600000;
|
|
1564
1569
|
/**
|
|
@@ -1604,4 +1609,4 @@ declare function dispatch(client: AlvaClient, args: string[], meta?: {
|
|
|
1604
1609
|
*/
|
|
1605
1610
|
declare function stripGlobalFlags(argv: string[]): string[];
|
|
1606
1611
|
|
|
1607
|
-
export { type AlvaCliRuntimeMode, BOOLEAN_FLAGS, CLI_VERSION, DEFAULT_RUN_TIMEOUT_MS, type DispatchRuntimeDeps, dispatch, handleConfigure, isVersionOlderThan, parseFlags, stripGlobalFlags };
|
|
1612
|
+
export { type AlvaCliRuntimeMode, BOOLEAN_FLAGS, CLI_VERSION, CliUsageError, DEFAULT_RUN_TIMEOUT_MS, type DispatchRuntimeDeps, dispatch, handleConfigure, isVersionOlderThan, parseFlags, stripGlobalFlags };
|
package/dist/cli.js
CHANGED
|
@@ -7550,7 +7550,6 @@ body {
|
|
|
7550
7550
|
width: 100%;
|
|
7551
7551
|
margin: 0 auto;
|
|
7552
7552
|
padding: var(--spacing-s) var(--spacing-xxl) var(--spacing-xxxxl);
|
|
7553
|
-
/* max-width: 2048px; */
|
|
7554
7553
|
}
|
|
7555
7554
|
|
|
7556
7555
|
@media (max-width: 768px) {
|
|
@@ -13122,7 +13121,7 @@ import * as fs2 from "fs";
|
|
|
13122
13121
|
import * as os2 from "os";
|
|
13123
13122
|
import * as fsPromises2 from "fs/promises";
|
|
13124
13123
|
import { Agent, setGlobalDispatcher } from "undici";
|
|
13125
|
-
var CLI_VERSION = true ? "0.
|
|
13124
|
+
var CLI_VERSION = true ? "0.13.1" : "dev";
|
|
13126
13125
|
var DEFAULT_RUN_TIMEOUT_MS = 6e5;
|
|
13127
13126
|
var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
|
|
13128
13127
|
var configuredRunFetchTimeoutMs;
|
|
@@ -13965,26 +13964,30 @@ Required:
|
|
|
13965
13964
|
|
|
13966
13965
|
Examples:
|
|
13967
13966
|
alva remix --child-username bob --child-name my-btc --parents '[{"username":"alice","name":"btc-signals"}]'`,
|
|
13968
|
-
screenshot: `Usage: alva screenshot --url <url> --out <file> [--selector <css>] [--xpath <xpath>] [--compress] [--compress-quality <n>] [--compress-max-width <px>]
|
|
13967
|
+
screenshot: `Usage: alva screenshot --url <url> (--base64 | --out <file>) [--selector <css>] [--xpath <xpath>] [--full] [--compress] [--compress-quality <n>] [--compress-max-width <px>]
|
|
13969
13968
|
|
|
13970
|
-
Capture a screenshot of an Alva page
|
|
13971
|
-
playbook rendering before release.
|
|
13969
|
+
Capture a screenshot of an Alva page. Choose exactly one output mode.
|
|
13972
13970
|
|
|
13973
13971
|
Required:
|
|
13974
13972
|
--url <url> URL or path to capture (e.g. /playbook/alice/dashboard)
|
|
13975
|
-
|
|
13973
|
+
|
|
13974
|
+
Output (choose one):
|
|
13975
|
+
--base64 Emit the image as base64 to stdout. Compresses by
|
|
13976
|
+
default (max-width 1280, quality 70) unless --full.
|
|
13977
|
+
--out <file> Write the image to a local file.
|
|
13976
13978
|
|
|
13977
13979
|
Optional:
|
|
13978
|
-
--selector <css>
|
|
13979
|
-
--xpath <xpath>
|
|
13980
|
-
--
|
|
13981
|
-
--compress-
|
|
13980
|
+
--selector <css> Capture a specific element by CSS selector
|
|
13981
|
+
--xpath <xpath> Capture a specific element by XPath
|
|
13982
|
+
--full (--base64) Return the raw image, no default compression
|
|
13983
|
+
--compress Re-encode the image to reduce file size
|
|
13984
|
+
--compress-quality <n> Compression quality 1-100
|
|
13982
13985
|
--compress-max-width <px> Downscale to at most this width in pixels
|
|
13983
13986
|
|
|
13984
13987
|
Examples:
|
|
13985
|
-
alva screenshot --url /playbook/alice/
|
|
13986
|
-
alva screenshot --url /playbook/alice/
|
|
13987
|
-
alva screenshot --url /playbook/alice/
|
|
13988
|
+
alva screenshot --url /playbook/alice/dashboard --base64
|
|
13989
|
+
alva screenshot --url /playbook/alice/dashboard --out dashboard.png
|
|
13990
|
+
alva screenshot --url /playbook/alice/dashboard --out chart.png --selector ".chart-container"`,
|
|
13988
13991
|
portfolio: `Usage: alva portfolio <subcommand> [options]
|
|
13989
13992
|
|
|
13990
13993
|
Read-only view of connected accounts across TREX and SnapTrade.
|
|
@@ -14137,7 +14140,9 @@ var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
|
|
|
14137
14140
|
"compress",
|
|
14138
14141
|
"bypass-lint",
|
|
14139
14142
|
"no-browser",
|
|
14140
|
-
"browser"
|
|
14143
|
+
"browser",
|
|
14144
|
+
"base64",
|
|
14145
|
+
"full"
|
|
14141
14146
|
]);
|
|
14142
14147
|
function parseFlags2(argv) {
|
|
14143
14148
|
const flags = {};
|
|
@@ -14389,6 +14394,19 @@ function readLocalFileBytes(path, command, flag, deps) {
|
|
|
14389
14394
|
assertLocalFileAvailable(command, flag, deps);
|
|
14390
14395
|
return fs2.readFileSync(path);
|
|
14391
14396
|
}
|
|
14397
|
+
function sniffImageMime(bytes) {
|
|
14398
|
+
const b = bytes;
|
|
14399
|
+
if (b.length >= 4 && b[0] === 137 && b[1] === 80 && b[2] === 78 && b[3] === 71) {
|
|
14400
|
+
return "image/png";
|
|
14401
|
+
}
|
|
14402
|
+
if (b.length >= 3 && b[0] === 255 && b[1] === 216 && b[2] === 255) {
|
|
14403
|
+
return "image/jpeg";
|
|
14404
|
+
}
|
|
14405
|
+
if (b.length >= 12 && b[0] === 82 && b[1] === 73 && b[2] === 70 && b[3] === 70 && b[8] === 87 && b[9] === 69 && b[10] === 66 && b[11] === 80) {
|
|
14406
|
+
return "image/webp";
|
|
14407
|
+
}
|
|
14408
|
+
return "image/png";
|
|
14409
|
+
}
|
|
14392
14410
|
function writeLocalFileBytes(path, data, command, flag, deps) {
|
|
14393
14411
|
assertLocalFileAvailable(command, flag, deps);
|
|
14394
14412
|
fs2.writeFileSync(path, data);
|
|
@@ -15393,14 +15411,70 @@ async function dispatch(client, args, meta, deps) {
|
|
|
15393
15411
|
);
|
|
15394
15412
|
}
|
|
15395
15413
|
case "screenshot": {
|
|
15414
|
+
const hasOut = flags["out"] !== void 0;
|
|
15415
|
+
const wantBase64 = boolFlag(flags["base64"]) === true;
|
|
15416
|
+
if (hasOut && wantBase64) {
|
|
15417
|
+
throw new CliUsageError(
|
|
15418
|
+
"screenshot accepts only one of --out (local file) or --base64 (stdout); both were provided.",
|
|
15419
|
+
"screenshot"
|
|
15420
|
+
);
|
|
15421
|
+
}
|
|
15422
|
+
if (!hasOut && !wantBase64) {
|
|
15423
|
+
throw new CliUsageError(
|
|
15424
|
+
"one of --out/--base64 is required for screenshot",
|
|
15425
|
+
"screenshot"
|
|
15426
|
+
);
|
|
15427
|
+
}
|
|
15428
|
+
const url = requireFlag(flags, "url", "screenshot");
|
|
15429
|
+
const selector = flags["selector"];
|
|
15430
|
+
const xpath = flags["xpath"];
|
|
15431
|
+
if (wantBase64) {
|
|
15432
|
+
const full = boolFlag(flags["full"]) === true;
|
|
15433
|
+
const explicitQuality = flags["compress-quality"];
|
|
15434
|
+
const explicitMaxWidth = flags["compress-max-width"];
|
|
15435
|
+
const noCompress = full || boolFlag(flags["compress"]) === false;
|
|
15436
|
+
let compress;
|
|
15437
|
+
let compressQuality2;
|
|
15438
|
+
let compressMaxWidth2;
|
|
15439
|
+
if (noCompress) {
|
|
15440
|
+
compress = false;
|
|
15441
|
+
compressQuality2 = void 0;
|
|
15442
|
+
compressMaxWidth2 = void 0;
|
|
15443
|
+
} else {
|
|
15444
|
+
compress = true;
|
|
15445
|
+
compressQuality2 = explicitQuality !== void 0 ? Number(explicitQuality) : 70;
|
|
15446
|
+
compressMaxWidth2 = explicitMaxWidth !== void 0 ? Number(explicitMaxWidth) : 1280;
|
|
15447
|
+
}
|
|
15448
|
+
const result2 = await client.screenshot.capture({
|
|
15449
|
+
url,
|
|
15450
|
+
selector,
|
|
15451
|
+
xpath,
|
|
15452
|
+
compress,
|
|
15453
|
+
compressQuality: compressQuality2,
|
|
15454
|
+
compressMaxWidth: compressMaxWidth2
|
|
15455
|
+
});
|
|
15456
|
+
const buf2 = Buffer.from(result2);
|
|
15457
|
+
if (buf2.length === 0) {
|
|
15458
|
+
throw new CliUsageError(
|
|
15459
|
+
"Screenshot service returned empty response (0 bytes). The service may be overloaded \u2014 retry in a few seconds.",
|
|
15460
|
+
"screenshot"
|
|
15461
|
+
);
|
|
15462
|
+
}
|
|
15463
|
+
return {
|
|
15464
|
+
_image: true,
|
|
15465
|
+
mimeType: sniffImageMime(buf2),
|
|
15466
|
+
data: Buffer.from(buf2).toString("base64"),
|
|
15467
|
+
bytes: buf2.length
|
|
15468
|
+
};
|
|
15469
|
+
}
|
|
15396
15470
|
const outFile = requireFlag(flags, "out", "screenshot");
|
|
15397
15471
|
assertLocalFileAvailable("screenshot", "out", deps);
|
|
15398
15472
|
const compressQuality = flags["compress-quality"];
|
|
15399
15473
|
const compressMaxWidth = flags["compress-max-width"];
|
|
15400
15474
|
const result = await client.screenshot.capture({
|
|
15401
|
-
url
|
|
15402
|
-
selector
|
|
15403
|
-
xpath
|
|
15475
|
+
url,
|
|
15476
|
+
selector,
|
|
15477
|
+
xpath,
|
|
15404
15478
|
compress: boolFlag(flags["compress"]),
|
|
15405
15479
|
compressQuality: compressQuality !== void 0 ? Number(compressQuality) : void 0,
|
|
15406
15480
|
compressMaxWidth: compressMaxWidth !== void 0 ? Number(compressMaxWidth) : void 0
|
|
@@ -15667,6 +15741,11 @@ async function main() {
|
|
|
15667
15741
|
process.stdout.write(helpResult.text + "\n");
|
|
15668
15742
|
return;
|
|
15669
15743
|
}
|
|
15744
|
+
if (result && typeof result === "object" && result._image === true && typeof result.data === "string") {
|
|
15745
|
+
const imageResult = result;
|
|
15746
|
+
process.stdout.write(imageResult.data + "\n");
|
|
15747
|
+
return;
|
|
15748
|
+
}
|
|
15670
15749
|
if (result instanceof ArrayBuffer) {
|
|
15671
15750
|
process.stdout.write(Buffer.from(result));
|
|
15672
15751
|
return;
|
|
@@ -15712,6 +15791,7 @@ if (isDirectRun) {
|
|
|
15712
15791
|
export {
|
|
15713
15792
|
BOOLEAN_FLAGS,
|
|
15714
15793
|
CLI_VERSION,
|
|
15794
|
+
CliUsageError,
|
|
15715
15795
|
DEFAULT_RUN_TIMEOUT_MS,
|
|
15716
15796
|
dispatch,
|
|
15717
15797
|
handleConfigure,
|