muse-cli 0.3.8__tar.gz → 0.3.9__tar.gz
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.
- {muse_cli-0.3.8 → muse_cli-0.3.9}/PKG-INFO +64 -37
- {muse_cli-0.3.8 → muse_cli-0.3.9}/README.md +63 -36
- {muse_cli-0.3.8 → muse_cli-0.3.9}/docs/PROTOCOL.md +26 -6
- {muse_cli-0.3.8 → muse_cli-0.3.9}/skills/muse-cli/SKILL.md +47 -19
- {muse_cli-0.3.8 → muse_cli-0.3.9}/src/muse_cli/__init__.py +1 -1
- muse_cli-0.3.9/src/muse_cli/browsers.py +196 -0
- {muse_cli-0.3.8 → muse_cli-0.3.9}/src/muse_cli/cli.py +73 -25
- {muse_cli-0.3.8 → muse_cli-0.3.9}/.gitignore +0 -0
- {muse_cli-0.3.8 → muse_cli-0.3.9}/LICENSE +0 -0
- {muse_cli-0.3.8 → muse_cli-0.3.9}/pyproject.toml +0 -0
- {muse_cli-0.3.8 → muse_cli-0.3.9}/src/muse_cli/__main__.py +0 -0
- {muse_cli-0.3.8 → muse_cli-0.3.9}/src/muse_cli/chat.py +0 -0
- {muse_cli-0.3.8 → muse_cli-0.3.9}/src/muse_cli/desc0.bin +0 -0
- {muse_cli-0.3.8 → muse_cli-0.3.9}/src/muse_cli/desc1.bin +0 -0
- {muse_cli-0.3.8 → muse_cli-0.3.9}/src/muse_cli/gateway.py +0 -0
- {muse_cli-0.3.8 → muse_cli-0.3.9}/src/muse_cli/routes.json +0 -0
- {muse_cli-0.3.8 → muse_cli-0.3.9}/src/muse_cli/skill.py +0 -0
- {muse_cli-0.3.8 → muse_cli-0.3.9}/src/muse_cli/update.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: muse-cli
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.9
|
|
4
4
|
Summary: Command-line client for your personal muse.ai AI agent: chat, automate, and manage side chats, feed, goals, ideas, and sessions from the terminal. No browser needed.
|
|
5
5
|
Project-URL: Homepage, https://github.com/nikships/muse-cli
|
|
6
6
|
Project-URL: Documentation, https://github.com/nikships/muse-cli#readme
|
|
@@ -86,24 +86,61 @@ curl -fsSL https://raw.githubusercontent.com/nikships/muse-cli/main/install.sh |
|
|
|
86
86
|
|
|
87
87
|
Upgrade with `muse-cli update`. It also refreshes the agent skill if you installed one (the skill ships inside the package, so it always matches the CLI). `muse-cli update --skill` refreshes or installs just the skill, with no package upgrade, which is handy after `pip` or `pipx` installs. In a terminal it also checks PyPI once a day and, when a newer release exists, prints that command on stderr. It does not upgrade itself. Set `MUSE_NO_UPDATE_CHECK=1` to silence the notice. The check stays quiet when output is piped or `CI` is set. Remove with `uv tool uninstall muse-cli`.
|
|
88
88
|
|
|
89
|
-
Logging in is a separate one-time step.
|
|
90
|
-
|
|
91
|
-
any other command.
|
|
89
|
+
Logging in is a separate one-time step. On a Mac it is one command, run after
|
|
90
|
+
you have logged in at https://muse.ai/ in your browser. Follow
|
|
91
|
+
[Log in once](#log-in-once) before running any other command.
|
|
92
92
|
|
|
93
93
|
## Log in once
|
|
94
94
|
|
|
95
|
-
muse-cli borrows the login you already have in
|
|
96
|
-
to `~/.config/muse-cli/cookies.txt` (mode `600`, only your user can
|
|
97
|
-
and after that talks to muse.ai directly. Access tokens are fetched
|
|
98
|
-
on every command. When a command later says the cookies expired, repeat
|
|
99
|
-
section.
|
|
95
|
+
muse-cli borrows the login you already have in your browser, saves those
|
|
96
|
+
cookies to `~/.config/muse-cli/cookies.txt` (mode `600`, only your user can
|
|
97
|
+
read it), and after that talks to muse.ai directly. Access tokens are fetched
|
|
98
|
+
fresh on every command. When a command later says the cookies expired, repeat
|
|
99
|
+
this section.
|
|
100
100
|
|
|
101
|
+
### On a Mac (Chrome, Brave, Arc, Edge or Chromium)
|
|
102
|
+
|
|
103
|
+
1. Log in at https://muse.ai/ in your browser.
|
|
104
|
+
2. Run:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
muse-cli auth export
|
|
108
|
+
muse-cli status
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
macOS asks once whether `security` may use the browser's **Safe Storage** key
|
|
112
|
+
(that key decrypts the browser's cookie file). Click **Allow**, or **Always
|
|
113
|
+
Allow** to skip the prompt next time. No Node.js and no debugging port are
|
|
114
|
+
needed, and the browser can be closed.
|
|
115
|
+
|
|
116
|
+
Success looks like this (the count varies):
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
saved 9 muse.ai cookies to /Users/you/.config/muse-cli/cookies.txt (from chrome (Default))
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
It reads every profile of every supported browser and uses the one that is
|
|
123
|
+
logged in to muse.ai. Pick one with `--browser chrome|brave|arc|edge|chromium`.
|
|
124
|
+
Unreadable profiles are skipped if another profile has a usable login.
|
|
125
|
+
Only cookies valid for `muse.ai` are exported, not subdomain-only cookies.
|
|
126
|
+
Expired cookies are ignored, and an empty or expired `hatch_sess` never
|
|
127
|
+
replaces your saved login. If the cookie database keeps changing during the
|
|
128
|
+
read, close the browser and retry.
|
|
129
|
+
If nothing is logged in, the command says so and leaves the cookies file on
|
|
130
|
+
disk as it was. `muse-cli status` then prints JSON with your VM id, how many
|
|
131
|
+
chats you have, the unread count, and your identity. That means install and
|
|
132
|
+
login both worked.
|
|
133
|
+
|
|
134
|
+
### Linux, Windows, or Safari: agent-browser or by hand
|
|
135
|
+
|
|
136
|
+
Direct reading is macOS-only and covers Chromium browsers, not Safari.
|
|
137
|
+
Elsewhere (or with `muse-cli auth export --browser agent-browser`) the login
|
|
138
|
+
is read from a running Google Chrome through [agent-browser](https://github.com/vercel-labs/agent-browser).
|
|
101
139
|
Do the steps in order. Each one checks itself before you continue.
|
|
102
140
|
|
|
103
|
-
|
|
141
|
+
#### 1. Install the cookie reader
|
|
104
142
|
|
|
105
|
-
|
|
106
|
-
to read Chrome's cookies. That package comes from npm, so you need Node.js first.
|
|
143
|
+
That package comes from npm, so you need Node.js first.
|
|
107
144
|
|
|
108
145
|
```bash
|
|
109
146
|
node --version # if this fails, install Node.js LTS from https://nodejs.org
|
|
@@ -118,7 +155,7 @@ errors with `EACCES`, pick one and use it from then on: configure an
|
|
|
118
155
|
or run the install with the same rights you use for other global npm tools.
|
|
119
156
|
Then check `command -v agent-browser` prints a path.
|
|
120
157
|
|
|
121
|
-
|
|
158
|
+
#### 2. Let Chrome share cookies
|
|
122
159
|
|
|
123
160
|
Open **Google Chrome**, the same profile you use for muse.ai. Paste this in
|
|
124
161
|
the address bar:
|
|
@@ -138,26 +175,21 @@ Stay in this window. Starting a second Chrome with
|
|
|
138
175
|
`--remote-debugging-port` opens a different profile, and that profile does
|
|
139
176
|
not have your muse.ai login.
|
|
140
177
|
|
|
141
|
-
|
|
178
|
+
#### 3. Be logged in, on a muse.ai tab
|
|
142
179
|
|
|
143
180
|
In that same Chrome window, open https://muse.ai/ and log in. Leave the tab
|
|
144
181
|
open. The exporter reads whichever tab is active, so the muse.ai tab has to
|
|
145
182
|
be the one in front when you run the next command.
|
|
146
183
|
|
|
147
|
-
|
|
184
|
+
#### 4. Save the login
|
|
148
185
|
|
|
149
186
|
```bash
|
|
150
|
-
muse-cli auth export
|
|
187
|
+
muse-cli auth export --browser agent-browser
|
|
151
188
|
```
|
|
152
189
|
|
|
153
190
|
Chrome may ask to allow the debugging connection. Click **Allow**. If the
|
|
154
|
-
command already failed, run it again after you click Allow.
|
|
155
|
-
|
|
156
|
-
Success looks like this (the count varies):
|
|
157
|
-
|
|
158
|
-
```
|
|
159
|
-
saved 12 muse.ai cookies to /home/you/.config/muse-cli/cookies.txt
|
|
160
|
-
```
|
|
191
|
+
command already failed, run it again after you click Allow. Then run
|
|
192
|
+
`muse-cli status` to check the connection.
|
|
161
193
|
|
|
162
194
|
The command prints the fix on the failure itself. These are the ones it
|
|
163
195
|
recognizes:
|
|
@@ -168,16 +200,7 @@ recognizes:
|
|
|
168
200
|
| No muse.ai tab | Step 3. Open https://muse.ai/ in that same window and leave the tab open. |
|
|
169
201
|
| No `hatch_sess` | The tab is open and you are logged out. Log in, then export again. The cookies file already on disk is left as it was. |
|
|
170
202
|
| `agent-browser` is not installed | Step 1. `node --version`, then `npm i -g agent-browser`, then a new terminal. |
|
|
171
|
-
| Daemon already running | A previous attempt is stuck. `agent-browser close`, then `muse-cli auth export`. |
|
|
172
|
-
|
|
173
|
-
### 5. Check the connection
|
|
174
|
-
|
|
175
|
-
```bash
|
|
176
|
-
muse-cli status
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
You get JSON with your VM id, how many chats you have, the unread count, and
|
|
180
|
-
your identity. That means install and login both worked.
|
|
203
|
+
| Daemon already running | A previous attempt is stuck. `agent-browser close`, then `muse-cli auth export --browser agent-browser`. |
|
|
181
204
|
|
|
182
205
|
### Copy cookies by hand
|
|
183
206
|
|
|
@@ -198,6 +221,7 @@ muse-cli status
|
|
|
198
221
|
|
|
199
222
|
```bash
|
|
200
223
|
muse-cli # interactive chat (same as `muse-cli chat`)
|
|
224
|
+
muse-cli auth export --browser auto # import the browser login (macOS: direct read)
|
|
201
225
|
muse-cli threads # main chat + side chats
|
|
202
226
|
muse-cli history --limit 5 # recent messages
|
|
203
227
|
muse-cli history --thread <session-id> --limit 5 # one side chat
|
|
@@ -276,6 +300,7 @@ skills/muse-cli/ agent skill
|
|
|
276
300
|
src/muse_cli/
|
|
277
301
|
cli.py argument parsing and all commands
|
|
278
302
|
chat.py interactive chat (the default command)
|
|
303
|
+
browsers.py reads the muse.ai login from Chromium browsers on macOS
|
|
279
304
|
gateway.py gateway client (auth, Noise transport, subscriptions)
|
|
280
305
|
update.py daily update notice and `muse-cli update`
|
|
281
306
|
skill.py installs and refreshes the bundled agent skill
|
|
@@ -295,10 +320,12 @@ release flow and contributor notes. Merging to `main` publishes a release.
|
|
|
295
320
|
- Login is the [Log in once](#log-in-once) section above. Cookies live at
|
|
296
321
|
`~/.config/muse-cli/cookies.txt` (mode 600). Access and gateway tokens are
|
|
297
322
|
fetched fresh on every run.
|
|
298
|
-
- `auth export`
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
(
|
|
323
|
+
- On macOS, `auth export` decrypts the muse.ai cookies from the browser's own
|
|
324
|
+
cookie file, using the browser's Safe Storage key from your login keychain.
|
|
325
|
+
Elsewhere it reads Google Chrome through
|
|
326
|
+
[agent-browser](https://github.com/vercel-labs/agent-browser), which needs
|
|
327
|
+
Chrome open with remote debugging on (`chrome://inspect/#remote-debugging`)
|
|
328
|
+
and a logged-in muse.ai tab in front.
|
|
302
329
|
- Respect muse.ai's terms and rate limits. Internal APIs are unversioned and
|
|
303
330
|
can change; if calls fail, re-derive from a fresh app bundle.
|
|
304
331
|
|
|
@@ -49,24 +49,61 @@ curl -fsSL https://raw.githubusercontent.com/nikships/muse-cli/main/install.sh |
|
|
|
49
49
|
|
|
50
50
|
Upgrade with `muse-cli update`. It also refreshes the agent skill if you installed one (the skill ships inside the package, so it always matches the CLI). `muse-cli update --skill` refreshes or installs just the skill, with no package upgrade, which is handy after `pip` or `pipx` installs. In a terminal it also checks PyPI once a day and, when a newer release exists, prints that command on stderr. It does not upgrade itself. Set `MUSE_NO_UPDATE_CHECK=1` to silence the notice. The check stays quiet when output is piped or `CI` is set. Remove with `uv tool uninstall muse-cli`.
|
|
51
51
|
|
|
52
|
-
Logging in is a separate one-time step.
|
|
53
|
-
|
|
54
|
-
any other command.
|
|
52
|
+
Logging in is a separate one-time step. On a Mac it is one command, run after
|
|
53
|
+
you have logged in at https://muse.ai/ in your browser. Follow
|
|
54
|
+
[Log in once](#log-in-once) before running any other command.
|
|
55
55
|
|
|
56
56
|
## Log in once
|
|
57
57
|
|
|
58
|
-
muse-cli borrows the login you already have in
|
|
59
|
-
to `~/.config/muse-cli/cookies.txt` (mode `600`, only your user can
|
|
60
|
-
and after that talks to muse.ai directly. Access tokens are fetched
|
|
61
|
-
on every command. When a command later says the cookies expired, repeat
|
|
62
|
-
section.
|
|
58
|
+
muse-cli borrows the login you already have in your browser, saves those
|
|
59
|
+
cookies to `~/.config/muse-cli/cookies.txt` (mode `600`, only your user can
|
|
60
|
+
read it), and after that talks to muse.ai directly. Access tokens are fetched
|
|
61
|
+
fresh on every command. When a command later says the cookies expired, repeat
|
|
62
|
+
this section.
|
|
63
63
|
|
|
64
|
+
### On a Mac (Chrome, Brave, Arc, Edge or Chromium)
|
|
65
|
+
|
|
66
|
+
1. Log in at https://muse.ai/ in your browser.
|
|
67
|
+
2. Run:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
muse-cli auth export
|
|
71
|
+
muse-cli status
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
macOS asks once whether `security` may use the browser's **Safe Storage** key
|
|
75
|
+
(that key decrypts the browser's cookie file). Click **Allow**, or **Always
|
|
76
|
+
Allow** to skip the prompt next time. No Node.js and no debugging port are
|
|
77
|
+
needed, and the browser can be closed.
|
|
78
|
+
|
|
79
|
+
Success looks like this (the count varies):
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
saved 9 muse.ai cookies to /Users/you/.config/muse-cli/cookies.txt (from chrome (Default))
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
It reads every profile of every supported browser and uses the one that is
|
|
86
|
+
logged in to muse.ai. Pick one with `--browser chrome|brave|arc|edge|chromium`.
|
|
87
|
+
Unreadable profiles are skipped if another profile has a usable login.
|
|
88
|
+
Only cookies valid for `muse.ai` are exported, not subdomain-only cookies.
|
|
89
|
+
Expired cookies are ignored, and an empty or expired `hatch_sess` never
|
|
90
|
+
replaces your saved login. If the cookie database keeps changing during the
|
|
91
|
+
read, close the browser and retry.
|
|
92
|
+
If nothing is logged in, the command says so and leaves the cookies file on
|
|
93
|
+
disk as it was. `muse-cli status` then prints JSON with your VM id, how many
|
|
94
|
+
chats you have, the unread count, and your identity. That means install and
|
|
95
|
+
login both worked.
|
|
96
|
+
|
|
97
|
+
### Linux, Windows, or Safari: agent-browser or by hand
|
|
98
|
+
|
|
99
|
+
Direct reading is macOS-only and covers Chromium browsers, not Safari.
|
|
100
|
+
Elsewhere (or with `muse-cli auth export --browser agent-browser`) the login
|
|
101
|
+
is read from a running Google Chrome through [agent-browser](https://github.com/vercel-labs/agent-browser).
|
|
64
102
|
Do the steps in order. Each one checks itself before you continue.
|
|
65
103
|
|
|
66
|
-
|
|
104
|
+
#### 1. Install the cookie reader
|
|
67
105
|
|
|
68
|
-
|
|
69
|
-
to read Chrome's cookies. That package comes from npm, so you need Node.js first.
|
|
106
|
+
That package comes from npm, so you need Node.js first.
|
|
70
107
|
|
|
71
108
|
```bash
|
|
72
109
|
node --version # if this fails, install Node.js LTS from https://nodejs.org
|
|
@@ -81,7 +118,7 @@ errors with `EACCES`, pick one and use it from then on: configure an
|
|
|
81
118
|
or run the install with the same rights you use for other global npm tools.
|
|
82
119
|
Then check `command -v agent-browser` prints a path.
|
|
83
120
|
|
|
84
|
-
|
|
121
|
+
#### 2. Let Chrome share cookies
|
|
85
122
|
|
|
86
123
|
Open **Google Chrome**, the same profile you use for muse.ai. Paste this in
|
|
87
124
|
the address bar:
|
|
@@ -101,26 +138,21 @@ Stay in this window. Starting a second Chrome with
|
|
|
101
138
|
`--remote-debugging-port` opens a different profile, and that profile does
|
|
102
139
|
not have your muse.ai login.
|
|
103
140
|
|
|
104
|
-
|
|
141
|
+
#### 3. Be logged in, on a muse.ai tab
|
|
105
142
|
|
|
106
143
|
In that same Chrome window, open https://muse.ai/ and log in. Leave the tab
|
|
107
144
|
open. The exporter reads whichever tab is active, so the muse.ai tab has to
|
|
108
145
|
be the one in front when you run the next command.
|
|
109
146
|
|
|
110
|
-
|
|
147
|
+
#### 4. Save the login
|
|
111
148
|
|
|
112
149
|
```bash
|
|
113
|
-
muse-cli auth export
|
|
150
|
+
muse-cli auth export --browser agent-browser
|
|
114
151
|
```
|
|
115
152
|
|
|
116
153
|
Chrome may ask to allow the debugging connection. Click **Allow**. If the
|
|
117
|
-
command already failed, run it again after you click Allow.
|
|
118
|
-
|
|
119
|
-
Success looks like this (the count varies):
|
|
120
|
-
|
|
121
|
-
```
|
|
122
|
-
saved 12 muse.ai cookies to /home/you/.config/muse-cli/cookies.txt
|
|
123
|
-
```
|
|
154
|
+
command already failed, run it again after you click Allow. Then run
|
|
155
|
+
`muse-cli status` to check the connection.
|
|
124
156
|
|
|
125
157
|
The command prints the fix on the failure itself. These are the ones it
|
|
126
158
|
recognizes:
|
|
@@ -131,16 +163,7 @@ recognizes:
|
|
|
131
163
|
| No muse.ai tab | Step 3. Open https://muse.ai/ in that same window and leave the tab open. |
|
|
132
164
|
| No `hatch_sess` | The tab is open and you are logged out. Log in, then export again. The cookies file already on disk is left as it was. |
|
|
133
165
|
| `agent-browser` is not installed | Step 1. `node --version`, then `npm i -g agent-browser`, then a new terminal. |
|
|
134
|
-
| Daemon already running | A previous attempt is stuck. `agent-browser close`, then `muse-cli auth export`. |
|
|
135
|
-
|
|
136
|
-
### 5. Check the connection
|
|
137
|
-
|
|
138
|
-
```bash
|
|
139
|
-
muse-cli status
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
You get JSON with your VM id, how many chats you have, the unread count, and
|
|
143
|
-
your identity. That means install and login both worked.
|
|
166
|
+
| Daemon already running | A previous attempt is stuck. `agent-browser close`, then `muse-cli auth export --browser agent-browser`. |
|
|
144
167
|
|
|
145
168
|
### Copy cookies by hand
|
|
146
169
|
|
|
@@ -161,6 +184,7 @@ muse-cli status
|
|
|
161
184
|
|
|
162
185
|
```bash
|
|
163
186
|
muse-cli # interactive chat (same as `muse-cli chat`)
|
|
187
|
+
muse-cli auth export --browser auto # import the browser login (macOS: direct read)
|
|
164
188
|
muse-cli threads # main chat + side chats
|
|
165
189
|
muse-cli history --limit 5 # recent messages
|
|
166
190
|
muse-cli history --thread <session-id> --limit 5 # one side chat
|
|
@@ -239,6 +263,7 @@ skills/muse-cli/ agent skill
|
|
|
239
263
|
src/muse_cli/
|
|
240
264
|
cli.py argument parsing and all commands
|
|
241
265
|
chat.py interactive chat (the default command)
|
|
266
|
+
browsers.py reads the muse.ai login from Chromium browsers on macOS
|
|
242
267
|
gateway.py gateway client (auth, Noise transport, subscriptions)
|
|
243
268
|
update.py daily update notice and `muse-cli update`
|
|
244
269
|
skill.py installs and refreshes the bundled agent skill
|
|
@@ -258,10 +283,12 @@ release flow and contributor notes. Merging to `main` publishes a release.
|
|
|
258
283
|
- Login is the [Log in once](#log-in-once) section above. Cookies live at
|
|
259
284
|
`~/.config/muse-cli/cookies.txt` (mode 600). Access and gateway tokens are
|
|
260
285
|
fetched fresh on every run.
|
|
261
|
-
- `auth export`
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
(
|
|
286
|
+
- On macOS, `auth export` decrypts the muse.ai cookies from the browser's own
|
|
287
|
+
cookie file, using the browser's Safe Storage key from your login keychain.
|
|
288
|
+
Elsewhere it reads Google Chrome through
|
|
289
|
+
[agent-browser](https://github.com/vercel-labs/agent-browser), which needs
|
|
290
|
+
Chrome open with remote debugging on (`chrome://inspect/#remote-debugging`)
|
|
291
|
+
and a logged-in muse.ai tab in front.
|
|
265
292
|
- Respect muse.ai's terms and rate limits. Internal APIs are unversioned and
|
|
266
293
|
can change; if calls fail, re-derive from a fresh app bundle.
|
|
267
294
|
|
|
@@ -95,9 +95,29 @@ chat / feed / goals / ideas / sessions / ...
|
|
|
95
95
|
`session_id` in the body did not move the run into that side chat; the
|
|
96
96
|
user message and the agent's reply landed in the main chat.
|
|
97
97
|
- POSTs to muse.ai need browser `Sec-Fetch-*` headers or they return 403.
|
|
98
|
-
- `auth export`
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
- `auth export` on macOS decrypts the muse.ai rows of the browser's own cookie
|
|
99
|
+
database (`~/Library/Application Support/<browser>/<profile>/{Network/,}Cookies`,
|
|
100
|
+
Chrome, Brave, Arc, Edge, Chromium). Values are `v10` + AES-128-CBC, key =
|
|
101
|
+
PBKDF2-HMAC-SHA1(password from keychain item "<Browser> Safe Storage",
|
|
102
|
+
salt `saltysalt`, 1003 rounds, 16 bytes), IV = 16 spaces. Cookie DB
|
|
103
|
+
version 24+ (Chromium 130+) prefixes the plaintext with SHA-256(host_key);
|
|
104
|
+
strip it when it matches. `expires_utc` is microseconds since 1601. The first
|
|
105
|
+
keychain read shows a macOS Allow dialog. The desktop Muse.app is not a
|
|
106
|
+
source: its OAuth tokens live in the keychain access group
|
|
107
|
+
`V9WTTPBFK9.com.meta.endo`, readable only by the app itself.
|
|
108
|
+
Copy the DB and its WAL/rollback journal together, checking their file
|
|
109
|
+
metadata before and after the copy; retry a changing store at most three
|
|
110
|
+
times. A checkpoint during copying can otherwise silently omit cookies.
|
|
111
|
+
Expired rows are ignored before keychain access, and unreadable or
|
|
112
|
+
undecryptable profiles do not block another usable profile. Cache both
|
|
113
|
+
keys and keychain failures per browser to avoid repeated prompts.
|
|
114
|
+
Select only host keys `muse.ai` and `.muse.ai`: subdomain-only cookies are
|
|
115
|
+
not valid for the CLI's requests to `https://muse.ai/api/`.
|
|
116
|
+
- Elsewhere (and with `--browser agent-browser`) `auth export` reads cookies
|
|
117
|
+
from the user's own Google Chrome through agent-browser `--auto-connect`.
|
|
118
|
+
Chrome 144+ shares that profile only after remote debugging is enabled at
|
|
119
|
+
`chrome://inspect/#remote-debugging`. That export follows the active tab, so
|
|
120
|
+
a muse.ai tab has to be focused first.
|
|
121
|
+
- Either way, `auth export` must never overwrite a working jar without a
|
|
122
|
+
non-empty, unexpired `hatch_sess` in the new one, and a freshly launched
|
|
123
|
+
browser has no login; do not fall back to one.
|
|
@@ -34,16 +34,43 @@ muse-cli --help >/dev/null && echo cli-ok # proves the install + deps resolve
|
|
|
34
34
|
## 2. Auth
|
|
35
35
|
|
|
36
36
|
The CLI stores the user's muse.ai browser login at
|
|
37
|
-
`~/.config/muse-cli/cookies.txt` (mode 0600).
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
switch is on and a logged-in muse.ai tab is open.
|
|
37
|
+
`~/.config/muse-cli/cookies.txt` (mode 0600). Access and gateway tokens are
|
|
38
|
+
fetched fresh on every run; only cookies persist. When a later command fails
|
|
39
|
+
with `auth error`, the cookies expired: repeat this step.
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
persist. When a later command fails with `auth error`, the cookies expired:
|
|
44
|
-
repeat 2b (or 2c).
|
|
41
|
+
### 2a. macOS: read the browser directly (try this first)
|
|
45
42
|
|
|
46
|
-
|
|
43
|
+
Needs no Node.js and no debugging port. The user must be logged in at
|
|
44
|
+
https://muse.ai/ in Chrome, Brave, Arc, Edge or Chromium (any profile; the
|
|
45
|
+
browser can be closed). Ask them to confirm, then:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
muse-cli auth export
|
|
49
|
+
test -s ~/.config/muse-cli/cookies.txt && echo auth-ok
|
|
50
|
+
muse-cli status
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The first run makes macOS show a dialog asking whether `security` may use the
|
|
54
|
+
browser's "Safe Storage" key. Tell the user to click **Allow** (or **Always
|
|
55
|
+
Allow**) and wait for them; do not retry in a loop while the dialog is open.
|
|
56
|
+
Success is `saved N muse.ai cookies to ... (from chrome (Default))`. The
|
|
57
|
+
cookie values are never printed; do not print the cookies file either.
|
|
58
|
+
|
|
59
|
+
- `no muse.ai login (hatch_sess) in ...`: they are not logged in in any
|
|
60
|
+
supported browser. Ask them to log in at https://muse.ai/ and rerun. The
|
|
61
|
+
cookies file on disk was kept.
|
|
62
|
+
- `could not read '... Safe Storage' from the keychain`: they denied the
|
|
63
|
+
dialog or it timed out. Rerun and have them click Allow.
|
|
64
|
+
- To target one browser: `muse-cli auth export --browser brave` (also
|
|
65
|
+
`chrome`, `arc`, `edge`, `chromium`). Safari is not supported; use 2d.
|
|
66
|
+
- Expired cookies are ignored. Empty or expired `hatch_sess` cookies never
|
|
67
|
+
replace a saved login. Unreadable profiles are skipped if another works.
|
|
68
|
+
- Only cookies valid for `muse.ai` are exported, not subdomain-only cookies.
|
|
69
|
+
- `cookie database changed while reading ...`: close that browser and rerun
|
|
70
|
+
once. The command retries a changing database at most three times.
|
|
71
|
+
- On Linux or Windows, or if the Mac route is not possible, use 2b.
|
|
72
|
+
|
|
73
|
+
### 2b. Other systems: cookie reader (agent-browser)
|
|
47
74
|
|
|
48
75
|
```bash
|
|
49
76
|
command -v node >/dev/null && node --version
|
|
@@ -66,13 +93,14 @@ or by installing with the same rights they use for other global npm tools.
|
|
|
66
93
|
Do not sudo unless they tell you to.
|
|
67
94
|
|
|
68
95
|
If `node` or `npm` is missing, stop. Tell them to install Node.js LTS from
|
|
69
|
-
https://nodejs.org, open a new terminal, and come back. Offer
|
|
96
|
+
https://nodejs.org, open a new terminal, and come back. Offer 2d if they
|
|
70
97
|
would rather not install Node.
|
|
71
98
|
|
|
72
|
-
###
|
|
99
|
+
### 2c. Other systems: Chrome, then export
|
|
73
100
|
|
|
74
|
-
|
|
75
|
-
use for muse.ai. Needs Chrome
|
|
101
|
+
Chrome hides its cookies until remote debugging is on. Walk the user through
|
|
102
|
+
this in the Google Chrome window they already use for muse.ai. Needs Chrome
|
|
103
|
+
144 or newer. Wait until they confirm, and do not run `auth export` before:
|
|
76
104
|
|
|
77
105
|
1. Address bar: `chrome://inspect/#remote-debugging`
|
|
78
106
|
2. Turn on remote debugging ("Allow remote debugging for this browser instance").
|
|
@@ -82,7 +110,7 @@ use for muse.ai. Needs Chrome 144 or newer. Wait until they confirm:
|
|
|
82
110
|
Then:
|
|
83
111
|
|
|
84
112
|
```bash
|
|
85
|
-
muse-cli auth export
|
|
113
|
+
muse-cli auth export --browser agent-browser
|
|
86
114
|
test -s ~/.config/muse-cli/cookies.txt && echo auth-ok
|
|
87
115
|
```
|
|
88
116
|
|
|
@@ -100,14 +128,14 @@ in a loop:
|
|
|
100
128
|
opens another profile, and it does not have their muse.ai login.
|
|
101
129
|
- "no muse.ai tab": Chrome connected. They still need https://muse.ai/ open
|
|
102
130
|
and in front in that same window.
|
|
103
|
-
- "no hatch_sess" / "do not include hatch_sess": the tab is open
|
|
104
|
-
|
|
105
|
-
- "daemon already running": `agent-browser close`, then `muse-cli auth export` once.
|
|
106
|
-
- `agent-browser` not found: back to
|
|
131
|
+
- "no hatch_sess" / "do not include a valid hatch_sess": the tab is open but
|
|
132
|
+
the login is missing, empty or expired. The cookies file on disk was kept.
|
|
133
|
+
- "daemon already running": `agent-browser close`, then `muse-cli auth export --browser agent-browser` once.
|
|
134
|
+
- `agent-browser` not found: back to 2b.
|
|
107
135
|
|
|
108
|
-
###
|
|
136
|
+
### 2d. Copy cookies by hand
|
|
109
137
|
|
|
110
|
-
Use this when Node is unavailable, or the user does not want remote debugging on.
|
|
138
|
+
Use this when Node is unavailable, the browser is Safari, or the user does not want remote debugging on.
|
|
111
139
|
|
|
112
140
|
1. They are logged in at https://muse.ai/ in Chrome.
|
|
113
141
|
2. DevTools (F12) → Application → Cookies → `https://muse.ai`.
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"""Read the muse.ai login straight from a Chromium browser's cookie store on macOS.
|
|
2
|
+
|
|
3
|
+
Chromium keeps cookies in a SQLite file. Values are AES-128-CBC encrypted with
|
|
4
|
+
a key derived from the browser's "Safe Storage" password in the login
|
|
5
|
+
keychain, so macOS asks the user once before `security` may read it. Nothing
|
|
6
|
+
here needs Node.js or a debugging port, and the browser can stay closed.
|
|
7
|
+
"""
|
|
8
|
+
import ctypes
|
|
9
|
+
import hashlib
|
|
10
|
+
import os
|
|
11
|
+
import shutil
|
|
12
|
+
import sqlite3
|
|
13
|
+
import subprocess
|
|
14
|
+
import sys
|
|
15
|
+
import tempfile
|
|
16
|
+
import time
|
|
17
|
+
|
|
18
|
+
SUPPORT = os.path.expanduser("~/Library/Application Support")
|
|
19
|
+
|
|
20
|
+
# name -> (data dir under Application Support, keychain service, keychain account)
|
|
21
|
+
BROWSERS = {
|
|
22
|
+
"chrome": ("Google/Chrome", "Chrome Safe Storage", "Chrome"),
|
|
23
|
+
"brave": ("BraveSoftware/Brave-Browser", "Brave Safe Storage", "Brave"),
|
|
24
|
+
"arc": ("Arc/User Data", "Arc Safe Storage", "Arc"),
|
|
25
|
+
"edge": ("Microsoft Edge", "Microsoft Edge Safe Storage", "Microsoft Edge"),
|
|
26
|
+
"chromium": ("Chromium", "Chromium Safe Storage", "Chromium"),
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
KEYCHAIN_WAIT = 120 # seconds; macOS shows an Allow dialog the first time
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class BrowserCookieError(RuntimeError):
|
|
33
|
+
pass
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def supported():
|
|
37
|
+
return sys.platform == "darwin"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def cookie_stores(names=None):
|
|
41
|
+
"""(browser, profile, path) for every cookie database that exists."""
|
|
42
|
+
found = []
|
|
43
|
+
for name in names or BROWSERS:
|
|
44
|
+
base = os.path.join(SUPPORT, BROWSERS[name][0])
|
|
45
|
+
try:
|
|
46
|
+
profiles = sorted(os.listdir(base))
|
|
47
|
+
except OSError:
|
|
48
|
+
continue
|
|
49
|
+
for profile in profiles:
|
|
50
|
+
if profile != "Default" and not profile.startswith("Profile "):
|
|
51
|
+
continue
|
|
52
|
+
for rel in ("Network/Cookies", "Cookies"):
|
|
53
|
+
path = os.path.join(base, profile, rel)
|
|
54
|
+
if os.path.isfile(path):
|
|
55
|
+
found.append((name, profile, path))
|
|
56
|
+
break
|
|
57
|
+
return found
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _file_stamp(path):
|
|
61
|
+
try:
|
|
62
|
+
s = os.stat(path)
|
|
63
|
+
except FileNotFoundError:
|
|
64
|
+
return None
|
|
65
|
+
return s.st_ino, s.st_size, s.st_mtime_ns, s.st_ctime_ns
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _muse_rows(path):
|
|
69
|
+
"""Encrypted muse.ai rows from a copy of the database (the browser locks the original)."""
|
|
70
|
+
paths = [path, path + "-wal", path + "-journal"]
|
|
71
|
+
try:
|
|
72
|
+
for _ in range(3):
|
|
73
|
+
before = [_file_stamp(p) for p in paths]
|
|
74
|
+
with tempfile.TemporaryDirectory(prefix="muse-cli-") as tmp: # mode 0700
|
|
75
|
+
copy = os.path.join(tmp, "Cookies")
|
|
76
|
+
try:
|
|
77
|
+
shutil.copy(path, copy)
|
|
78
|
+
for src, stamp in zip(paths[1:], before[1:]):
|
|
79
|
+
if stamp is not None:
|
|
80
|
+
shutil.copy(src, copy + src[len(path):])
|
|
81
|
+
except FileNotFoundError:
|
|
82
|
+
continue
|
|
83
|
+
# A checkpoint between copying the DB and WAL can silently lose cookies.
|
|
84
|
+
if before != [_file_stamp(p) for p in paths]:
|
|
85
|
+
continue
|
|
86
|
+
db = sqlite3.connect(copy)
|
|
87
|
+
try:
|
|
88
|
+
return db.execute(
|
|
89
|
+
"SELECT host_key, name, path, is_secure, expires_utc, value, encrypted_value "
|
|
90
|
+
"FROM cookies WHERE host_key IN ('muse.ai', '.muse.ai')").fetchall()
|
|
91
|
+
finally:
|
|
92
|
+
db.close()
|
|
93
|
+
except (OSError, sqlite3.Error) as e:
|
|
94
|
+
raise BrowserCookieError(f"cannot read {path}: {e}")
|
|
95
|
+
raise BrowserCookieError(f"cookie database changed while reading {path}; close the browser and retry")
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _safe_storage_key(service, account):
|
|
99
|
+
try:
|
|
100
|
+
r = subprocess.run(["security", "find-generic-password", "-w", "-s", service, "-a", account],
|
|
101
|
+
capture_output=True, text=True, timeout=KEYCHAIN_WAIT)
|
|
102
|
+
except subprocess.TimeoutExpired:
|
|
103
|
+
raise BrowserCookieError("timed out waiting for the macOS keychain prompt")
|
|
104
|
+
except OSError as e:
|
|
105
|
+
raise BrowserCookieError(f"could not read '{service}' from the keychain ({e})")
|
|
106
|
+
if r.returncode != 0:
|
|
107
|
+
why = (r.stderr or "").strip().splitlines()[-1:] or [f"exit {r.returncode}"]
|
|
108
|
+
raise BrowserCookieError(f"could not read '{service}' from the keychain ({why[0]})")
|
|
109
|
+
# 1003 rounds, fixed salt: Chromium's own derivation on macOS.
|
|
110
|
+
return hashlib.pbkdf2_hmac("sha1", r.stdout.strip().encode(), b"saltysalt", 1003, 16)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _aes_cbc_decrypt(key, iv, data):
|
|
114
|
+
lib = ctypes.CDLL("/usr/lib/libSystem.B.dylib")
|
|
115
|
+
lib.CCCrypt.argtypes = [ctypes.c_uint32, ctypes.c_uint32, ctypes.c_uint32,
|
|
116
|
+
ctypes.c_char_p, ctypes.c_size_t, ctypes.c_char_p,
|
|
117
|
+
ctypes.c_char_p, ctypes.c_size_t,
|
|
118
|
+
ctypes.c_void_p, ctypes.c_size_t, ctypes.POINTER(ctypes.c_size_t)]
|
|
119
|
+
out = ctypes.create_string_buffer(len(data) + 16)
|
|
120
|
+
moved = ctypes.c_size_t()
|
|
121
|
+
# op 1 = decrypt, algorithm 0 = AES, options 1 = PKCS7 padding
|
|
122
|
+
rc = lib.CCCrypt(1, 0, 1, key, len(key), iv, data, len(data), out, len(out), ctypes.byref(moved))
|
|
123
|
+
if rc != 0:
|
|
124
|
+
raise BrowserCookieError(f"cookie decryption failed (CCCrypt {rc}); wrong keychain key?")
|
|
125
|
+
return out.raw[:moved.value]
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def _decrypt(blob, key, host, decrypt=_aes_cbc_decrypt):
|
|
129
|
+
if blob[:3] not in (b"v10", b"v11"):
|
|
130
|
+
raise BrowserCookieError("unknown cookie encryption format")
|
|
131
|
+
plain = decrypt(key, b" " * 16, bytes(blob[3:]))
|
|
132
|
+
# Chromium 130+ (cookie DB version 24) prefixes the value with SHA-256 of the host.
|
|
133
|
+
if plain[:32] == hashlib.sha256(host.encode()).digest():
|
|
134
|
+
plain = plain[32:]
|
|
135
|
+
try:
|
|
136
|
+
return plain.decode("utf-8")
|
|
137
|
+
except UnicodeDecodeError:
|
|
138
|
+
raise BrowserCookieError("cookie decrypted to garbage; wrong keychain key?")
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def _expires(chrome_us):
|
|
142
|
+
# Chromium counts microseconds from 1601-01-01; 0 marks a session cookie.
|
|
143
|
+
return int(chrome_us / 1e6 - 11644473600) if chrome_us else 0
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def read_cookies(browser="auto", key_for=_safe_storage_key, decrypt=_aes_cbc_decrypt):
|
|
147
|
+
"""Return (jar, source) with the muse.ai cookies of the profile that is logged in.
|
|
148
|
+
|
|
149
|
+
jar entries match what `auth export` writes: name, value, domain, path,
|
|
150
|
+
secure, expires. The keychain is asked only once a profile with an
|
|
151
|
+
unexpired `hatch_sess` row is found, so a browser without a muse.ai login never
|
|
152
|
+
triggers a prompt. Raises BrowserCookieError with a reason otherwise.
|
|
153
|
+
"""
|
|
154
|
+
if not supported():
|
|
155
|
+
raise BrowserCookieError("reading browser cookies directly is macOS-only")
|
|
156
|
+
names = None if browser == "auto" else [browser]
|
|
157
|
+
stores = cookie_stores(names)
|
|
158
|
+
if not stores:
|
|
159
|
+
raise BrowserCookieError("no Chromium-based browser profile found"
|
|
160
|
+
if names is None else f"no {browser} profile found")
|
|
161
|
+
logged_in, errors = [], []
|
|
162
|
+
now = time.time()
|
|
163
|
+
for name, profile, path in stores:
|
|
164
|
+
try:
|
|
165
|
+
rows = [r for r in _muse_rows(path) if not r[4] or _expires(r[4]) > now]
|
|
166
|
+
except BrowserCookieError as e:
|
|
167
|
+
errors.append(str(e))
|
|
168
|
+
continue
|
|
169
|
+
sess = [r for r in rows if r[1] == "hatch_sess"]
|
|
170
|
+
if sess:
|
|
171
|
+
logged_in.append((max(r[4] for r in sess), name, profile, rows))
|
|
172
|
+
keys = {}
|
|
173
|
+
for _, name, profile, rows in sorted(logged_in, key=lambda t: t[0], reverse=True):
|
|
174
|
+
try:
|
|
175
|
+
if name not in keys:
|
|
176
|
+
_, service, account = BROWSERS[name]
|
|
177
|
+
try:
|
|
178
|
+
keys[name] = key_for(service, account)
|
|
179
|
+
except BrowserCookieError as e:
|
|
180
|
+
keys[name] = e
|
|
181
|
+
key = keys[name]
|
|
182
|
+
if isinstance(key, BrowserCookieError):
|
|
183
|
+
raise key
|
|
184
|
+
jar = []
|
|
185
|
+
for host, cname, cpath, secure, expires, value, blob in rows:
|
|
186
|
+
jar.append({"name": cname, "domain": host, "path": cpath or "/",
|
|
187
|
+
"secure": bool(secure), "expires": _expires(expires),
|
|
188
|
+
"value": _decrypt(blob, key, host, decrypt) if blob else value})
|
|
189
|
+
if any(c["name"] == "hatch_sess" and c["value"] for c in jar):
|
|
190
|
+
return jar, f"{name} ({profile})"
|
|
191
|
+
except (BrowserCookieError, OSError) as e:
|
|
192
|
+
errors.append(f"{name} ({profile}): {e}")
|
|
193
|
+
if errors:
|
|
194
|
+
raise BrowserCookieError("; ".join(errors))
|
|
195
|
+
raise BrowserCookieError("no muse.ai login (hatch_sess) in " +
|
|
196
|
+
", ".join(sorted({f"{n} {p}" for n, p, _ in stores})))
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"""muse-cli: CLI for your personal muse.ai agent. No browser needed after cookie export.
|
|
2
2
|
|
|
3
|
-
One-time setup
|
|
4
|
-
1.
|
|
5
|
-
2.
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
One-time setup:
|
|
4
|
+
1. Log in at https://muse.ai/ in Chrome, Brave, Arc or Edge.
|
|
5
|
+
2. muse-cli auth export # saves session cookies locally (chmod 600)
|
|
6
|
+
On Linux/Windows `auth export` needs agent-browser and Chrome remote debugging
|
|
7
|
+
instead; it prints those steps when something is missing.
|
|
8
8
|
|
|
9
9
|
Then: muse-cli status | muse-cli threads | muse-cli history | muse-cli send "hello" | ...
|
|
10
10
|
"""
|
|
@@ -17,7 +17,7 @@ import sys
|
|
|
17
17
|
import time
|
|
18
18
|
import urllib.parse
|
|
19
19
|
|
|
20
|
-
from . import __version__
|
|
20
|
+
from . import __version__, browsers
|
|
21
21
|
from .gateway import Gateway, AuthError, GatewayError, load_cookies
|
|
22
22
|
from .update import cmd_update, finish_update_check, start_update_check
|
|
23
23
|
|
|
@@ -53,9 +53,8 @@ def connect(cfg):
|
|
|
53
53
|
if not os.path.exists(cfg["cookies_file"]):
|
|
54
54
|
raise AuthError(
|
|
55
55
|
f"no cookies at {cfg['cookies_file']}. Run `muse-cli auth export` "
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"window, then export again.")
|
|
56
|
+
"after logging in at https://muse.ai/ in your browser, "
|
|
57
|
+
"and follow the setup steps it prints.")
|
|
59
58
|
cookies = load_cookies(cfg["cookies_file"])
|
|
60
59
|
if not cookies.strip():
|
|
61
60
|
raise AuthError(f"cookies file {cfg['cookies_file']} is empty; run `muse-cli auth export`")
|
|
@@ -259,19 +258,52 @@ def _browser_cookies():
|
|
|
259
258
|
return None, last_err
|
|
260
259
|
|
|
261
260
|
|
|
262
|
-
def
|
|
261
|
+
def _print_need_browser_login(err):
|
|
262
|
+
print(f"Could not read a muse.ai login from your browser: {err}", file=sys.stderr)
|
|
263
|
+
print(file=sys.stderr)
|
|
264
|
+
print("Log in at https://muse.ai/ in Chrome, Brave, Arc or Edge, then run", file=sys.stderr)
|
|
265
|
+
print("`muse-cli auth export` again. macOS may ask to let `security` use", file=sys.stderr)
|
|
266
|
+
print("the browser's Safe Storage key; click Allow.", file=sys.stderr)
|
|
267
|
+
print(file=sys.stderr)
|
|
268
|
+
_print_hand_copy()
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def cmd_auth_export(args):
|
|
263
272
|
os.makedirs(CONFIG_DIR, exist_ok=True)
|
|
264
|
-
|
|
265
|
-
|
|
273
|
+
choice = getattr(args, "browser", None) or "auto"
|
|
274
|
+
jar, source = None, "Chrome"
|
|
275
|
+
if choice != "agent-browser" and browsers.supported():
|
|
276
|
+
print("Reading muse.ai cookies from your browser...", file=sys.stderr)
|
|
277
|
+
try:
|
|
278
|
+
jar, source = browsers.read_cookies(choice)
|
|
279
|
+
except browsers.BrowserCookieError as e:
|
|
280
|
+
if choice != "auto":
|
|
281
|
+
print(f"cookie export failed: {e}", file=sys.stderr)
|
|
282
|
+
sys.exit(1)
|
|
283
|
+
if shutil.which("agent-browser") is None:
|
|
284
|
+
_print_need_browser_login(e)
|
|
285
|
+
sys.exit(1)
|
|
286
|
+
print(f"({e}; trying agent-browser)", file=sys.stderr)
|
|
287
|
+
elif choice not in ("auto", "agent-browser"):
|
|
288
|
+
print("cookie export failed: reading browser cookies directly is macOS-only; "
|
|
289
|
+
"use --browser agent-browser", file=sys.stderr)
|
|
266
290
|
sys.exit(1)
|
|
267
|
-
print("Reading muse.ai cookies from Chrome...", file=sys.stderr)
|
|
268
|
-
jar, err = _browser_cookies()
|
|
269
291
|
if jar is None:
|
|
270
|
-
|
|
271
|
-
|
|
292
|
+
if shutil.which("agent-browser") is None:
|
|
293
|
+
_print_need_agent_browser()
|
|
294
|
+
sys.exit(1)
|
|
295
|
+
print("Reading muse.ai cookies from Chrome...", file=sys.stderr)
|
|
296
|
+
jar, err = _browser_cookies()
|
|
297
|
+
if jar is None:
|
|
298
|
+
_print_export_failure(err)
|
|
299
|
+
sys.exit(1)
|
|
272
300
|
# Never clobber a working login with an empty or logged-out jar.
|
|
273
|
-
|
|
274
|
-
|
|
301
|
+
now = time.time()
|
|
302
|
+
if not any(c["name"] == "hatch_sess" and c.get("value")
|
|
303
|
+
and (float(c.get("expires") or 0) <= 0 or float(c["expires"]) > now)
|
|
304
|
+
for c in jar):
|
|
305
|
+
print(f"{source} answered, but the cookies do not include a valid hatch_sess "
|
|
306
|
+
"(non-empty and unexpired).", file=sys.stderr)
|
|
275
307
|
print("That cookie is set only after you log in at https://muse.ai/.", file=sys.stderr)
|
|
276
308
|
print("Log in, leave the muse.ai tab open, and run `muse-cli auth export` again.",
|
|
277
309
|
file=sys.stderr)
|
|
@@ -292,7 +324,8 @@ def cmd_auth_export(_args):
|
|
|
292
324
|
fd = os.open(COOKIES_FILE, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
|
|
293
325
|
with os.fdopen(fd, "w") as fh:
|
|
294
326
|
fh.write("\n".join(lines) + "\n")
|
|
295
|
-
print(f"saved {len(jar)} muse.ai cookies to {COOKIES_FILE}"
|
|
327
|
+
print(f"saved {len(jar)} muse.ai cookies to {COOKIES_FILE}"
|
|
328
|
+
+ (f" (from {source})" if source != "Chrome" else ""))
|
|
296
329
|
|
|
297
330
|
|
|
298
331
|
def cmd_status(_args):
|
|
@@ -854,10 +887,20 @@ def main():
|
|
|
854
887
|
|
|
855
888
|
p = sub.add_parser("auth", help="auth helpers"); a = p.add_subparsers(dest="op", required=True)
|
|
856
889
|
export_help = (
|
|
857
|
-
"Copy your muse.ai login out of
|
|
890
|
+
"Copy your muse.ai login out of your browser into\n"
|
|
858
891
|
"~/.config/muse-cli/cookies.txt (mode 600).\n"
|
|
859
892
|
"\n"
|
|
860
|
-
"
|
|
893
|
+
"On macOS it reads the cookies of Chrome, Brave, Arc, Edge or Chromium\n"
|
|
894
|
+
"directly: log in at https://muse.ai/ once, then run this command.\n"
|
|
895
|
+
"macOS asks once to let `security` use the browser's Safe Storage key;\n"
|
|
896
|
+
"click Allow. No Node.js or debugging port is needed, and the browser\n"
|
|
897
|
+
"can be closed.\n"
|
|
898
|
+
"Unreadable profiles are skipped if another has a usable login.\n"
|
|
899
|
+
"Subdomain-only cookies are not exported.\n"
|
|
900
|
+
"Empty or expired login cookies never replace a saved login.\n"
|
|
901
|
+
"\n"
|
|
902
|
+
"Elsewhere, or with --browser agent-browser, it reads Google Chrome through\n"
|
|
903
|
+
"agent-browser. Chrome shares those cookies only after remote debugging is on.\n"
|
|
861
904
|
"In the Chrome window you already use for muse.ai:\n"
|
|
862
905
|
"\n"
|
|
863
906
|
" 1. Open chrome://inspect/#remote-debugging\n"
|
|
@@ -867,18 +910,23 @@ def main():
|
|
|
867
910
|
" 4. Run this command. If Chrome asks to allow the connection,\n"
|
|
868
911
|
" click Allow, then run it again if it failed before the click.\n"
|
|
869
912
|
"\n"
|
|
870
|
-
"
|
|
913
|
+
"That route requires agent-browser: npm i -g agent-browser\n"
|
|
871
914
|
"(install Node.js LTS from https://nodejs.org first if npm is missing).\n"
|
|
872
915
|
"\n"
|
|
873
916
|
"Stay in that same Chrome. Starting another Chrome with\n"
|
|
874
917
|
"--remote-debugging-port uses a different profile and has no muse.ai login."
|
|
875
918
|
)
|
|
876
|
-
a.add_parser(
|
|
919
|
+
p = a.add_parser(
|
|
877
920
|
"export",
|
|
878
|
-
help="copy the muse.ai login out of
|
|
921
|
+
help="copy the muse.ai login out of your browser",
|
|
879
922
|
description=export_help,
|
|
880
923
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
881
|
-
)
|
|
924
|
+
)
|
|
925
|
+
p.add_argument("--browser", default="auto",
|
|
926
|
+
choices=["auto", *browsers.BROWSERS, "agent-browser"],
|
|
927
|
+
help="where to read the login (default: auto = any logged-in "
|
|
928
|
+
"Chromium browser on macOS, else agent-browser)")
|
|
929
|
+
p.set_defaults(fn=cmd_auth_export)
|
|
882
930
|
|
|
883
931
|
sub.add_parser("chat", help="interactive chat (the default with no command)").set_defaults(fn=_chat)
|
|
884
932
|
sub.add_parser("status", help="VM, session count, unread, identity").set_defaults(fn=cmd_status)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|