@ai-digital-factory/lmt-web-cli 0.1.0 → 0.1.2
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 +64 -1
- package/dist/index.js +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,6 +5,67 @@ browser interaction with the configured local or dev Live Market Terminal Web UR
|
|
|
5
5
|
keeps browser dependencies and session lifetime out of the browser-free `lmt`
|
|
6
6
|
HTTP CLI.
|
|
7
7
|
|
|
8
|
+
## Agent guide (Dev only)
|
|
9
|
+
|
|
10
|
+
Agents working with a deployed Live Market Terminal must use the **Dev** environment.
|
|
11
|
+
Do not target production. The examples here use the published CLI through `npx` and
|
|
12
|
+
open a headless desktop browser by default.
|
|
13
|
+
|
|
14
|
+
Install Chromium once on the machine that will own the browser session:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npx --yes @ai-digital-factory/lmt-web-cli@latest install-browser
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
If Operator login needs the Gate Operator Directory, provision this CLI's SMS read
|
|
21
|
+
credential once from a secure input source. The Web CLI keeps its credential
|
|
22
|
+
separately from `lmt-cli` and does not use profiles:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npx --yes @ai-digital-factory/lmt-web-cli@latest credential provision --env dev --credential-stdin
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Start a fresh desktop session against Dev and keep the returned `sessionId` for every
|
|
29
|
+
later command:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
npx --yes @ai-digital-factory/lmt-web-cli@latest start --env dev --device desktop
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The session starts on the Home Page. Use the same session to log into the Operator;
|
|
36
|
+
if a Zerodha login is required, start that flow and submit the current OTP through
|
|
37
|
+
standard input only, using the `attemptId` returned by `zerodha-login`:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npx --yes @ai-digital-factory/lmt-web-cli@latest operator-login --session SESSION_ID
|
|
41
|
+
npx --yes @ai-digital-factory/lmt-web-cli@latest zerodha-login --session SESSION_ID
|
|
42
|
+
npx --yes @ai-digital-factory/lmt-web-cli@latest zerodha-otp --session SESSION_ID --attempt ATTEMPT_ID --stdin
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The user supplies the OTP for the active attempt. Never put it in a command-line
|
|
46
|
+
argument or ask the CLI to retrieve it. Inspect the latest JSON result after each
|
|
47
|
+
command. Control references are short-lived: every new observation or action returns
|
|
48
|
+
fresh references, so use only references from the most recent result.
|
|
49
|
+
|
|
50
|
+
For example, to add an instrument to Market Watch, inspect the page, select `NSE`
|
|
51
|
+
in an empty row, enter the symbol, then apply that row. Use the current row's control
|
|
52
|
+
references from each immediately preceding result. `Apply` configures the Market
|
|
53
|
+
Watch row; it does not submit a trade.
|
|
54
|
+
|
|
55
|
+
Each command returns JSON with the page state and screenshot path. Review the result
|
|
56
|
+
before continuing, especially if an action is `uncertain`; inspect the page instead
|
|
57
|
+
of repeating that action automatically. When finished, stop only the session you
|
|
58
|
+
started:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
npx --yes @ai-digital-factory/lmt-web-cli@latest stop --session SESSION_ID
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Stopping releases the browser process but does not log out the Operator or stop
|
|
65
|
+
Broker activity. The CLI also supports `inspect`, `click`, `fill`, `select`, and
|
|
66
|
+
`navigate`; run `npx --yes @ai-digital-factory/lmt-web-cli@latest --help` for the
|
|
67
|
+
complete command list.
|
|
68
|
+
|
|
8
69
|
## Install
|
|
9
70
|
|
|
10
71
|
Requires Node.js 22 or later, Chromium, and a macOS or Linux session owner.
|
|
@@ -83,7 +144,9 @@ are written to unique absolute paths in an owner-only temporary directory;
|
|
|
83
144
|
screenshots preserve the rendered page without added blur or masking. Field values
|
|
84
145
|
are omitted from JSON observations. Captures wait for document loading, visible
|
|
85
146
|
session-loading or busy indicators, fonts, visible images, and finite animations
|
|
86
|
-
to finish.
|
|
147
|
+
to finish. The page must render text, controls, or visual content; an empty app
|
|
148
|
+
root is not ready. Pages that remain empty reach the command deadline without a
|
|
149
|
+
captured screenshot. Infinite animations do not block capture. `--timeout` sets one deadline for the command's browser action and
|
|
87
150
|
screenshot, from `1ms` through `10m`. If an operation exceeds it, the session is
|
|
88
151
|
closed. Action failures return nonzero; invalid commands and targets return exit code 2.
|
|
89
152
|
The JSON `error.code` is machine-readable:
|
package/dist/index.js
CHANGED
|
@@ -1854,7 +1854,10 @@ async function waitForRenderedPage(page) {
|
|
|
1854
1854
|
(animation) => (animation.pending || animation.playState === "running") && Number.isFinite(Number(animation.effect?.getComputedTiming().endTime))
|
|
1855
1855
|
);
|
|
1856
1856
|
const imagesPending = Array.from(document.images).some((image) => visible(image) && !image.complete);
|
|
1857
|
-
|
|
1857
|
+
const hasContent = !!document.body?.innerText.trim() || Array.from(
|
|
1858
|
+
document.querySelectorAll('button, a[href], input:not([type="hidden"]), select, textarea, canvas, svg, img, video, iframe')
|
|
1859
|
+
).some(visible);
|
|
1860
|
+
return document.readyState === "complete" && document.fonts.status === "loaded" && hasContent && !loading && !animating && !imagesPending;
|
|
1858
1861
|
});
|
|
1859
1862
|
if (ready && settled) return;
|
|
1860
1863
|
settled = ready;
|