@rynx-ai/cli 0.1.10 → 0.1.11-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-runtime.d.ts +10 -0
- package/dist/app-runtime.js +34 -0
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/commands/app-distribution.d.ts +2 -2
- package/dist/commands/app-distribution.js +2 -6
- package/dist/commands/browser.js +9 -5
- package/dist/commands/index.d.ts +3 -1
- package/dist/commands/index.js +3 -1
- package/dist/commands/lifecycle.d.ts +1 -0
- package/dist/commands/lifecycle.js +21 -0
- package/dist/commands/market.d.ts +1 -0
- package/dist/commands/market.js +71 -0
- package/dist/commands/plugin.js +37 -93
- package/dist/commands/session.d.ts +1 -0
- package/dist/commands/session.js +38 -0
- package/dist/commands/setup.d.ts +2 -0
- package/dist/commands/setup.js +339 -0
- package/dist/commands/skills.d.ts +6 -4
- package/dist/commands/skills.js +41 -28
- package/dist/commands/update.d.ts +20 -0
- package/dist/commands/update.js +234 -0
- package/dist/control-client.d.ts +7 -14
- package/dist/control-client.js +32 -54
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/run-cli.js +41 -12
- package/dist/standalone.d.ts +13 -0
- package/dist/standalone.js +54 -0
- package/dist/usage.d.ts +1 -1
- package/dist/usage.js +27 -16
- package/package.json +20 -6
- package/skill-guides/browser.md +72 -0
- package/skill-guides/emulator.md +79 -0
- package/skills/rynx-cli/SKILL.md +19 -87
- package/dist/legacy-adapter.d.ts +0 -7
- package/dist/legacy-adapter.js +0 -63
package/dist/usage.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
export const USAGE = `Usage: rynx <command>
|
|
2
2
|
|
|
3
3
|
General:
|
|
4
|
-
version | --version
|
|
4
|
+
version [--json] | --version
|
|
5
|
+
print the installed Rynx version
|
|
5
6
|
|
|
6
7
|
Setup:
|
|
7
|
-
setup
|
|
8
|
+
setup [--non-interactive] [--default-runtime <codex|traex|claude>]
|
|
9
|
+
[--host <host>] [--port <port>] [--log-level <level>]
|
|
10
|
+
[--install-browser|--skip-browser] [--json]
|
|
11
|
+
initialize configuration and local dependencies
|
|
8
12
|
doctor read-only health check
|
|
9
13
|
|
|
10
14
|
Lifecycle:
|
|
@@ -12,11 +16,15 @@ Lifecycle:
|
|
|
12
16
|
update [version] [--check] [--json]
|
|
13
17
|
|
|
14
18
|
Plugins:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
plugin
|
|
19
|
+
market list
|
|
20
|
+
market add <git-or-local-source> [--alias <id>]
|
|
21
|
+
market refresh [market-id]
|
|
22
|
+
market remove <market-id>
|
|
23
|
+
plugin list
|
|
24
|
+
plugin install <source|plugin@market> [--force] [--expect-digest <sha256-...>]
|
|
25
|
+
plugin update <plugin@market> [--expect-digest <sha256-...>]
|
|
26
|
+
plugin enable|disable|uninstall <plugin@market>
|
|
27
|
+
plugin <plugin@market> <command> invoke a plugin-owned command
|
|
20
28
|
|
|
21
29
|
Agents:
|
|
22
30
|
agent list
|
|
@@ -26,7 +34,7 @@ Agents:
|
|
|
26
34
|
|
|
27
35
|
Builtin Skills:
|
|
28
36
|
skills list [--json]
|
|
29
|
-
skills get <
|
|
37
|
+
skills get <browser|emulator> [--full] [--json]
|
|
30
38
|
|
|
31
39
|
Maintenance:
|
|
32
40
|
cleanup sessions [--dry-run]
|
|
@@ -43,14 +51,17 @@ Remote Runtime:
|
|
|
43
51
|
runtime clients list [--json]
|
|
44
52
|
runtime clients revoke <grant-id>
|
|
45
53
|
|
|
54
|
+
Sessions:
|
|
55
|
+
session fork <session-id> [--title <title>] [--json]
|
|
56
|
+
|
|
46
57
|
Browser:
|
|
47
58
|
browser install|update|version|clean [...]
|
|
48
|
-
browser open [url] --session <id> [--runtime <local|daemon-id>] [--json]
|
|
49
|
-
browser status|pages|close --session <id> [--runtime <local|daemon-id>] [--json]
|
|
50
|
-
browser endpoint [--ensure] --session <local-id> [--json]
|
|
51
|
-
browser snapshot --session <local-id> [--json]
|
|
52
|
-
browser navigate <url> --session <local-id> [--json]
|
|
53
|
-
browser click (--ref <ref>|--selector <css>|--x <n> --y <n>) --session <local-id> [--json]
|
|
54
|
-
browser type (--ref <ref>|--selector <css>) --text <text> --session <local-id> [--json]
|
|
55
|
-
browser screenshot --output <absolute-path> --session <local-id> [--json]
|
|
59
|
+
browser open [url] [--session <id>] [--runtime <local|daemon-id>] [--json]
|
|
60
|
+
browser status|pages|close [--session <id>] [--runtime <local|daemon-id>] [--json]
|
|
61
|
+
browser endpoint [--ensure] [--session <local-id>] [--json]
|
|
62
|
+
browser snapshot [--session <local-id>] [--json]
|
|
63
|
+
browser navigate <url> [--session <local-id>] [--json]
|
|
64
|
+
browser click (--ref <ref>|--selector <css>|--x <n> --y <n>) [--session <local-id>] [--json]
|
|
65
|
+
browser type (--ref <ref>|--selector <css>) --text <text> [--session <local-id>] [--json]
|
|
66
|
+
browser screenshot --output <absolute-path> [--session <local-id>] [--json]
|
|
56
67
|
`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rynx-ai/cli",
|
|
3
|
-
"version": "0.1.10",
|
|
3
|
+
"version": "0.1.11-beta.10",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/rynx-ai/rynx.git",
|
|
@@ -9,13 +9,17 @@
|
|
|
9
9
|
"description": "Rynx command-line client and local control-plane management surface.",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"type": "module",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=22"
|
|
14
|
+
},
|
|
12
15
|
"publishConfig": {
|
|
13
16
|
"registry": "https://registry.npmjs.org/",
|
|
14
17
|
"access": "public"
|
|
15
18
|
},
|
|
16
19
|
"files": [
|
|
17
20
|
"dist",
|
|
18
|
-
"skills"
|
|
21
|
+
"skills",
|
|
22
|
+
"skill-guides"
|
|
19
23
|
],
|
|
20
24
|
"bin": {
|
|
21
25
|
"rynx": "./dist/cli.js"
|
|
@@ -34,14 +38,24 @@
|
|
|
34
38
|
"./commands": {
|
|
35
39
|
"types": "./dist/commands/index.d.ts",
|
|
36
40
|
"default": "./dist/commands/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./standalone": {
|
|
43
|
+
"types": "./dist/standalone.d.ts",
|
|
44
|
+
"default": "./dist/standalone.js"
|
|
45
|
+
},
|
|
46
|
+
"./app-runtime": {
|
|
47
|
+
"types": "./dist/app-runtime.d.ts",
|
|
48
|
+
"default": "./dist/app-runtime.js"
|
|
37
49
|
}
|
|
38
50
|
},
|
|
39
51
|
"dependencies": {
|
|
52
|
+
"@clack/prompts": "^1.6.0",
|
|
40
53
|
"ws": "^8.21.0",
|
|
41
|
-
"@rynx-ai/
|
|
42
|
-
"@rynx-ai/
|
|
43
|
-
"@rynx-ai/
|
|
44
|
-
"@rynx-ai/
|
|
54
|
+
"@rynx-ai/browser-cdp": "0.1.11-beta.10",
|
|
55
|
+
"@rynx-ai/core": "0.1.11-beta.10",
|
|
56
|
+
"@rynx-ai/daemon": "0.1.11-beta.10",
|
|
57
|
+
"@rynx-ai/emulator": "0.1.11-beta.10",
|
|
58
|
+
"@rynx-ai/protocol": "0.1.11-beta.10"
|
|
45
59
|
},
|
|
46
60
|
"devDependencies": {
|
|
47
61
|
"@types/ws": "^8.18.1"
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: browser
|
|
3
|
+
description: Use the bundled Rynx CLI to inspect and automate the Browser owned by the active Rynx Session with snapshots, accessibility refs, navigation, clicks, typing, screenshots, page inspection, and safe failure handling.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Rynx Browser
|
|
7
|
+
|
|
8
|
+
Use the bundled `rynx` executable supplied by the active Rynx Session. Choose
|
|
9
|
+
that executable once and reuse it. Do not locate another installation with
|
|
10
|
+
`which`, `npx`, npm, filesystem searches, App-name guesses, or alternate paths.
|
|
11
|
+
|
|
12
|
+
The active Session already owns the resident daemon, Browser host, and Session
|
|
13
|
+
binding. Omit `--session`; the managed Session credential scopes every command
|
|
14
|
+
to the current Session. Prefer `--json`.
|
|
15
|
+
|
|
16
|
+
## Sandbox boundary
|
|
17
|
+
|
|
18
|
+
If a `rynx browser ...` command cannot connect to its local endpoint, do not
|
|
19
|
+
interpret that as a stopped daemon. Stop and ask the user to approve rerunning
|
|
20
|
+
the exact same command outside the Agent sandbox.
|
|
21
|
+
|
|
22
|
+
Do not change the command or try another executable, endpoint, port, transport,
|
|
23
|
+
installation, App, browser, or service. Do not scan `/Applications`, use `find`
|
|
24
|
+
or `mdfind`, run `open`, `open -a`, or `osascript`, inspect Preview/dev builds,
|
|
25
|
+
or launch/relaunch a Rynx App or daemon.
|
|
26
|
+
|
|
27
|
+
## Core loop
|
|
28
|
+
|
|
29
|
+
Open or navigate the Session Browser when needed:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
rynx browser open https://example.com --json
|
|
33
|
+
rynx browser navigate https://example.com/next --json
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Inspect before acting:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
rynx browser snapshot --json
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Use a returned accessibility `ref` for the next action:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
rynx browser click --ref <ref> --json
|
|
46
|
+
rynx browser type --ref <ref> --text "hello" --json
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Take a fresh snapshot after navigation or substantial DOM replacement because
|
|
50
|
+
old refs become stale. Use `--selector` only when no useful accessibility ref
|
|
51
|
+
exists. Use coordinate clicks only as a final fallback after a screenshot.
|
|
52
|
+
|
|
53
|
+
Inspect pages and save visual evidence with:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
rynx browser status --json
|
|
57
|
+
rynx browser pages --json
|
|
58
|
+
rynx browser screenshot --output /absolute/path/page.png --json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Do not request or connect to the raw CDP endpoint unless diagnosing Rynx itself.
|
|
62
|
+
Do not close a Browser generation the user still needs.
|
|
63
|
+
|
|
64
|
+
## Failure handling
|
|
65
|
+
|
|
66
|
+
- On endpoint access failure, follow **Sandbox boundary** and make no fallback
|
|
67
|
+
attempt.
|
|
68
|
+
- On `stale reference`, take a new snapshot and retry once.
|
|
69
|
+
- On `busy`, preserve the current Turn or Terminal for the user to resolve.
|
|
70
|
+
- On an unavailable capability, report the missing App integration or macOS
|
|
71
|
+
permission; do not install an unpinned replacement.
|
|
72
|
+
- Preserve structured error codes and relevant stderr when reporting failure.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: emulator
|
|
3
|
+
description: Use the bundled Rynx CLI to inspect and control the iOS Simulator, Android emulator, or adb-visible Android device bound to the active Rynx Session, including device discovery, attach, taps, typing, buttons, screenshots, rotation, launch, and gestures.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Rynx Emulator
|
|
7
|
+
|
|
8
|
+
Use the bundled `rynx` executable supplied by the active Rynx Session and run
|
|
9
|
+
Emulator operations through `rynx emulator ...`. Choose that executable once
|
|
10
|
+
and reuse it. Do not locate another CLI or call `serve-sim`, `simctl`, or `adb`
|
|
11
|
+
directly.
|
|
12
|
+
|
|
13
|
+
The active Session already owns the resident daemon and Session binding. Use the
|
|
14
|
+
Session's bound device by default. Add `--runtime <local|daemon-id>` only when
|
|
15
|
+
the user explicitly selected another paired Runtime. Prefer `--json`.
|
|
16
|
+
|
|
17
|
+
## Sandbox boundary
|
|
18
|
+
|
|
19
|
+
If a `rynx emulator ...` command cannot connect to its local endpoint, do not
|
|
20
|
+
interpret that as a stopped daemon. Stop and ask the user to approve rerunning
|
|
21
|
+
the exact same command outside the Agent sandbox.
|
|
22
|
+
|
|
23
|
+
Do not change the command or try another executable, endpoint, port, transport,
|
|
24
|
+
installation, App, or service. Do not scan `/Applications`, use `find` or
|
|
25
|
+
`mdfind`, run `open`, `open -a`, or `osascript`, inspect Preview/dev builds, or
|
|
26
|
+
launch/relaunch a Rynx App or daemon.
|
|
27
|
+
|
|
28
|
+
## Inspect and select
|
|
29
|
+
|
|
30
|
+
Inspect current state before acting:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
rynx emulator devices --json
|
|
34
|
+
rynx emulator active --json
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Attach only when no suitable device is already bound or the user asks to switch:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
rynx emulator attach <device-id-or-exact-name> --json
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Never reuse a device id, serial, or name remembered from another Session. After
|
|
44
|
+
switching or reconnecting, read `active --json` again.
|
|
45
|
+
|
|
46
|
+
## Control loop
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
rynx emulator tap <x> <y> --json
|
|
50
|
+
rynx emulator type "hello" --json
|
|
51
|
+
rynx emulator type --mode keys "hello" --json
|
|
52
|
+
rynx emulator button home --json
|
|
53
|
+
rynx emulator button backspace --json
|
|
54
|
+
rynx emulator button appswitch --json
|
|
55
|
+
rynx emulator screenshot --json
|
|
56
|
+
rynx emulator rotate portrait --json
|
|
57
|
+
rynx emulator launch <bundle-id-or-package> --json
|
|
58
|
+
rynx emulator gesture '<json-points>' --json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Coordinates are normalized `0..1` with top-left origin. Re-inspect with a
|
|
62
|
+
screenshot after every meaningful UI-changing action.
|
|
63
|
+
|
|
64
|
+
For `launch`, use an exact iOS `CFBundleIdentifier` or Android package name.
|
|
65
|
+
Never pass a display name or guess an identifier. If only a visible app name is
|
|
66
|
+
known, navigate visually and confirm with screenshots.
|
|
67
|
+
|
|
68
|
+
Do not run `exec`, `kill`, or `shutdown` as routine cleanup. Raw host commands
|
|
69
|
+
and device/process lifecycle changes require an explicit user request.
|
|
70
|
+
|
|
71
|
+
## Failure handling
|
|
72
|
+
|
|
73
|
+
- On endpoint access failure, follow **Sandbox boundary** and make no fallback
|
|
74
|
+
attempt.
|
|
75
|
+
- On a missing/stale device, refresh `devices --json` and `active --json`.
|
|
76
|
+
- On `busy`, preserve the current Turn or Terminal for the user to resolve.
|
|
77
|
+
- On an unavailable capability, report the missing integration or macOS
|
|
78
|
+
permission; do not install an unpinned replacement.
|
|
79
|
+
- Preserve structured error codes and relevant stderr when reporting failure.
|
package/skills/rynx-cli/SKILL.md
CHANGED
|
@@ -1,99 +1,31 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: rynx-cli
|
|
3
|
-
description:
|
|
3
|
+
description: Use the bundled `rynx` CLI when a task needs to inspect or automate the Browser or Emulator owned by the active Rynx Session. Load the version-matched Browser or Emulator guide from the CLI before operating it. Prefer this over direct CDP, browser drivers, `serve-sim`, `simctl`, adb, guessed ports, or guessed App installations.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Rynx CLI
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
Session
|
|
8
|
+
This file is a discovery stub, not the usage guide. Rynx injects it into an
|
|
9
|
+
active Session only so the Agent can discover the capability without carrying a
|
|
10
|
+
stale copy of the CLI command surface.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
Use the bundled `rynx` executable supplied by the Session. Do not locate or try
|
|
13
|
+
another installation with `which`, `npx`, npm, filesystem searches, App-name
|
|
14
|
+
guesses, or alternate executable paths.
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- Outside a managed Session, pass `--session <id>`.
|
|
16
|
-
- Add `--runtime <local|daemon-id>` only when the user explicitly selected a
|
|
17
|
-
different paired Runtime.
|
|
18
|
-
- Prefer `--json` for inspection and automation output.
|
|
16
|
+
Before running an operational command, load only the matching version-matched
|
|
17
|
+
guide from that exact CLI:
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
## Browser workflow
|
|
24
|
-
|
|
25
|
-
Open the Session Browser when needed:
|
|
26
|
-
|
|
27
|
-
```sh
|
|
28
|
-
rynx browser open https://example.com --json
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Inspect before acting:
|
|
32
|
-
|
|
33
|
-
```sh
|
|
34
|
-
rynx browser snapshot --json
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Use a returned `ref` for the next action. Take a fresh snapshot after navigation
|
|
38
|
-
or substantial DOM replacement because old references become stale.
|
|
39
|
-
|
|
40
|
-
```sh
|
|
41
|
-
rynx browser click --ref <ref> --json
|
|
42
|
-
rynx browser type --ref <ref> --text "hello" --json
|
|
43
|
-
rynx browser navigate https://example.com/next --json
|
|
44
|
-
rynx browser screenshot --output /absolute/path/page.png --json
|
|
19
|
+
```text
|
|
20
|
+
rynx skills get browser
|
|
21
|
+
rynx skills get emulator
|
|
45
22
|
```
|
|
46
23
|
|
|
47
|
-
Use
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Useful inspection commands:
|
|
51
|
-
|
|
52
|
-
```sh
|
|
53
|
-
rynx browser status --json
|
|
54
|
-
rynx browser pages --json
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Do not request or connect to the raw CDP endpoint unless diagnosing Rynx itself.
|
|
58
|
-
Do not close a Browser generation that the user still needs.
|
|
59
|
-
|
|
60
|
-
## Emulator workflow
|
|
61
|
-
|
|
62
|
-
Inspect available commands and devices before acting:
|
|
63
|
-
|
|
64
|
-
```sh
|
|
65
|
-
rynx emulator --help
|
|
66
|
-
rynx emulator devices
|
|
67
|
-
rynx emulator active
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Use the Session's bound device by default. Select another device or Runtime only
|
|
71
|
-
when the user asks. Re-inspect the screen after every navigation or state-changing
|
|
72
|
-
input, and never call `kill` or `shutdown` as cleanup unless requested.
|
|
73
|
-
|
|
74
|
-
## Runtime and plugin operations
|
|
75
|
-
|
|
76
|
-
List and test Runtime targets before selecting a remote target:
|
|
77
|
-
|
|
78
|
-
```sh
|
|
79
|
-
rynx runtime list --json
|
|
80
|
-
rynx runtime test <local|daemon-id> --json
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
Invoke plugin-declared commands through:
|
|
84
|
-
|
|
85
|
-
```sh
|
|
86
|
-
rynx plugin <plugin-id> <command> --json
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
Treat pairing, client revocation, plugin installation, Browser engine updates,
|
|
90
|
-
and daemon lifecycle changes as administrative operations. Perform them only
|
|
91
|
-
when the user explicitly requests them.
|
|
92
|
-
|
|
93
|
-
## Failure handling
|
|
24
|
+
Use `browser` for Browser inspection/automation and `emulator` for mobile device
|
|
25
|
+
inspection/control. Do not load an unrelated guide. These commands read guides
|
|
26
|
+
shipped in the exact CLI npm package and do not contact the daemon or network.
|
|
94
27
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
- Preserve structured error codes and relevant stderr when reporting failure.
|
|
28
|
+
If `rynx skills get <topic>` itself cannot execute, report its exact error and
|
|
29
|
+
stop. Do not scan `/Applications`, use `find` or `mdfind`, run `open`, `open -a`,
|
|
30
|
+
or `osascript`, inspect Preview/dev builds, start a daemon, guess a port, or try
|
|
31
|
+
a different Rynx App or CLI.
|
package/dist/legacy-adapter.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Temporary bridge for commands whose daemon-owned mutation has no management
|
|
3
|
-
* RPC yet. It crosses the package boundary as a subprocess, never by importing
|
|
4
|
-
* daemon implementation modules into the CLI process.
|
|
5
|
-
*/
|
|
6
|
-
export declare function runLegacyDaemonCli(args: readonly string[]): Promise<number>;
|
|
7
|
-
export declare function resolveLegacyDaemonCli(env?: NodeJS.ProcessEnv, moduleUrl?: string): string | null;
|
package/dist/legacy-adapter.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import { existsSync, realpathSync, statSync } from "node:fs";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
const LEGACY_CLI_ENV = "RYNX_LEGACY_CLI_PATH";
|
|
6
|
-
/**
|
|
7
|
-
* Temporary bridge for commands whose daemon-owned mutation has no management
|
|
8
|
-
* RPC yet. It crosses the package boundary as a subprocess, never by importing
|
|
9
|
-
* daemon implementation modules into the CLI process.
|
|
10
|
-
*/
|
|
11
|
-
export async function runLegacyDaemonCli(args) {
|
|
12
|
-
const cliPath = resolveLegacyDaemonCli();
|
|
13
|
-
if (!cliPath) {
|
|
14
|
-
throw new Error("This command still requires the legacy daemon CLI, but it is not installed. " +
|
|
15
|
-
`Set ${LEGACY_CLI_ENV} to its absolute cli.js path or use the bundled Rynx App.`);
|
|
16
|
-
}
|
|
17
|
-
return new Promise((resolve, reject) => {
|
|
18
|
-
const child = spawn(process.execPath, [cliPath, ...args], {
|
|
19
|
-
stdio: "inherit",
|
|
20
|
-
env: process.env,
|
|
21
|
-
});
|
|
22
|
-
child.once("error", (error) => {
|
|
23
|
-
reject(new Error(`failed to launch legacy daemon CLI: ${error.message}`));
|
|
24
|
-
});
|
|
25
|
-
child.once("exit", (code, signal) => {
|
|
26
|
-
if (signal) {
|
|
27
|
-
reject(new Error(`legacy daemon CLI exited with signal ${signal}`));
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
resolve(code ?? 1);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
export function resolveLegacyDaemonCli(env = process.env, moduleUrl = import.meta.url) {
|
|
35
|
-
const configured = env[LEGACY_CLI_ENV];
|
|
36
|
-
if (configured !== undefined) {
|
|
37
|
-
if (!path.isAbsolute(configured)) {
|
|
38
|
-
throw new Error(`${LEGACY_CLI_ENV} must be an absolute path`);
|
|
39
|
-
}
|
|
40
|
-
return validateCliFile(configured);
|
|
41
|
-
}
|
|
42
|
-
// Works both in the workspace and when @rynx-ai/cli and @rynx-ai/daemon are
|
|
43
|
-
// siblings under node_modules/@rynx-ai.
|
|
44
|
-
const sibling = fileURLToPath(new URL("../../daemon/dist/cli.js", moduleUrl));
|
|
45
|
-
return validateCliFile(sibling);
|
|
46
|
-
}
|
|
47
|
-
function validateCliFile(candidate) {
|
|
48
|
-
try {
|
|
49
|
-
if (!existsSync(candidate) || !statSync(candidate).isFile())
|
|
50
|
-
return null;
|
|
51
|
-
const resolved = realpathSync(candidate);
|
|
52
|
-
const current = process.argv[1];
|
|
53
|
-
if (current &&
|
|
54
|
-
existsSync(current) &&
|
|
55
|
-
realpathSync(current) === resolved) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
return resolved;
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
}
|