@lichao0223/lobehub-cli 0.0.0-stage → 0.0.79

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.
@@ -0,0 +1,97 @@
1
+ import { execFile, spawn } from "node:child_process";
2
+ import { rmSync } from "node:fs";
3
+ import { readFile, rename, rm, writeFile } from "node:fs/promises";
4
+ import { setTimeout as setTimeout$1 } from "node:timers/promises";
5
+ import { promisify } from "node:util";
6
+ //#region src/daemon/maintenanceWorker.ts
7
+ /** Atomic replacement lets the connected daemon read progress during installation. */
8
+ async function writeMaintenanceState(file, operation) {
9
+ const temporary = `${file}.${process.pid}.tmp`;
10
+ await writeFile(temporary, JSON.stringify(operation), { mode: 384 });
11
+ await rename(temporary, file);
12
+ }
13
+ async function run(command, args, timeout) {
14
+ await new Promise((resolve, reject) => {
15
+ const child = spawn(command, args, {
16
+ stdio: "inherit",
17
+ timeout
18
+ });
19
+ child.once("error", reject);
20
+ child.once("close", (code, signal) => {
21
+ if (code === 0) resolve();
22
+ else reject(/* @__PURE__ */ new Error(`CLI maintenance command failed (${signal ?? code}). See lh connect logs.`));
23
+ });
24
+ });
25
+ }
26
+ /** Runs from a private copy outside the package being replaced. No runtime package imports. */
27
+ async function runMaintenanceWorker(config, ready) {
28
+ const { entry, executable, operation, statePath } = config;
29
+ const persist = async () => {
30
+ await writeMaintenanceState(config.receiptPath, operation);
31
+ await writeMaintenanceState(statePath, operation);
32
+ };
33
+ try {
34
+ if (config.install) await run(config.install.command, config.install.args, 18e4);
35
+ const { stdout } = await promisify(execFile)(executable, [entry, "--version"], { timeout: 3e4 });
36
+ if (stdout.trim() !== operation.targetVersion) throw new Error("Installed CLI version did not match the requested version. The existing connection was kept.");
37
+ operation.stage = "restarting";
38
+ await persist();
39
+ ready();
40
+ const deadline = Date.now() + 3e4;
41
+ while (true) {
42
+ try {
43
+ process.kill(config.parentPid, 0);
44
+ } catch (error) {
45
+ if (error.code === "ESRCH") break;
46
+ throw error;
47
+ }
48
+ if (Date.now() >= deadline) throw new Error("The previous CLI did not stop. No second daemon was started.");
49
+ await setTimeout$1(100);
50
+ }
51
+ if (!config.restartArgs) return;
52
+ await run(executable, [
53
+ entry,
54
+ ...config.restartArgs,
55
+ "--daemon"
56
+ ], 45e3);
57
+ } catch (error) {
58
+ operation.stage = "failed";
59
+ operation.error = error instanceof Error ? error.message : String(error);
60
+ await persist();
61
+ throw error;
62
+ }
63
+ }
64
+ if (process.argv[2] === "--maintenance-config") {
65
+ const configPath = process.argv[3];
66
+ const config = JSON.parse(await readFile(configPath, "utf8"));
67
+ await rm(configPath);
68
+ let started = false;
69
+ const timeout = setTimeout(() => process.disconnect?.(), 15e3);
70
+ process.once("message", () => {
71
+ started = true;
72
+ clearTimeout(timeout);
73
+ runMaintenanceWorker(config, () => {
74
+ if (!process.connected) throw new Error("The original daemon stopped during installation. Start the connection manually.");
75
+ process.send?.({ type: "ready-to-restart" });
76
+ }).catch((error) => {
77
+ console.error(error);
78
+ process.exitCode = 1;
79
+ }).finally(async () => {
80
+ if (process.connected) process.disconnect();
81
+ await rm(process.argv[1], { force: true });
82
+ });
83
+ });
84
+ process.once("SIGTERM", () => {
85
+ rmSync(process.argv[1], { force: true });
86
+ process.exit(143);
87
+ });
88
+ process.once("disconnect", () => {
89
+ clearTimeout(timeout);
90
+ if (!started) {
91
+ process.exitCode = 1;
92
+ rm(process.argv[1], { force: true }).catch(console.error);
93
+ }
94
+ });
95
+ }
96
+ //#endregion
97
+ export { runMaintenanceWorker, writeMaintenanceState };
package/man/man1/lh.1 ADDED
@@ -0,0 +1,241 @@
1
+ .\" Code generated by `npm run man:generate`; DO NOT EDIT.
2
+ .\" Manual command details come from the Commander command tree.
3
+ .TH LH 1 "" "@lichao0223/lobehub\-cli 0.0.79" "User Commands"
4
+ .SH NAME
5
+ lh \- LobeHub CLI \- manage and connect to LobeHub services
6
+ .SH SYNOPSIS
7
+ .B lh
8
+ [\fIOPTION\fR]...
9
+ [\fICOMMAND\fR]
10
+ .br
11
+ .B lobe
12
+ [\fIOPTION\fR]...
13
+ [\fICOMMAND\fR]
14
+ .br
15
+ .B lobehub
16
+ [\fIOPTION\fR]...
17
+ [\fICOMMAND\fR]
18
+ .SH DESCRIPTION
19
+ lh is the command\-line interface for LobeHub. It provides authentication, device gateway connectivity, content generation, resource search, and management commands for agents, files, models, providers, plugins, knowledge bases, threads, topics, and related resources.
20
+ .PP
21
+ For command-specific manuals, use the built-in manual command:
22
+ .PP
23
+ .RS
24
+ .B lh man
25
+ [\fICOMMAND\fR]...
26
+ .RE
27
+ .SH COMMANDS
28
+ .TP
29
+ .B tool\-worker
30
+ Internal command for isolated tool execution
31
+ .TP
32
+ .B login
33
+ Log in to LobeHub via browser (Device Code Flow) or configure API key server
34
+ .TP
35
+ .B logout
36
+ Log out and remove stored credentials
37
+ .TP
38
+ .B completion
39
+ Output shell completion script
40
+ .TP
41
+ .B man
42
+ Show a manual page for the CLI or a subcommand
43
+ .TP
44
+ .B connect
45
+ Connect to the device gateway and listen for tool calls
46
+ .TP
47
+ .B disconnect
48
+ Disconnect from the device gateway (alias for `connect stop`)
49
+ .TP
50
+ .B device
51
+ Manage connected devices
52
+ .TP
53
+ .B quota
54
+ Read subscription quota of agent runtimes (Claude Code / Codex / Kimi Code accounts)
55
+ .TP
56
+ .B status
57
+ Check if gateway connection can be established
58
+ .TP
59
+ .B doctor
60
+ Diagnose this machine: runtime, endpoints, credentials, scope, device and agent readiness
61
+ .TP
62
+ .B doc
63
+ Manage documents
64
+ .TP
65
+ .B search
66
+ Search across local resources or the web
67
+ .TP
68
+ .B read
69
+ Read a LobeHub link as plain text via the API (e.g. a shared topic: https://lobehub.com/share/t/<id>), bypassing the Cloudflare\-protected web page
70
+ .TP
71
+ .B recall
72
+ Recall what happened around a topic: matching messages, conversations, goals and pages in one time window
73
+ .TP
74
+ .B kb
75
+ Manage knowledge bases, folders, documents, and files
76
+ .TP
77
+ .B meeting
78
+ Read recorded meetings
79
+ .TP
80
+ .B memory
81
+ Manage user memories
82
+ .TP
83
+ .B agent
84
+ Manage agents
85
+ .TP
86
+ .B agent\-group
87
+ Manage agent groups
88
+ .TP
89
+ .B agent\-signal
90
+ Inspect and trigger Agent Signal source events
91
+ .TP
92
+ .B bot
93
+ Manage bot integrations
94
+ .TP
95
+ .B channel
96
+ Read the current Agent run’s Channel conversation, message Agents in other Channels, and message people for your requester
97
+ .TP
98
+ .B generate
99
+ Generate content (text, image, video, speech) Alias: gen.
100
+ .TP
101
+ .B goal
102
+ Run long\-horizon Goal Graphs
103
+ .TP
104
+ .B file
105
+ Manage files
106
+ .TP
107
+ .B artifact
108
+ Publish local pages as artifacts
109
+ .TP
110
+ .B hetero
111
+ Run heterogeneous agent CLIs (Antigravity / Amp / Claude Code / CodeBuddy / Codex / GitHub Copilot / Cursor / Factory Droid / Devin / Grok Build / Kimi Code / OpenCode / Pi / Qoder / TRAE CLI / DeepSeek Harness) and stream their output
112
+ .TP
113
+ .B skill
114
+ Manage agent skills
115
+ .TP
116
+ .B session\-group
117
+ Manage agent session groups
118
+ .TP
119
+ .B task
120
+ Manage agent tasks
121
+ .TP
122
+ .B thread
123
+ Manage message threads
124
+ .TP
125
+ .B tfs
126
+ TFS / Azure DevOps Server operations
127
+ .TP
128
+ .B topic
129
+ Manage conversation topics
130
+ .TP
131
+ .B work
132
+ Look up agent work
133
+ .TP
134
+ .B trace
135
+ Inspect and replay recorded agent execution traces
136
+ .TP
137
+ .B message
138
+ Manage messages
139
+ .TP
140
+ .B model
141
+ Manage AI models
142
+ .TP
143
+ .B notify
144
+ Send a callback message to a topic and trigger the agent to process it
145
+ .TP
146
+ .B notification
147
+ Manage notification delivery settings (email, IM, inbox, push)
148
+ .TP
149
+ .B provider
150
+ Manage AI providers
151
+ .TP
152
+ .B project
153
+ Manage goal\-oriented projects
154
+ .TP
155
+ .B dashboard
156
+ Manage dashboards (boards of monitoring widgets)
157
+ .TP
158
+ .B widget
159
+ Build monitoring widgets: sandboxed scripts rendered as dashboard cards
160
+ .TP
161
+ .B legacy\-plugin
162
+ Manage legacy 1.0 plugins (user_installed_plugins). Add new MCP servers with lh connector add Alias: plugin.
163
+ .TP
164
+ .B connector
165
+ Manage MCP connectors (user connectors and their synced tools) Alias: mcp.
166
+ .TP
167
+ .B webhook
168
+ Manage custom webhooks: URLs any system calls to wake an agent (MCP Events subscriptions are under lh automation) Alias: webhooks.
169
+ .TP
170
+ .B automation
171
+ Manage automations: MCP Events subscriptions that run an agent on a connector event (an agent creates them in a conversation) Alias: automations.
172
+ .TP
173
+ .B workspace
174
+ Manage workspaces and the workspace scope commands run under Alias: ws.
175
+ .TP
176
+ .B user
177
+ Manage user account and settings
178
+ .TP
179
+ .B acceptance
180
+ Delivery acceptances: the cross\-round review loop (checks, feedback, decision)
181
+ .TP
182
+ .B whoami
183
+ Display current user information
184
+ .TP
185
+ .B usage
186
+ View usage statistics
187
+ .TP
188
+ .B eval
189
+ Manage evaluation workflows
190
+ .TP
191
+ .B migrate
192
+ Migrate data from external tools (OpenClaw, ChatGPT, Claude, etc.)
193
+ .TP
194
+ .B update
195
+ Update the LobeHub CLI to the latest published version
196
+ .SH OPTIONS
197
+ .TP
198
+ .B \-V, \-\-version
199
+ output the version number
200
+ .TP
201
+ .B \-h, \-\-help
202
+ display help for command
203
+ .SH FILES
204
+ .TP
205
+ .I ~/.lobehub/credentials.json
206
+ Encrypted access and refresh tokens.
207
+ .TP
208
+ .I ~/.lobehub/settings.json
209
+ CLI settings such as server and gateway URLs.
210
+ .TP
211
+ .I ~/.lobehub/daemon.pid
212
+ Background daemon PID file.
213
+ .TP
214
+ .I ~/.lobehub/daemon.status
215
+ Background daemon status metadata.
216
+ .TP
217
+ .I ~/.lobehub/daemon.log
218
+ Background daemon log output.
219
+ .PP
220
+ The base directory can be overridden with the
221
+ .B LOBEHUB_CLI_HOME
222
+ environment variable.
223
+ .SH EXAMPLES
224
+ .TP
225
+ .B lh login
226
+ Start interactive login in the browser.
227
+ .TP
228
+ .B lh connect \-\-daemon
229
+ Start the device gateway connection in the background.
230
+ .TP
231
+ .B lh search \-q "gpt\-5"
232
+ Search local resources for a query.
233
+ .TP
234
+ .B lh generate text "Write release notes"
235
+ Generate text from a prompt.
236
+ .TP
237
+ .B lh man generate
238
+ Show the built\-in manual for the generate command group.
239
+ .SH SEE ALSO
240
+ .BR lobe (1),
241
+ .BR lobehub (1)
@@ -0,0 +1 @@
1
+ .so man1/lh.1
@@ -0,0 +1 @@
1
+ .so man1/lh.1
package/package.json CHANGED
@@ -1,6 +1,87 @@
1
1
  {
2
2
  "name": "@lichao0223/lobehub-cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.79",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/lichao0223/lobehub",
7
+ "directory": "apps/cli"
8
+ },
9
+ "type": "module",
10
+ "bin": {
11
+ "lh": "dist/index.js",
12
+ "lobe": "dist/index.js",
13
+ "lobehub": "dist/index.js"
14
+ },
15
+ "man": [
16
+ "./man/man1/lh.1",
17
+ "./man/man1/lobe.1",
18
+ "./man/man1/lobehub.1"
19
+ ],
20
+ "files": [
21
+ "dist",
22
+ "man"
23
+ ],
24
+ "scripts": {
25
+ "build": "bun scripts/ensureWorkspaceLinks.ts && tsdown && tsdown src/daemon/maintenanceWorker.ts --no-config --no-clean --format esm --target node22 && bun scripts/copyReportTemplate.ts",
26
+ "cli:link": "bun link",
27
+ "cli:unlink": "bun unlink",
28
+ "dev": "LOBEHUB_CLI_HOME=.lobehub-dev bun src/index.ts",
29
+ "man:generate": "bun src/man/generate.ts",
30
+ "prepublishOnly": "bun run --cwd ../workbench build:report && npm run build && bun scripts/copyReportTemplate.ts --require && npm run man:generate",
31
+ "test": "bunx vitest run --config vitest.config.mts --silent='passed-only'",
32
+ "test:coverage": "bunx vitest run --config vitest.config.mts --coverage",
33
+ "test:e2e": "bunx vitest run --config vitest.e2e.config.mts --silent='passed-only'",
34
+ "type-check": "tsc --noEmit"
35
+ },
36
+ "dependencies": {
37
+ "@lydell/node-pty": "1.2.0-beta.15",
38
+ "ws": "^8.21.0"
39
+ },
40
+ "devDependencies": {
41
+ "@lobechat/agent-gateway-client": "workspace:*",
42
+ "@lobechat/agent-tracing": "workspace:*",
43
+ "@lobechat/const": "workspace:*",
44
+ "@lobechat/device-control": "workspace:*",
45
+ "@lobechat/device-gateway-client": "workspace:*",
46
+ "@lobechat/device-identity": "workspace:*",
47
+ "@lobechat/device-mcp": "workspace:*",
48
+ "@lobechat/eval-rubric": "workspace:*",
49
+ "@lobechat/heterogeneous-agents": "workspace:*",
50
+ "@lobechat/html-artifact": "workspace:*",
51
+ "@lobechat/local-file-shell": "workspace:*",
52
+ "@lobechat/prompts": "workspace:*",
53
+ "@lobechat/tool-runtime": "workspace:*",
54
+ "@lobechat/types": "workspace:*",
55
+ "@lobechat/utils": "workspace:*",
56
+ "@modelcontextprotocol/client": "~2.4.0",
57
+ "@trpc/client": "^11.18.0",
58
+ "@types/node": "^24.13.2",
59
+ "@types/semver": "^7.7.1",
60
+ "@types/ws": "^8.18.1",
61
+ "commander": "^13.1.0",
62
+ "dayjs": "^1.11.21",
63
+ "debug": "^4.4.3",
64
+ "diff": "^8.0.4",
65
+ "es-toolkit": "^1.50.0",
66
+ "fast-glob": "^3.3.3",
67
+ "ignore": "^7.0.5",
68
+ "picocolors": "^1.1.1",
69
+ "semver": "^7.8.5",
70
+ "superjson": "^2.2.6",
71
+ "tinyexec": "^1.3.0",
72
+ "tree-kill": "^1.2.2",
73
+ "tsdown": "^0.21.10",
74
+ "typescript": "^6.0.3",
75
+ "url-join": "^5.0.0",
76
+ "vitest": "5.0.0",
77
+ "zod": "^4.4.3"
78
+ },
79
+ "engines": {
80
+ "node": ">=22.15"
81
+ },
82
+ "publishConfig": {
83
+ "access": "public",
84
+ "registry": "https://registry.npmjs.org"
85
+ },
86
+ "gitHead": "b1ae07bbb156616174079b367ceec9d20f3dac48"
87
+ }