heyyumi 0.1.5 → 0.1.6
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 +1 -0
- package/package.json +1 -1
- package/src/args.js +1 -0
- package/src/commands.js +6 -1
- package/src/detach.js +82 -0
package/README.md
CHANGED
|
@@ -97,6 +97,7 @@ npx -y heyyumi place <placeId> --fields all # menu, hours, attributes,
|
|
|
97
97
|
- Each sign-in gets its own HeyYumi key on the user's account, so usage is metered per user.
|
|
98
98
|
- Credentials are saved to `~/.config/heyyumi/credentials.json` (mode 0600; `%APPDATA%\heyyumi` on Windows). Access tokens refresh on their own; refresh is locked across processes so parallel agent commands never sign the user out.
|
|
99
99
|
- `heyyumi status` shows whether you are signed in (never prints tokens). `heyyumi logout` removes local credentials. Keys can be revoked any time at <https://heyyumi.ai/dashboard>.
|
|
100
|
+
- `--detach` is for agents that must hand the link to a person: it prints `{"pending":true,"url":...}` and returns at once, while a background process waits up to 5 minutes for the sign-in. Many agent shells kill what a command left running (`&`, `nohup`), so a plain background `login` would die before the person opens the link. Check with `heyyumi status` afterwards.
|
|
100
101
|
- `--no-browser` prints the URL instead of opening it. `--client-name NAME` labels the connection (it shows up as the source of reservation requests, e.g. `--client-name "My Agent"`).
|
|
101
102
|
- Already have a dashboard key? Set `HEYYUMI_API_KEY=hmp_...` and skip `login`.
|
|
102
103
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "heyyumi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Your AI finds and books real Korean restaurants and hair & nail salons, no Korean needed. 546,000+ verified venues; search, details and reservation requests as JSON for any agent.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
package/src/args.js
CHANGED
package/src/commands.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const { flagsToToolArgs } = require("./args");
|
|
4
4
|
const { callTool, listTools, rpc } = require("./mcp");
|
|
5
5
|
const { login } = require("./oauth");
|
|
6
|
+
const { detachedLogin } = require("./detach");
|
|
6
7
|
const { readCredentials, removeCredentials } = require("./credentials");
|
|
7
8
|
const { normalizeReservationTime } = require("./time");
|
|
8
9
|
const { credentialsPath, DEFAULT_CLIENT_NAME, MCP_URL, version } = require("./config");
|
|
@@ -120,7 +121,7 @@ function photosResult(data) {
|
|
|
120
121
|
// `--nme` would book under no name, so reject it. Commands not listed forward flags to the tool,
|
|
121
122
|
// where validateArgs checks them against the live schema.
|
|
122
123
|
const OWN_FLAGS = {
|
|
123
|
-
login: ["client-name", "no-browser", "timeout", "force"],
|
|
124
|
+
login: ["client-name", "no-browser", "detach", "timeout", "force"],
|
|
124
125
|
logout: [],
|
|
125
126
|
status: [],
|
|
126
127
|
photos: ["category", "limit"],
|
|
@@ -156,6 +157,9 @@ const commands = {
|
|
|
156
157
|
return { ok: true, alreadySignedIn: true, clientName: existing.clientName, note: "Already signed in. Use --force to sign in again." };
|
|
157
158
|
}
|
|
158
159
|
const clientName = typeof flags["client-name"] === "string" ? flags["client-name"] : process.env.HEYYUMI_CLIENT_NAME || DEFAULT_CLIENT_NAME;
|
|
160
|
+
if (flags.detach === true) {
|
|
161
|
+
return detachedLogin({ clientName, timeoutSec: timeoutFlag(flags, 300), force: flags.force === true });
|
|
162
|
+
}
|
|
159
163
|
const creds = await login({
|
|
160
164
|
clientName,
|
|
161
165
|
noBrowser: flags["no-browser"] === true,
|
|
@@ -345,6 +349,7 @@ const HELP = `heyyumi ${version} — Korean restaurant search & table requests f
|
|
|
345
349
|
|
|
346
350
|
Sign in (once per machine; opens Google sign-in, finishes on its own):
|
|
347
351
|
heyyumi login [--no-browser] [--client-name NAME] [--timeout 300] [--force]
|
|
352
|
+
heyyumi login --detach for agents: prints the sign-in url and returns; sign-in finishes in the background
|
|
348
353
|
heyyumi status | logout
|
|
349
354
|
|
|
350
355
|
Rules for agents (from the server, always current):
|
package/src/detach.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("node:fs");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const { spawn } = require("node:child_process");
|
|
6
|
+
const { configDir } = require("./config");
|
|
7
|
+
const { CliError } = require("./errors");
|
|
8
|
+
|
|
9
|
+
const BIN = path.join(__dirname, "..", "bin", "heyyumi.js");
|
|
10
|
+
const AUTH_URL = /^https?:\/\/\S+\/oauth\/authorize\?\S+$/m;
|
|
11
|
+
|
|
12
|
+
function readLog(file) {
|
|
13
|
+
try {
|
|
14
|
+
return fs.readFileSync(file, "utf8");
|
|
15
|
+
} catch {
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function lastJson(text) {
|
|
21
|
+
const line = text.trim().split("\n").reverse().find((l) => l.startsWith("{"));
|
|
22
|
+
try {
|
|
23
|
+
return line ? JSON.parse(line) : null;
|
|
24
|
+
} catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* `login --detach`: print the sign-in link and return at once, while a child in its own session keeps the
|
|
31
|
+
* loopback callback open and saves the sign-in. Agent shells kill whatever a command left running when it
|
|
32
|
+
* returns (`&` and `nohup` included), so a plain background login dies before the person opens the link.
|
|
33
|
+
*/
|
|
34
|
+
async function detachedLogin({ clientName, timeoutSec, force = false, waitMs = 25000 }) {
|
|
35
|
+
const dir = configDir();
|
|
36
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
37
|
+
const logFile = path.join(dir, "login.log");
|
|
38
|
+
const fd = fs.openSync(logFile, "w", 0o600);
|
|
39
|
+
const args = [BIN, "login", "--no-browser", "--timeout", String(timeoutSec), "--client-name", clientName];
|
|
40
|
+
if (force) args.push("--force");
|
|
41
|
+
const child = spawn(process.execPath, args, { detached: true, stdio: ["ignore", fd, fd], windowsHide: true });
|
|
42
|
+
fs.closeSync(fd);
|
|
43
|
+
let exited = false;
|
|
44
|
+
child.once("exit", () => {
|
|
45
|
+
exited = true;
|
|
46
|
+
});
|
|
47
|
+
child.unref();
|
|
48
|
+
|
|
49
|
+
const deadline = Date.now() + waitMs;
|
|
50
|
+
while (Date.now() < deadline) {
|
|
51
|
+
await new Promise((r) => setTimeout(r, 150));
|
|
52
|
+
const text = readLog(logFile);
|
|
53
|
+
const url = text.match(AUTH_URL)?.[0];
|
|
54
|
+
if (url) {
|
|
55
|
+
return {
|
|
56
|
+
ok: true,
|
|
57
|
+
pending: true,
|
|
58
|
+
url,
|
|
59
|
+
expiresInSec: timeoutSec,
|
|
60
|
+
next: "Give the url to the person. It must be opened on this computer. Once they say they signed in, run: npx -y heyyumi status",
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (exited) break;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const out = lastJson(readLog(logFile));
|
|
67
|
+
if (out?.ok) return out;
|
|
68
|
+
const err = out?.error;
|
|
69
|
+
if (!exited) {
|
|
70
|
+
try {
|
|
71
|
+
process.kill(child.pid);
|
|
72
|
+
} catch {
|
|
73
|
+
// Already gone.
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
throw new CliError(err?.code || "login_start_failed", err?.message || "Could not start the sign-in. Try again.", {
|
|
77
|
+
exitCode: err?.code ? 3 : 1,
|
|
78
|
+
next: "npx -y heyyumi login --detach",
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
module.exports = { detachedLogin };
|