@lobehub/cli 0.0.29 → 0.0.30
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/index.js +49 -23
- package/man/man1/lh.1 +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17349,6 +17349,13 @@ async function resolveToken(options) {
|
|
|
17349
17349
|
* Re-invokes the current CLI entry (`process.execPath` + `process.argv[1]`)
|
|
17350
17350
|
* instead of relying on `lh` being on `PATH`, so it also works inside the
|
|
17351
17351
|
* detached `lh connect --daemon` child where `PATH` may be minimal.
|
|
17352
|
+
*
|
|
17353
|
+
* Resolves only once the child's outcome is known: `accepted` on the `spawn`
|
|
17354
|
+
* event, `rejected` on an early `error`. `spawn()` reports failures (missing or
|
|
17355
|
+
* inaccessible `cwd`, etc.) asynchronously via `error`, so acking eagerly would
|
|
17356
|
+
* report a false success and leave the run with no process to emit
|
|
17357
|
+
* `heteroFinish` — surfacing as a stuck assistant message. A rejected ack
|
|
17358
|
+
* instead flows back as a dispatch failure the user can see.
|
|
17352
17359
|
*/
|
|
17353
17360
|
function spawnHeteroAgentRun(params, logger) {
|
|
17354
17361
|
const { agentType, cwd, jwt, operationId, prompt, resumeSessionId, serverUrl, systemContext, topicId } = params;
|
|
@@ -17371,19 +17378,6 @@ function spawnHeteroAgentRun(params, logger) {
|
|
|
17371
17378
|
workDir,
|
|
17372
17379
|
...resumeSessionId ? ["--resume", resumeSessionId] : []
|
|
17373
17380
|
];
|
|
17374
|
-
const child = spawn(process.execPath, [...process.execArgv, ...cliArgs], {
|
|
17375
|
-
cwd: workDir,
|
|
17376
|
-
env: {
|
|
17377
|
-
...process.env,
|
|
17378
|
-
LOBEHUB_JWT: jwt,
|
|
17379
|
-
LOBEHUB_SERVER: serverUrl
|
|
17380
|
-
},
|
|
17381
|
-
stdio: [
|
|
17382
|
-
"pipe",
|
|
17383
|
-
"inherit",
|
|
17384
|
-
"inherit"
|
|
17385
|
-
]
|
|
17386
|
-
});
|
|
17387
17381
|
const stdinPayload = systemContext ? JSON.stringify([{
|
|
17388
17382
|
text: systemContext,
|
|
17389
17383
|
type: "text"
|
|
@@ -17391,13 +17385,45 @@ function spawnHeteroAgentRun(params, logger) {
|
|
|
17391
17385
|
text: prompt,
|
|
17392
17386
|
type: "text"
|
|
17393
17387
|
}]) : JSON.stringify(prompt);
|
|
17394
|
-
|
|
17395
|
-
|
|
17396
|
-
|
|
17397
|
-
|
|
17398
|
-
|
|
17399
|
-
|
|
17400
|
-
|
|
17388
|
+
return new Promise((resolve) => {
|
|
17389
|
+
let settled = false;
|
|
17390
|
+
const settle = (result) => {
|
|
17391
|
+
if (settled) return;
|
|
17392
|
+
settled = true;
|
|
17393
|
+
resolve(result);
|
|
17394
|
+
};
|
|
17395
|
+
const child = spawn(process.execPath, [...process.execArgv, ...cliArgs], {
|
|
17396
|
+
cwd: workDir,
|
|
17397
|
+
env: {
|
|
17398
|
+
...process.env,
|
|
17399
|
+
LOBEHUB_JWT: jwt,
|
|
17400
|
+
LOBEHUB_SERVER: serverUrl
|
|
17401
|
+
},
|
|
17402
|
+
stdio: [
|
|
17403
|
+
"pipe",
|
|
17404
|
+
"inherit",
|
|
17405
|
+
"inherit"
|
|
17406
|
+
]
|
|
17407
|
+
});
|
|
17408
|
+
child.once("spawn", () => {
|
|
17409
|
+
try {
|
|
17410
|
+
child.stdin?.write(stdinPayload);
|
|
17411
|
+
child.stdin?.end();
|
|
17412
|
+
} catch (err) {
|
|
17413
|
+
logger?.error?.(`hetero exec stdin write failed (op=${operationId}): ${err.message}`);
|
|
17414
|
+
}
|
|
17415
|
+
settle({ status: "accepted" });
|
|
17416
|
+
});
|
|
17417
|
+
child.once("error", (err) => {
|
|
17418
|
+
logger?.error?.(`hetero exec spawn failed (op=${operationId}): ${err.message}`);
|
|
17419
|
+
settle({
|
|
17420
|
+
reason: err.message,
|
|
17421
|
+
status: "rejected"
|
|
17422
|
+
});
|
|
17423
|
+
});
|
|
17424
|
+
child.on("exit", (code, signal) => {
|
|
17425
|
+
logger?.info?.(`hetero exec exited (op=${operationId}) code=${code} signal=${signal}`);
|
|
17426
|
+
});
|
|
17401
17427
|
});
|
|
17402
17428
|
}
|
|
17403
17429
|
|
|
@@ -210016,10 +210042,10 @@ async function runConnect(options, isDaemonChild) {
|
|
|
210016
210042
|
}
|
|
210017
210043
|
});
|
|
210018
210044
|
});
|
|
210019
|
-
client.on("agent_run_request", (request) => {
|
|
210045
|
+
client.on("agent_run_request", async (request) => {
|
|
210020
210046
|
info(`Received agent_run_request: operationId=${request.operationId} type=${request.agentType}`);
|
|
210021
210047
|
try {
|
|
210022
|
-
spawnHeteroAgentRun({
|
|
210048
|
+
const ack = await spawnHeteroAgentRun({
|
|
210023
210049
|
agentType: request.agentType,
|
|
210024
210050
|
cwd: request.cwd,
|
|
210025
210051
|
jwt: request.jwt,
|
|
@@ -210035,7 +210061,7 @@ async function runConnect(options, isDaemonChild) {
|
|
|
210035
210061
|
});
|
|
210036
210062
|
client.sendAgentRunAck({
|
|
210037
210063
|
operationId: request.operationId,
|
|
210038
|
-
|
|
210064
|
+
...ack
|
|
210039
210065
|
});
|
|
210040
210066
|
} catch (err) {
|
|
210041
210067
|
const reason = err instanceof Error ? err.message : String(err);
|
package/man/man1/lh.1
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
.\" Code generated by `npm run man:generate`; DO NOT EDIT.
|
|
2
2
|
.\" Manual command details come from the Commander command tree.
|
|
3
|
-
.TH LH 1 "" "@lobehub/cli 0.0.
|
|
3
|
+
.TH LH 1 "" "@lobehub/cli 0.0.30" "User Commands"
|
|
4
4
|
.SH NAME
|
|
5
5
|
lh \- LobeHub CLI \- manage and connect to LobeHub services
|
|
6
6
|
.SH SYNOPSIS
|