@lobehub/cli 0.0.100 → 0.0.102
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 +65 -35
- package/man/man1/lh.1 +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -26567,6 +26567,15 @@ const subjectOf = (token) => {
|
|
|
26567
26567
|
return typeof sub === "string" && sub ? sub : void 0;
|
|
26568
26568
|
};
|
|
26569
26569
|
const isOperationTokenRefusal = (error) => isTRPCClientError(error) && error.data?.code === "UNAUTHORIZED" && error.message === "hetero-operation tokens are not accepted on this endpoint";
|
|
26570
|
+
/** A library destination cannot be filed as run-scoped evidence. The refusal
|
|
26571
|
+
* happens before createFile writes, so it can use the same one-shot, same-owner
|
|
26572
|
+
* fallback as a user-scoped endpoint. Never retry a general permission denial.
|
|
26573
|
+
*/
|
|
26574
|
+
const isLibraryUploadRefusal = (op, error) => {
|
|
26575
|
+
if (op.path !== "file.createFile" || !isTRPCClientError(error) || error.data?.code !== "FORBIDDEN" || !["This run's token can only upload acceptance evidence", "This run's token can only upload acceptance evidence or tool-result images"].includes(error.message)) return false;
|
|
26576
|
+
const input = op.input;
|
|
26577
|
+
return [input?.knowledgeBaseId, input?.parentId].some((id) => typeof id === "string" && id.length > 0);
|
|
26578
|
+
};
|
|
26570
26579
|
/**
|
|
26571
26580
|
* The stored login, when it is usable and belongs to the operation token's own
|
|
26572
26581
|
* account.
|
|
@@ -26591,7 +26600,7 @@ const operationTokenFallbackLink = (operationToken) => () => ({ next, op }) => o
|
|
|
26591
26600
|
let subscription = next(op).subscribe({
|
|
26592
26601
|
complete: () => observer.complete(),
|
|
26593
26602
|
error: (error) => {
|
|
26594
|
-
if (op.context[STORED_LOGIN] || !isOperationTokenRefusal(error)) {
|
|
26603
|
+
if (op.context[STORED_LOGIN] || !isOperationTokenRefusal(error) && !isLibraryUploadRefusal(op, error)) {
|
|
26595
26604
|
observer.error(error);
|
|
26596
26605
|
return;
|
|
26597
26606
|
}
|
|
@@ -63231,6 +63240,11 @@ const createCodexAgentHandle = async (options) => {
|
|
|
63231
63240
|
let nativeSessionId;
|
|
63232
63241
|
let cancelledSignal;
|
|
63233
63242
|
let nativeTurnInterrupted = false;
|
|
63243
|
+
let markTurnStarted;
|
|
63244
|
+
const turnStarted = new Promise((resolve) => {
|
|
63245
|
+
markTurnStarted = resolve;
|
|
63246
|
+
});
|
|
63247
|
+
let runEnded = false;
|
|
63234
63248
|
const provenance = pickCodexRunProvenance({
|
|
63235
63249
|
...options.env,
|
|
63236
63250
|
LOBEHUB_OPERATION_ID: options.operationId
|
|
@@ -63252,7 +63266,9 @@ const createCodexAgentHandle = async (options) => {
|
|
|
63252
63266
|
if (batch.some((event) => event.type === "agent_runtime_end" && event.data?.reason === "interrupted")) nativeTurnInterrupted = true;
|
|
63253
63267
|
events.push(batch);
|
|
63254
63268
|
},
|
|
63255
|
-
onRuntimeStatus: () => {
|
|
63269
|
+
onRuntimeStatus: (status) => {
|
|
63270
|
+
if (status.state === "running") markTurnStarted();
|
|
63271
|
+
},
|
|
63256
63272
|
onSessionId: (id) => {
|
|
63257
63273
|
nativeSessionId = id;
|
|
63258
63274
|
},
|
|
@@ -63275,37 +63291,39 @@ const createCodexAgentHandle = async (options) => {
|
|
|
63275
63291
|
operationId: options.operationId,
|
|
63276
63292
|
provenance
|
|
63277
63293
|
};
|
|
63294
|
+
const exit = (cancelledSignal ? Promise.resolve() : session.run(turnOptions)).then(() => {
|
|
63295
|
+
if (cancelledSignal) return {
|
|
63296
|
+
code: null,
|
|
63297
|
+
signal: cancelledSignal
|
|
63298
|
+
};
|
|
63299
|
+
if (!nativeTurnInterrupted) return {
|
|
63300
|
+
code: 0,
|
|
63301
|
+
signal: null
|
|
63302
|
+
};
|
|
63303
|
+
stderr.write("Codex app-server interrupted the turn before it completed\n");
|
|
63304
|
+
return {
|
|
63305
|
+
code: 1,
|
|
63306
|
+
signal: null
|
|
63307
|
+
};
|
|
63308
|
+
}, (error) => {
|
|
63309
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
63310
|
+
stderr.write(`${detail}\n`);
|
|
63311
|
+
return {
|
|
63312
|
+
code: cancelledSignal ? null : 1,
|
|
63313
|
+
signal: cancelledSignal ?? null
|
|
63314
|
+
};
|
|
63315
|
+
}).finally(() => {
|
|
63316
|
+
runEnded = true;
|
|
63317
|
+
session.close();
|
|
63318
|
+
client.close();
|
|
63319
|
+
stopStderr();
|
|
63320
|
+
events.close();
|
|
63321
|
+
stderr.end();
|
|
63322
|
+
jwtFile?.cleanup();
|
|
63323
|
+
});
|
|
63278
63324
|
return {
|
|
63279
63325
|
events,
|
|
63280
|
-
exit
|
|
63281
|
-
if (cancelledSignal) return {
|
|
63282
|
-
code: null,
|
|
63283
|
-
signal: cancelledSignal
|
|
63284
|
-
};
|
|
63285
|
-
if (!nativeTurnInterrupted) return {
|
|
63286
|
-
code: 0,
|
|
63287
|
-
signal: null
|
|
63288
|
-
};
|
|
63289
|
-
stderr.write("Codex app-server interrupted the turn before it completed\n");
|
|
63290
|
-
return {
|
|
63291
|
-
code: 1,
|
|
63292
|
-
signal: null
|
|
63293
|
-
};
|
|
63294
|
-
}, (error) => {
|
|
63295
|
-
const detail = error instanceof Error ? error.message : String(error);
|
|
63296
|
-
stderr.write(`${detail}\n`);
|
|
63297
|
-
return {
|
|
63298
|
-
code: cancelledSignal ? null : 1,
|
|
63299
|
-
signal: cancelledSignal ?? null
|
|
63300
|
-
};
|
|
63301
|
-
}).finally(() => {
|
|
63302
|
-
session.close();
|
|
63303
|
-
client.close();
|
|
63304
|
-
stopStderr();
|
|
63305
|
-
events.close();
|
|
63306
|
-
stderr.end();
|
|
63307
|
-
jwtFile?.cleanup();
|
|
63308
|
-
}),
|
|
63326
|
+
exit,
|
|
63309
63327
|
kill: (signal = "SIGINT") => {
|
|
63310
63328
|
cancel(signal).catch(() => {
|
|
63311
63329
|
session.close();
|
|
@@ -63313,6 +63331,17 @@ const createCodexAgentHandle = async (options) => {
|
|
|
63313
63331
|
});
|
|
63314
63332
|
},
|
|
63315
63333
|
pid: void 0,
|
|
63334
|
+
/**
|
|
63335
|
+
* Add a follow-up to the running turn (`turn/steer`). The app-server echoes it
|
|
63336
|
+
* as a user message carrying `uuid`, which confirms the delivery. Resolves
|
|
63337
|
+
* false when the turn takes no input (it ended, or a review or compaction
|
|
63338
|
+
* turn), so the caller sends the message as the next run instead.
|
|
63339
|
+
*/
|
|
63340
|
+
sendUserMessage: async (prompt, sendOptions) => {
|
|
63341
|
+
if (!await Promise.race([turnStarted.then(() => true), exit.then(() => false)]) || runEnded) return false;
|
|
63342
|
+
const plan = await buildAgentInput("codex", prompt);
|
|
63343
|
+
return await session.steer(buildCodexAppServerInput(plan), sendOptions?.uuid ?? randomUUID()) === "accepted";
|
|
63344
|
+
},
|
|
63316
63345
|
get sessionId() {
|
|
63317
63346
|
return nativeSessionId;
|
|
63318
63347
|
},
|
|
@@ -581628,13 +581657,14 @@ const isPermanentRefusal = (error) => {
|
|
|
581628
581657
|
const isUserMessageReplay = (event) => event.type === "step_complete" && event.data?.phase === "user_message" && typeof event.data?.uuid === "string";
|
|
581629
581658
|
const isMainStreamStart = (event) => event.type === "stream_start" && !event.data?.subagent;
|
|
581630
581659
|
/**
|
|
581631
|
-
* Stream a Claude Code run's events while typing the
|
|
581632
|
-
* queues behind it into the live session (steer), instead
|
|
581633
|
-
* the next turn.
|
|
581660
|
+
* Stream a Claude Code or native Codex run's events while typing the
|
|
581661
|
+
* follow-ups the user queues behind it into the live session (steer), instead
|
|
581662
|
+
* of leaving them for the next turn.
|
|
581634
581663
|
*
|
|
581635
581664
|
* Polls `aiAgent.waitHeteroSteer` for as long as the run streams and its
|
|
581636
581665
|
* session takes input; a message the session refuses goes back with
|
|
581637
|
-
* `aiAgent.returnHeteroSteer`.
|
|
581666
|
+
* `aiAgent.returnHeteroSteer`. The agent reports every message it picks up
|
|
581667
|
+
* (Claude Code replays it, Codex echoes its client id):
|
|
581638
581668
|
* the replay of a delivery is forwarded for the server to write the message
|
|
581639
581669
|
* into the conversation; any other replay (the run's own prompt) is dropped.
|
|
581640
581670
|
* Once the server answered, the next main `stream_start` carries `liveSteer`
|
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.102" "User Commands"
|
|
4
4
|
.SH NAME
|
|
5
5
|
lh \- LobeHub CLI \- manage and connect to LobeHub services
|
|
6
6
|
.SH SYNOPSIS
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.102",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/lobehub/lobehub",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"access": "public",
|
|
84
84
|
"registry": "https://registry.npmjs.org"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "6933028268f628a950b855ba02dc28d1e384210b"
|
|
87
87
|
}
|