@lobehub/cli 0.0.224 → 0.0.226
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/acceptance-report.html +1 -1
- package/dist/index.js +155 -320
- package/man/man1/lh.1 +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -199,14 +199,27 @@ const firstEnvEntry = (names) => {
|
|
|
199
199
|
}
|
|
200
200
|
};
|
|
201
201
|
const firstEnvValue = (names) => firstEnvEntry(names)?.value;
|
|
202
|
-
/**
|
|
203
|
-
|
|
202
|
+
/**
|
|
203
|
+
* Whether this process runs inside a LobeHub agent run: the app stamps the run's ids into the
|
|
204
|
+
* environment of every agent it launches, and every shell that agent opens inherits them (Codex
|
|
205
|
+
* included, through `shell_environment_policy.set`).
|
|
206
|
+
*/
|
|
207
|
+
const isInsideAgentRun = (env = process.env) => !!(env.LOBEHUB_TOPIC_ID || env.LOBEHUB_OPERATION_ID);
|
|
208
|
+
/**
|
|
209
|
+
* API key from the environment, honouring every accepted variable name.
|
|
210
|
+
*
|
|
211
|
+
* Inside an agent run there is none: the run authenticates with its own sign-in
|
|
212
|
+
* (`LOBEHUB_JWT`), and a key the user exported in their shell belongs to this
|
|
213
|
+
* machine, not to the run — the same reason the stored login is not read there
|
|
214
|
+
* (`getValidToken`).
|
|
215
|
+
*/
|
|
216
|
+
const readCliApiKeyEnv = () => isInsideAgentRun() ? void 0 : firstEnvValue(CLI_API_KEY_ENV_NAMES);
|
|
204
217
|
/**
|
|
205
218
|
* Same lookup as {@link readCliApiKeyEnv}, but keeps the variable name that
|
|
206
219
|
* actually matched. `lh doctor` reports which env var a credential came from,
|
|
207
220
|
* and "LOBEHUB_CLI_API_KEY" is the wrong answer when an older alias won.
|
|
208
221
|
*/
|
|
209
|
-
const readCliApiKeyEnvSource = () => firstEnvEntry(CLI_API_KEY_ENV_NAMES);
|
|
222
|
+
const readCliApiKeyEnvSource = () => isInsideAgentRun() ? void 0 : firstEnvEntry(CLI_API_KEY_ENV_NAMES);
|
|
210
223
|
/** Config directory name, overridable per-install by the home env var. */
|
|
211
224
|
const resolveCliDirName = () => firstEnvValue(CLI_HOME_ENV_NAMES) ?? ".lobehub";
|
|
212
225
|
|
|
@@ -302,7 +315,7 @@ function clearCredentials() {
|
|
|
302
315
|
function resolveIdentityFingerprint() {
|
|
303
316
|
const envJwt = process.env.LOBEHUB_JWT;
|
|
304
317
|
if (envJwt) return userIdentity(envJwt);
|
|
305
|
-
if (readCliApiKeyEnv()) return void 0;
|
|
318
|
+
if (readCliApiKeyEnv() || isInsideAgentRun()) return void 0;
|
|
306
319
|
const stored = loadCredentials();
|
|
307
320
|
return stored?.accessToken ? userIdentity(stored.accessToken) : void 0;
|
|
308
321
|
}
|
|
@@ -18486,8 +18499,8 @@ const rw = (read, write) => ({
|
|
|
18486
18499
|
*/
|
|
18487
18500
|
const TRPC_NAMESPACE_API_KEY_RULES = {
|
|
18488
18501
|
accountDeletion: "blocked",
|
|
18489
|
-
acceptance: "
|
|
18490
|
-
acceptanceComment: "
|
|
18502
|
+
acceptance: rw("acceptance:read", "acceptance:write"),
|
|
18503
|
+
acceptanceComment: rw("acceptance:read", "acceptance:write"),
|
|
18491
18504
|
agent: rw("agent:read", "agent:write"),
|
|
18492
18505
|
agentAccount: rw("agent:read", "agent:write"),
|
|
18493
18506
|
agentAvailability: rw("agent:read", null),
|
|
@@ -18504,7 +18517,7 @@ const TRPC_NAMESPACE_API_KEY_RULES = {
|
|
|
18504
18517
|
agentSkills: rw("agent:read", "agent:write"),
|
|
18505
18518
|
agentSteerQueue: rw("agent:read", "agent:write"),
|
|
18506
18519
|
agentRunBoard: "blocked",
|
|
18507
|
-
agentTrace: "
|
|
18520
|
+
agentTrace: rw("trace:read", null),
|
|
18508
18521
|
aiAgent: rw("agent:read", "agent:write"),
|
|
18509
18522
|
aiChat: { any: "model:invoke" },
|
|
18510
18523
|
aiModel: rw("model:read", "model:write"),
|
|
@@ -18514,7 +18527,7 @@ const TRPC_NAMESPACE_API_KEY_RULES = {
|
|
|
18514
18527
|
auth: "open",
|
|
18515
18528
|
artboard: "blocked",
|
|
18516
18529
|
artifactShare: rw("chat:read", null),
|
|
18517
|
-
botMessage: "
|
|
18530
|
+
botMessage: { any: "bot:message" },
|
|
18518
18531
|
brief: rw("chat:read", "chat:write"),
|
|
18519
18532
|
canvas: "blocked",
|
|
18520
18533
|
changelog: "open",
|
|
@@ -18526,7 +18539,7 @@ const TRPC_NAMESPACE_API_KEY_RULES = {
|
|
|
18526
18539
|
config: "open",
|
|
18527
18540
|
connector: "blocked",
|
|
18528
18541
|
dashboard: rw("agent:read", null),
|
|
18529
|
-
device:
|
|
18542
|
+
device: rw(null, null),
|
|
18530
18543
|
deviceMetric: "blocked",
|
|
18531
18544
|
document: rw("knowledge:read", "knowledge:write"),
|
|
18532
18545
|
documentComment: rw("knowledge:read", "knowledge:write"),
|
|
@@ -18601,7 +18614,7 @@ const TRPC_NAMESPACE_API_KEY_RULES = {
|
|
|
18601
18614
|
userMemories: rw("user:read", "user:write"),
|
|
18602
18615
|
userMemory: rw("user:read", "user:write"),
|
|
18603
18616
|
userSkill: rw("agent:read", "agent:write"),
|
|
18604
|
-
verify: "
|
|
18617
|
+
verify: rw("acceptance:read", "acceptance:write"),
|
|
18605
18618
|
video: { any: "model:invoke" },
|
|
18606
18619
|
waitlist: "blocked",
|
|
18607
18620
|
webBrowsing: { any: "model:invoke" },
|
|
@@ -21083,7 +21096,7 @@ const DEFAULT_AGENT_CONFIG = {
|
|
|
21083
21096
|
|
|
21084
21097
|
//#endregion
|
|
21085
21098
|
//#region ../../package.json
|
|
21086
|
-
var version$2 = "2.3.
|
|
21099
|
+
var version$2 = "2.3.6";
|
|
21087
21100
|
|
|
21088
21101
|
//#endregion
|
|
21089
21102
|
//#region ../../packages/const/src/version.ts
|
|
@@ -26671,7 +26684,7 @@ const GOMS_KLM_TIMING_SECONDS = {
|
|
|
26671
26684
|
};
|
|
26672
26685
|
|
|
26673
26686
|
//#endregion
|
|
26674
|
-
//#region node_modules/.pnpm/@trpc+server@11.29.
|
|
26687
|
+
//#region node_modules/.pnpm/@trpc+server@11.29.10_@types+ws@8.18.2_typescript@6.0.3/node_modules/@trpc/server/dist/observable-CodTG6Sf.mjs
|
|
26675
26688
|
/**
|
|
26676
26689
|
* Creates an observable. `subscribe` runs for each subscriber, and can
|
|
26677
26690
|
* return a function that cleans up when it unsubscribes.
|
|
@@ -26685,7 +26698,7 @@ const GOMS_KLM_TIMING_SECONDS = {
|
|
|
26685
26698
|
* @see https://trpc.io/docs/client/links#creating-a-custom-link
|
|
26686
26699
|
* @public
|
|
26687
26700
|
*/
|
|
26688
|
-
function observable
|
|
26701
|
+
function observable(subscribe) {
|
|
26689
26702
|
const self = {
|
|
26690
26703
|
subscribe(observer) {
|
|
26691
26704
|
let teardownRef = null;
|
|
@@ -26744,12 +26757,12 @@ function observable$1(subscribe) {
|
|
|
26744
26757
|
return { unsubscribe };
|
|
26745
26758
|
},
|
|
26746
26759
|
pipe(...operations) {
|
|
26747
|
-
return operations.reduce(pipeReducer
|
|
26760
|
+
return operations.reduce(pipeReducer, self);
|
|
26748
26761
|
}
|
|
26749
26762
|
};
|
|
26750
26763
|
return self;
|
|
26751
26764
|
}
|
|
26752
|
-
function pipeReducer
|
|
26765
|
+
function pipeReducer(prev, fn) {
|
|
26753
26766
|
return fn(prev);
|
|
26754
26767
|
}
|
|
26755
26768
|
/**
|
|
@@ -26897,7 +26910,7 @@ function observableToAsyncIterable(observable, signal) {
|
|
|
26897
26910
|
}
|
|
26898
26911
|
|
|
26899
26912
|
//#endregion
|
|
26900
|
-
//#region node_modules/.pnpm/@trpc+server@11.29.
|
|
26913
|
+
//#region node_modules/.pnpm/@trpc+server@11.29.10_@types+ws@8.18.2_typescript@6.0.3/node_modules/@trpc/server/dist/observable-BjUZYMQq.mjs
|
|
26901
26914
|
/**
|
|
26902
26915
|
* Shares one subscription to the source between all subscribers. It
|
|
26903
26916
|
* starts with the first subscriber and ends when the last unsubscribes.
|
|
@@ -26965,7 +26978,7 @@ function share(_opts) {
|
|
|
26965
26978
|
function resetIfNeeded() {
|
|
26966
26979
|
if (refCount === 0 && subscription) resetSource();
|
|
26967
26980
|
}
|
|
26968
|
-
return observable
|
|
26981
|
+
return observable((subscriber) => {
|
|
26969
26982
|
refCount++;
|
|
26970
26983
|
const subscriberObservers = observers;
|
|
26971
26984
|
subscriberObservers.add(subscriber);
|
|
@@ -27007,7 +27020,7 @@ function behaviorSubject(initialValue) {
|
|
|
27007
27020
|
const removeObserver = (observer) => {
|
|
27008
27021
|
observerList.delete(observer);
|
|
27009
27022
|
};
|
|
27010
|
-
const obs = observable
|
|
27023
|
+
const obs = observable((observer) => {
|
|
27011
27024
|
addObserver(observer);
|
|
27012
27025
|
return () => {
|
|
27013
27026
|
removeObserver(observer);
|
|
@@ -27023,10 +27036,10 @@ function behaviorSubject(initialValue) {
|
|
|
27023
27036
|
}
|
|
27024
27037
|
|
|
27025
27038
|
//#endregion
|
|
27026
|
-
//#region node_modules/.pnpm/@trpc+client@11.29.
|
|
27039
|
+
//#region node_modules/.pnpm/@trpc+client@11.29.10_@trpc+server@11.29.10_@types+ws@8.18.2_typescript@6.0.3__typescript@6.0.3/node_modules/@trpc/client/dist/splitLink-PFsRy7Mf.mjs
|
|
27027
27040
|
/** @internal */
|
|
27028
27041
|
function createChain(opts) {
|
|
27029
|
-
return observable
|
|
27042
|
+
return observable((observer) => {
|
|
27030
27043
|
function execute(index = 0, op = opts.op) {
|
|
27031
27044
|
const next = opts.links[index];
|
|
27032
27045
|
if (!next) throw new Error("No more links to execute - did you forget to add an ending link?");
|
|
@@ -27042,7 +27055,7 @@ function createChain(opts) {
|
|
|
27042
27055
|
}
|
|
27043
27056
|
|
|
27044
27057
|
//#endregion
|
|
27045
|
-
//#region node_modules/.pnpm/@trpc+client@11.29.
|
|
27058
|
+
//#region node_modules/.pnpm/@trpc+client@11.29.10_@trpc+server@11.29.10_@types+ws@8.18.2_typescript@6.0.3__typescript@6.0.3/node_modules/@trpc/client/dist/objectSpread2-pyA4QVO4.mjs
|
|
27046
27059
|
function _typeof$1(o) {
|
|
27047
27060
|
"@babel/helpers - typeof";
|
|
27048
27061
|
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -27096,7 +27109,7 @@ function _objectSpread2$1(e) {
|
|
|
27096
27109
|
}
|
|
27097
27110
|
|
|
27098
27111
|
//#endregion
|
|
27099
|
-
//#region node_modules/.pnpm/@trpc+server@11.29.
|
|
27112
|
+
//#region node_modules/.pnpm/@trpc+server@11.29.10_@types+ws@8.18.2_typescript@6.0.3/node_modules/@trpc/server/dist/codes-BCsCCyMj.mjs
|
|
27100
27113
|
/**
|
|
27101
27114
|
* Check that value is object
|
|
27102
27115
|
* @internal
|
|
@@ -27159,7 +27172,7 @@ const retryableRpcCodes = [
|
|
|
27159
27172
|
];
|
|
27160
27173
|
|
|
27161
27174
|
//#endregion
|
|
27162
|
-
//#region node_modules/.pnpm/@trpc+server@11.29.
|
|
27175
|
+
//#region node_modules/.pnpm/@trpc+server@11.29.10_@types+ws@8.18.2_typescript@6.0.3/node_modules/@trpc/server/dist/getErrorShape-CVrl8_-w.mjs
|
|
27163
27176
|
const noop$4 = () => {};
|
|
27164
27177
|
const freezeIfAvailable = (obj) => {
|
|
27165
27178
|
if (Object.freeze) Object.freeze(obj);
|
|
@@ -27264,7 +27277,7 @@ function _objectSpread2(e) {
|
|
|
27264
27277
|
}
|
|
27265
27278
|
|
|
27266
27279
|
//#endregion
|
|
27267
|
-
//#region node_modules/.pnpm/@trpc+server@11.29.
|
|
27280
|
+
//#region node_modules/.pnpm/@trpc+server@11.29.10_@types+ws@8.18.2_typescript@6.0.3/node_modules/@trpc/server/dist/asyncGeneratorDelegate-qZNHzmPI.mjs
|
|
27268
27281
|
/** @internal */
|
|
27269
27282
|
function transformResultInner(response, transformer) {
|
|
27270
27283
|
if ("error" in response) {
|
|
@@ -27370,7 +27383,7 @@ AsyncGenerator$1.prototype["function" == typeof Symbol && Symbol.asyncIterator |
|
|
|
27370
27383
|
};
|
|
27371
27384
|
|
|
27372
27385
|
//#endregion
|
|
27373
|
-
//#region node_modules/.pnpm/@trpc+client@11.29.
|
|
27386
|
+
//#region node_modules/.pnpm/@trpc+client@11.29.10_@trpc+server@11.29.10_@types+ws@8.18.2_typescript@6.0.3__typescript@6.0.3/node_modules/@trpc/client/dist/TRPCClientError-DE6-fd1n.mjs
|
|
27374
27387
|
/**
|
|
27375
27388
|
* Whether a value is a `TRPCClientError`, typed for a router or procedure.
|
|
27376
27389
|
* @see https://trpc.io/docs/client/vanilla/error-handling#catching-a-thrown-error
|
|
@@ -27426,7 +27439,7 @@ var TRPCClientError = class TRPCClientError extends Error {
|
|
|
27426
27439
|
};
|
|
27427
27440
|
|
|
27428
27441
|
//#endregion
|
|
27429
|
-
//#region node_modules/.pnpm/@trpc+client@11.29.
|
|
27442
|
+
//#region node_modules/.pnpm/@trpc+client@11.29.10_@trpc+server@11.29.10_@types+ws@8.18.2_typescript@6.0.3__typescript@6.0.3/node_modules/@trpc/client/dist/unstable-internals.mjs
|
|
27430
27443
|
/**
|
|
27431
27444
|
* @internal
|
|
27432
27445
|
*/
|
|
@@ -27453,7 +27466,7 @@ function getTransformer(transformer) {
|
|
|
27453
27466
|
}
|
|
27454
27467
|
|
|
27455
27468
|
//#endregion
|
|
27456
|
-
//#region node_modules/.pnpm/@trpc+client@11.29.
|
|
27469
|
+
//#region node_modules/.pnpm/@trpc+client@11.29.10_@trpc+server@11.29.10_@types+ws@8.18.2_typescript@6.0.3__typescript@6.0.3/node_modules/@trpc/client/dist/httpUtils-CtMuyl9j.mjs
|
|
27457
27470
|
const isFunction$1 = (fn) => typeof fn === "function";
|
|
27458
27471
|
/**
|
|
27459
27472
|
* The `fetch` to use: `customFetchImpl` if given, or else the global one.
|
|
@@ -27589,7 +27602,7 @@ async function httpRequest(opts) {
|
|
|
27589
27602
|
}
|
|
27590
27603
|
|
|
27591
27604
|
//#endregion
|
|
27592
|
-
//#region node_modules/.pnpm/@trpc+client@11.29.
|
|
27605
|
+
//#region node_modules/.pnpm/@trpc+client@11.29.10_@trpc+server@11.29.10_@types+ws@8.18.2_typescript@6.0.3__typescript@6.0.3/node_modules/@trpc/client/dist/httpLink-B4UwXApa.mjs
|
|
27593
27606
|
/** Whether an input is binary: a `Uint8Array`, `Blob` or `File`. */
|
|
27594
27607
|
function isOctetType(input) {
|
|
27595
27608
|
return input instanceof Uint8Array || input instanceof Blob;
|
|
@@ -27630,7 +27643,7 @@ function httpLink(opts) {
|
|
|
27630
27643
|
return () => {
|
|
27631
27644
|
return (operationOpts) => {
|
|
27632
27645
|
const { op } = operationOpts;
|
|
27633
|
-
return observable
|
|
27646
|
+
return observable((observer) => {
|
|
27634
27647
|
const { path, input, type } = op;
|
|
27635
27648
|
/* istanbul ignore if -- @preserve */
|
|
27636
27649
|
if (type === "subscription") throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");
|
|
@@ -27682,7 +27695,7 @@ function httpLink(opts) {
|
|
|
27682
27695
|
}
|
|
27683
27696
|
|
|
27684
27697
|
//#endregion
|
|
27685
|
-
//#region node_modules/.pnpm/@trpc+client@11.29.
|
|
27698
|
+
//#region node_modules/.pnpm/@trpc+client@11.29.10_@trpc+server@11.29.10_@types+ws@8.18.2_typescript@6.0.3__typescript@6.0.3/node_modules/@trpc/client/dist/wsLink-DYx-NUSN.mjs
|
|
27686
27699
|
/**
|
|
27687
27700
|
* Get the result of a value or function that returns a value
|
|
27688
27701
|
* It also optionally accepts typesafe arguments for the function
|
|
@@ -27872,7 +27885,7 @@ var WsConnection = class WsConnection {
|
|
|
27872
27885
|
_defineProperty$1(WsConnection, "connectCount", 0);
|
|
27873
27886
|
|
|
27874
27887
|
//#endregion
|
|
27875
|
-
//#region node_modules/.pnpm/@trpc+client@11.29.
|
|
27888
|
+
//#region node_modules/.pnpm/@trpc+client@11.29.10_@trpc+server@11.29.10_@types+ws@8.18.2_typescript@6.0.3__typescript@6.0.3/node_modules/@trpc/client/dist/index.mjs
|
|
27876
27889
|
const observerKeys = [
|
|
27877
27890
|
"onStarted",
|
|
27878
27891
|
"onData",
|
|
@@ -27942,7 +27955,7 @@ var TRPCUntypedClient = class {
|
|
|
27942
27955
|
});
|
|
27943
27956
|
if (!hasCallbacks) {
|
|
27944
27957
|
var _opts$signal;
|
|
27945
|
-
const iterator = observableToAsyncIterable(observable
|
|
27958
|
+
const iterator = observableToAsyncIterable(observable((observer) => observable$.subscribe({
|
|
27946
27959
|
next(envelope) {
|
|
27947
27960
|
if (envelope.result.type === "data" || envelope.result.type === void 0) observer.next(envelope.result.data);
|
|
27948
27961
|
},
|
|
@@ -28958,6 +28971,7 @@ let refreshInFlight;
|
|
|
28958
28971
|
* Get a valid access token, refreshing if expired.
|
|
28959
28972
|
*/
|
|
28960
28973
|
async function getValidToken(bufferSeconds = 60) {
|
|
28974
|
+
if (isInsideAgentRun()) return { status: "agent-run" };
|
|
28961
28975
|
const credentials = loadCredentials();
|
|
28962
28976
|
if (!credentials) return { status: "no-login" };
|
|
28963
28977
|
if (credentials.expiresAt && Date.now() / 1e3 < credentials.expiresAt - bufferSeconds) return {
|
|
@@ -28989,22 +29003,16 @@ const refreshStoredToken = async (credentials) => {
|
|
|
28989
29003
|
};
|
|
28990
29004
|
};
|
|
28991
29005
|
/**
|
|
28992
|
-
*
|
|
28993
|
-
* environment of every agent it launches, and every shell that agent opens inherits them.
|
|
28994
|
-
*/
|
|
28995
|
-
const isInsideAgentRun = (env = process.env) => !!(env.LOBEHUB_TOPIC_ID || env.LOBEHUB_OPERATION_ID);
|
|
28996
|
-
/**
|
|
28997
|
-
* The missing-login report for a command run by an agent inside LobeHub.
|
|
29006
|
+
* The report for a command run by an agent inside LobeHub without the run's own sign-in.
|
|
28998
29007
|
*
|
|
28999
|
-
* Read by the agent, not by a person at a terminal
|
|
29000
|
-
*
|
|
29001
|
-
*
|
|
29002
|
-
*
|
|
29003
|
-
|
|
29004
|
-
|
|
29005
|
-
|
|
29006
|
-
|
|
29007
|
-
fix: `Ask the user to run '${"lh"} login' in a terminal on this machine and approve it in the browser, then retry. Do not run it yourself; restarting LobeHub does not fix this. Updating LobeHub Desktop lets local agents use the app's own sign-in.`
|
|
29008
|
+
* Read by the agent, not by a person at a terminal. Inside a run `lh` uses only the sign-in the
|
|
29009
|
+
* run passed it, never this machine's login or API key, so a bare "run `lh login`" would send the
|
|
29010
|
+
* agent after exactly the credential it must not use. Spell out the cause and the one fix that
|
|
29011
|
+
* works: a LobeHub that passes the run its sign-in.
|
|
29012
|
+
*/
|
|
29013
|
+
const agentRunNoSignInReport = () => ({
|
|
29014
|
+
detail: "This command runs inside a LobeHub agent run, but the run passed no LobeHub sign-in to the CLI. Inside an agent run the CLI uses only the run's own sign-in, never this machine's login or API key.",
|
|
29015
|
+
fix: `Tell the user that LobeHub (Desktop, or '${"lh"} connect' on this machine) needs updating so its runs carry their sign-in. Do not run '${"lh"} login', set an API key, or clear the run's environment to get around this.`
|
|
29008
29016
|
});
|
|
29009
29017
|
/**
|
|
29010
29018
|
* How to explain a lookup that produced no token, or `undefined` when there is nothing to
|
|
@@ -29012,7 +29020,7 @@ const agentRunMissingLoginReport = () => ({
|
|
|
29012
29020
|
*/
|
|
29013
29021
|
function describeTokenLookup(lookup) {
|
|
29014
29022
|
switch (lookup.status) {
|
|
29015
|
-
case "
|
|
29023
|
+
case "agent-run": return agentRunNoSignInReport();
|
|
29016
29024
|
case "spent": return {
|
|
29017
29025
|
detail: `The stored login is no longer valid (${lookup.detail}).`,
|
|
29018
29026
|
fix: `Run '${"lh"} login' again.`
|
|
@@ -29121,6 +29129,11 @@ function pickAuthSource(options = {}) {
|
|
|
29121
29129
|
token: apiKey.value,
|
|
29122
29130
|
tokenType: "apiKey"
|
|
29123
29131
|
};
|
|
29132
|
+
if (isInsideAgentRun()) return {
|
|
29133
|
+
kind: "stored",
|
|
29134
|
+
origin: "none: an agent run uses only its own sign-in",
|
|
29135
|
+
tokenType: "jwt"
|
|
29136
|
+
};
|
|
29124
29137
|
return {
|
|
29125
29138
|
kind: "stored",
|
|
29126
29139
|
origin: `stored login (${credentialsPath()})`,
|
|
@@ -29155,198 +29168,6 @@ const cliVersion = pkg.version;
|
|
|
29155
29168
|
/** The node range this build is published for, e.g. `>=22.15`. */
|
|
29156
29169
|
const cliNodeEngine = pkg.engines?.node;
|
|
29157
29170
|
|
|
29158
|
-
//#endregion
|
|
29159
|
-
//#region ../../node_modules/.pnpm/@trpc+server@11.29.7_@types+aws-lambda@8.10.164_@types+express@5.0.6_@types+ws@8.18.2_n_4a5bbc7e05a0f03e83d6e27192082686/node_modules/@trpc/server/dist/observable-CodTG6Sf.mjs
|
|
29160
|
-
/**
|
|
29161
|
-
* Creates an observable. `subscribe` runs for each subscriber, and can
|
|
29162
|
-
* return a function that cleans up when it unsubscribes.
|
|
29163
|
-
* @example
|
|
29164
|
-
* ```ts
|
|
29165
|
-
* const ticks = observable<number>((observer) => {
|
|
29166
|
-
* const timer = setInterval(() => observer.next(Date.now()), 1000);
|
|
29167
|
-
* return () => clearInterval(timer);
|
|
29168
|
-
* });
|
|
29169
|
-
* ```
|
|
29170
|
-
* @see https://trpc.io/docs/client/links#creating-a-custom-link
|
|
29171
|
-
* @public
|
|
29172
|
-
*/
|
|
29173
|
-
function observable(subscribe) {
|
|
29174
|
-
const self = {
|
|
29175
|
-
subscribe(observer) {
|
|
29176
|
-
let teardownRef = null;
|
|
29177
|
-
let isDone = false;
|
|
29178
|
-
let unsubscribed = false;
|
|
29179
|
-
let teardownImmediately = false;
|
|
29180
|
-
let subscribing = true;
|
|
29181
|
-
let thrownWhileSubscribing = null;
|
|
29182
|
-
function end(notify) {
|
|
29183
|
-
try {
|
|
29184
|
-
notify();
|
|
29185
|
-
} catch (cause) {
|
|
29186
|
-
var _thrownWhileSubscribi;
|
|
29187
|
-
if (!subscribing) throw cause;
|
|
29188
|
-
(_thrownWhileSubscribi = thrownWhileSubscribing) !== null && _thrownWhileSubscribi !== void 0 || (thrownWhileSubscribing = { cause });
|
|
29189
|
-
} finally {
|
|
29190
|
-
unsubscribe();
|
|
29191
|
-
}
|
|
29192
|
-
}
|
|
29193
|
-
function unsubscribe() {
|
|
29194
|
-
if (teardownRef === null) {
|
|
29195
|
-
teardownImmediately = true;
|
|
29196
|
-
return;
|
|
29197
|
-
}
|
|
29198
|
-
if (unsubscribed) return;
|
|
29199
|
-
unsubscribed = true;
|
|
29200
|
-
if (typeof teardownRef === "function") teardownRef();
|
|
29201
|
-
else if (teardownRef) teardownRef.unsubscribe();
|
|
29202
|
-
}
|
|
29203
|
-
teardownRef = subscribe({
|
|
29204
|
-
next(value) {
|
|
29205
|
-
var _observer$next;
|
|
29206
|
-
if (isDone) return;
|
|
29207
|
-
(_observer$next = observer.next) === null || _observer$next === void 0 || _observer$next.call(observer, value);
|
|
29208
|
-
},
|
|
29209
|
-
error(err) {
|
|
29210
|
-
if (isDone) return;
|
|
29211
|
-
isDone = true;
|
|
29212
|
-
end(() => {
|
|
29213
|
-
var _observer$error;
|
|
29214
|
-
return (_observer$error = observer.error) === null || _observer$error === void 0 ? void 0 : _observer$error.call(observer, err);
|
|
29215
|
-
});
|
|
29216
|
-
},
|
|
29217
|
-
complete() {
|
|
29218
|
-
if (isDone) return;
|
|
29219
|
-
isDone = true;
|
|
29220
|
-
end(() => {
|
|
29221
|
-
var _observer$complete;
|
|
29222
|
-
return (_observer$complete = observer.complete) === null || _observer$complete === void 0 ? void 0 : _observer$complete.call(observer);
|
|
29223
|
-
});
|
|
29224
|
-
}
|
|
29225
|
-
});
|
|
29226
|
-
subscribing = false;
|
|
29227
|
-
if (teardownImmediately) unsubscribe();
|
|
29228
|
-
if (thrownWhileSubscribing) throw thrownWhileSubscribing.cause;
|
|
29229
|
-
return { unsubscribe };
|
|
29230
|
-
},
|
|
29231
|
-
pipe(...operations) {
|
|
29232
|
-
return operations.reduce(pipeReducer, self);
|
|
29233
|
-
}
|
|
29234
|
-
};
|
|
29235
|
-
return self;
|
|
29236
|
-
}
|
|
29237
|
-
function pipeReducer(prev, fn) {
|
|
29238
|
-
return fn(prev);
|
|
29239
|
-
}
|
|
29240
|
-
|
|
29241
|
-
//#endregion
|
|
29242
|
-
//#region src/api/operationTokenFallback.ts
|
|
29243
|
-
/**
|
|
29244
|
-
* Device-dispatched runs (desktop gateway, `lh connect`) carry the run's narrow
|
|
29245
|
-
* `hetero-operation` token in `LOBEHUB_JWT`. It is accepted by the operation
|
|
29246
|
-
* endpoints (`heteroIngest`, `goal.*Operation`, …) and refused by every
|
|
29247
|
-
* user-scoped one, while it still outranks the machine's stored login. So an
|
|
29248
|
-
* agent's `lh doc` / `lh kb` / … failed until the agent itself cleared the
|
|
29249
|
-
* variable — an instruction the `lh` guide had to teach, and one an agent then
|
|
29250
|
-
* applied to errors it did not fit.
|
|
29251
|
-
*
|
|
29252
|
-
* The refusal is a fixed `oidcAuth` answer, so the client recognises exactly it
|
|
29253
|
-
* and re-sends that one request with the stored login — but only when that
|
|
29254
|
-
* login is the same account the operation token was minted for. A workspace
|
|
29255
|
-
* device is reachable by every member, so the machine's login can belong to
|
|
29256
|
-
* someone other than the member whose run this is; borrowing it would read and
|
|
29257
|
-
* write that person's data. Everything else is unchanged: operation endpoints
|
|
29258
|
-
* keep the operation token, and the workspace header stays the run's own scope
|
|
29259
|
-
* (`LOBEHUB_WORKSPACE_ID` or personal) — which the manual fallback did not do,
|
|
29260
|
-
* since an empty `LOBEHUB_JWT` re-enables the terminal's persisted
|
|
29261
|
-
* `lh workspace use` scope.
|
|
29262
|
-
*
|
|
29263
|
-
* Reads with an operation-authenticated route need neither: `lh topic view`
|
|
29264
|
-
* tries `topic.getTopicTranscriptOperation` first (`commands/topic/readTranscript`).
|
|
29265
|
-
*/
|
|
29266
|
-
/** `oidcAuth`'s message when an operation token reaches a user-scoped route. */
|
|
29267
|
-
const OPERATION_TOKEN_REFUSAL = "hetero-operation tokens are not accepted on this endpoint";
|
|
29268
|
-
/** Operation-context key carrying the stored login on the request the link re-sends. */
|
|
29269
|
-
const STORED_LOGIN = "storedLogin";
|
|
29270
|
-
const isOperationToken = (token) => !!token && parseJwtPayload(token)?.purpose === "hetero-operation";
|
|
29271
|
-
const subjectOf = (token) => {
|
|
29272
|
-
const sub = parseJwtPayload(token)?.sub;
|
|
29273
|
-
return typeof sub === "string" && sub ? sub : void 0;
|
|
29274
|
-
};
|
|
29275
|
-
const isOperationTokenRefusal = (error) => isTRPCClientError(error) && error.data?.code === "UNAUTHORIZED" && error.message === "hetero-operation tokens are not accepted on this endpoint";
|
|
29276
|
-
/** A library destination cannot be filed as run-scoped evidence. The refusal
|
|
29277
|
-
* happens before createFile writes, so it can use the same one-shot, same-owner
|
|
29278
|
-
* fallback as a user-scoped endpoint. Never retry a general permission denial.
|
|
29279
|
-
*/
|
|
29280
|
-
const isLibraryUploadRefusal = (op, error) => {
|
|
29281
|
-
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;
|
|
29282
|
-
const input = op.input;
|
|
29283
|
-
return [input?.knowledgeBaseId, input?.parentId].some((id) => typeof id === "string" && id.length > 0);
|
|
29284
|
-
};
|
|
29285
|
-
/**
|
|
29286
|
-
* The stored login, when it is usable and belongs to the operation token's own
|
|
29287
|
-
* account.
|
|
29288
|
-
*/
|
|
29289
|
-
const storedLoginFor = async (operationToken) => {
|
|
29290
|
-
const result = await getValidToken();
|
|
29291
|
-
if (result.status === "ok") {
|
|
29292
|
-
const owner = subjectOf(operationToken);
|
|
29293
|
-
const stored = result.credentials.accessToken;
|
|
29294
|
-
if (owner && subjectOf(stored) === owner) return { token: stored };
|
|
29295
|
-
}
|
|
29296
|
-
const report = result.status === "no-login" ? void 0 : describeTokenLookup(result);
|
|
29297
|
-
return { warning: report ? `${report.detail} ${report.fix}` : "LOBEHUB_JWT is this run's operation token, which this endpoint refuses, and this machine has no stored login of the same account to use instead." };
|
|
29298
|
-
};
|
|
29299
|
-
/**
|
|
29300
|
-
* Re-send a request whose operation token was refused, once, with the stored
|
|
29301
|
-
* login of the same account. Without one, say why instead of re-sending a
|
|
29302
|
-
* request that can only be refused again.
|
|
29303
|
-
*/
|
|
29304
|
-
const operationTokenFallbackLink = (operationToken) => () => ({ next, op }) => observable((observer) => {
|
|
29305
|
-
let closed = false;
|
|
29306
|
-
let subscription = next(op).subscribe({
|
|
29307
|
-
complete: () => observer.complete(),
|
|
29308
|
-
error: (error) => {
|
|
29309
|
-
if (op.context[STORED_LOGIN] || !isOperationTokenRefusal(error) && !isLibraryUploadRefusal(op, error)) {
|
|
29310
|
-
observer.error(error);
|
|
29311
|
-
return;
|
|
29312
|
-
}
|
|
29313
|
-
storedLoginFor(operationToken()).then((lookup) => {
|
|
29314
|
-
if (closed) return;
|
|
29315
|
-
if ("warning" in lookup) {
|
|
29316
|
-
log$15.warn(lookup.warning);
|
|
29317
|
-
observer.error(error);
|
|
29318
|
-
return;
|
|
29319
|
-
}
|
|
29320
|
-
log$15.debug(`${op.path}: operation token refused, retrying with the stored login`);
|
|
29321
|
-
subscription = next({
|
|
29322
|
-
...op,
|
|
29323
|
-
context: {
|
|
29324
|
-
...op.context,
|
|
29325
|
-
[STORED_LOGIN]: lookup.token
|
|
29326
|
-
}
|
|
29327
|
-
}).subscribe(observer);
|
|
29328
|
-
}).catch((lookupError) => {
|
|
29329
|
-
if (closed) return;
|
|
29330
|
-
log$15.warn(`Could not look up the stored login: ${lookupError instanceof Error ? lookupError.message : String(lookupError)}`);
|
|
29331
|
-
observer.error(error);
|
|
29332
|
-
});
|
|
29333
|
-
},
|
|
29334
|
-
next: (value) => observer.next(value)
|
|
29335
|
-
});
|
|
29336
|
-
return () => {
|
|
29337
|
-
closed = true;
|
|
29338
|
-
subscription.unsubscribe();
|
|
29339
|
-
};
|
|
29340
|
-
});
|
|
29341
|
-
/**
|
|
29342
|
-
* Auth headers for a client holding an operation token: the token itself, or
|
|
29343
|
-
* the stored login `operationTokenFallbackLink` attached to a re-sent request.
|
|
29344
|
-
*/
|
|
29345
|
-
const operationTokenHeaders = (operationToken) => (opts) => {
|
|
29346
|
-
const stored = opts?.op?.context[STORED_LOGIN];
|
|
29347
|
-
return { "Oidc-Auth": typeof stored === "string" ? stored : operationToken() };
|
|
29348
|
-
};
|
|
29349
|
-
|
|
29350
29171
|
//#endregion
|
|
29351
29172
|
//#region src/api/client.ts
|
|
29352
29173
|
const PERSONAL_KEY = "__personal__";
|
|
@@ -29357,11 +29178,6 @@ async function getAuthAndServer() {
|
|
|
29357
29178
|
if (source.kind === "env-jwt") {
|
|
29358
29179
|
const serverUrl = resolveServerUrl();
|
|
29359
29180
|
const envToken = () => process.env.LOBEHUB_JWT || source.token;
|
|
29360
|
-
if (isOperationToken(source.token)) return {
|
|
29361
|
-
headers: operationTokenHeaders(envToken),
|
|
29362
|
-
operationToken: envToken,
|
|
29363
|
-
serverUrl
|
|
29364
|
-
};
|
|
29365
29181
|
return {
|
|
29366
29182
|
headers: () => ({ "Oidc-Auth": envToken() }),
|
|
29367
29183
|
serverUrl
|
|
@@ -29394,9 +29210,9 @@ async function getTrpcClient(workspaceId) {
|
|
|
29394
29210
|
const cacheKey = wsId ?? PERSONAL_KEY;
|
|
29395
29211
|
const cached = _clients.get(cacheKey);
|
|
29396
29212
|
if (cached) return cached;
|
|
29397
|
-
const { headers,
|
|
29398
|
-
const client = createTRPCClient({ links: [
|
|
29399
|
-
headers: async (
|
|
29213
|
+
const { headers, serverUrl } = await getAuthAndServer();
|
|
29214
|
+
const client = createTRPCClient({ links: [httpLink({
|
|
29215
|
+
headers: async () => withWorkspaceHeader(await headers(), wsId),
|
|
29400
29216
|
transformer: SuperJSON,
|
|
29401
29217
|
url: `${serverUrl}/trpc/lambda`
|
|
29402
29218
|
})] });
|
|
@@ -29443,9 +29259,9 @@ async function getToolsTrpcClient(workspaceId) {
|
|
|
29443
29259
|
const cacheKey = wsId ?? PERSONAL_KEY;
|
|
29444
29260
|
const cached = _toolsClients.get(cacheKey);
|
|
29445
29261
|
if (cached) return cached;
|
|
29446
|
-
const { headers,
|
|
29447
|
-
const client = createTRPCClient({ links: [
|
|
29448
|
-
headers: async (
|
|
29262
|
+
const { headers, serverUrl } = await getAuthAndServer();
|
|
29263
|
+
const client = createTRPCClient({ links: [httpLink({
|
|
29264
|
+
headers: async () => withWorkspaceHeader(await headers(), wsId),
|
|
29449
29265
|
transformer: SuperJSON,
|
|
29450
29266
|
url: `${serverUrl}/trpc/tools`
|
|
29451
29267
|
})] });
|
|
@@ -41620,6 +41436,22 @@ function withEvidenceUploadOptions(cmd) {
|
|
|
41620
41436
|
return cmd.requiredOption("--check <checkResultId>", "Target check result id").requiredOption("--type <type>", "screenshot|gif|video|audio|text|markdown|dom_snapshot|transcript").option("--file <path>", "Local file to upload as the artifact").option("--file-id <id>", "Attach an already-uploaded file without uploading it again").option("--content <text>", "Inline text payload (instead of a file)").option("--metadata <json>", "Evidence metadata, preserved when retrying an attachment").option("--chapters <file>", "Video chapters JSON (steps, checks, flags on the timeline)").option("--by <capturedBy>", "agent-browser|cdp|cli|program|llm_judge", "cli").option("--desc <text>", "Human-readable caption").option("--json [fields]", "Output JSON");
|
|
41621
41437
|
}
|
|
41622
41438
|
|
|
41439
|
+
//#endregion
|
|
41440
|
+
//#region src/api/operationToken.ts
|
|
41441
|
+
/**
|
|
41442
|
+
* A device-dispatched run (desktop gateway, `lh connect`) authenticates with
|
|
41443
|
+
* the run's `hetero-operation` token in `LOBEHUB_JWT`. A server that mints it
|
|
41444
|
+
* with `caller:act` accepts it on user routes as the user who started the run;
|
|
41445
|
+
* an older server answers those routes with this refusal.
|
|
41446
|
+
*
|
|
41447
|
+
* `lh` never answers a refusal by switching to this machine's own login: on a
|
|
41448
|
+
* shared device that login can belong to someone else, and the server alone
|
|
41449
|
+
* decides what a run may do.
|
|
41450
|
+
*/
|
|
41451
|
+
const OPERATION_TOKEN_REFUSAL = "hetero-operation tokens are not accepted on this endpoint";
|
|
41452
|
+
const isOperationToken = (token) => !!token && parseJwtPayload(token)?.purpose === "hetero-operation";
|
|
41453
|
+
const isOperationTokenRefusal = (error) => isTRPCClientError(error) && error.data?.code === "UNAUTHORIZED" && error.message === "hetero-operation tokens are not accepted on this endpoint";
|
|
41454
|
+
|
|
41623
41455
|
//#endregion
|
|
41624
41456
|
//#region src/commands/acceptance/run/report.ts
|
|
41625
41457
|
/**
|
|
@@ -41629,9 +41461,8 @@ function withEvidenceUploadOptions(cmd) {
|
|
|
41629
41461
|
* round's verifier writes it, and `upsertReport` stays off the operation-token
|
|
41630
41462
|
* allowlist. A token without `acceptance:evidence` is refused one step earlier,
|
|
41631
41463
|
* on the language check's `user.getUserState`, and is no closer to writing it.
|
|
41632
|
-
* A
|
|
41633
|
-
*
|
|
41634
|
-
* 401 only got retried. The commands below take the run's own operation id,
|
|
41464
|
+
* A run never retries with the machine's stored login, so the refusal is
|
|
41465
|
+
* final. The commands below take the run's own operation id,
|
|
41635
41466
|
* which the token is bound to.
|
|
41636
41467
|
*/
|
|
41637
41468
|
const reportRefusalGuidance = (runId) => {
|
|
@@ -50425,6 +50256,7 @@ const CLI_USER_RATE_LIMIT_PATTERNS = [
|
|
|
50425
50256
|
/you'?ve hit your limit/i,
|
|
50426
50257
|
/you'?ve hit your \S+ limit/i,
|
|
50427
50258
|
...CLI_CREDIT_LIMIT_PATTERNS,
|
|
50259
|
+
/\bindividual quota reached\b/i,
|
|
50428
50260
|
/usage limit reached/i,
|
|
50429
50261
|
/\blimit reached\b/i,
|
|
50430
50262
|
/使用上限/
|
|
@@ -50486,23 +50318,35 @@ const classifyCliQuotaMessage = (message) => {
|
|
|
50486
50318
|
//#endregion
|
|
50487
50319
|
//#region ../../packages/heterogeneous-agents/src/errors/classifyCliMessageError.ts
|
|
50488
50320
|
init_config();
|
|
50321
|
+
/** agy reports its reset as a compact relative duration, for example 28m39s. */
|
|
50322
|
+
const antigravityQuotaResetAt = (message) => {
|
|
50323
|
+
const duration = /\bResets in\s+(?:(\d+)d\s*)?(?:(\d+)h\s*)?(?:(\d+)m\s*)?(?:(\d+)s)?(?=\.|$)/i.exec(message);
|
|
50324
|
+
if (!duration) return;
|
|
50325
|
+
const [, days = "0", hours = "0", minutes = "0", seconds = "0"] = duration;
|
|
50326
|
+
const reset = Number(days) * 86400 + Number(hours) * 3600 + Number(minutes) * 60 + Number(seconds);
|
|
50327
|
+
if (Number.isSafeInteger(reset) && reset > 0) return Math.floor(Date.now() / 1e3) + reset;
|
|
50328
|
+
};
|
|
50489
50329
|
/** Error text shared by stream adapters and process failure handling. */
|
|
50490
50330
|
const classifyCliMessageError = ({ agentType, command, detail: rawDetail }) => {
|
|
50491
50331
|
const detail = rawDetail?.trim();
|
|
50492
50332
|
if (!detail) return;
|
|
50493
50333
|
const quota = classifyCliQuotaMessage(detail);
|
|
50494
|
-
if (quota)
|
|
50495
|
-
agentType
|
|
50496
|
-
|
|
50497
|
-
|
|
50498
|
-
|
|
50499
|
-
|
|
50500
|
-
|
|
50501
|
-
|
|
50502
|
-
|
|
50503
|
-
|
|
50504
|
-
|
|
50505
|
-
|
|
50334
|
+
if (quota) {
|
|
50335
|
+
const resetsAt = agentType === "antigravity" ? antigravityQuotaResetAt(detail) : void 0;
|
|
50336
|
+
return {
|
|
50337
|
+
agentType,
|
|
50338
|
+
code: "rate_limit",
|
|
50339
|
+
details: { kind: quota.kind },
|
|
50340
|
+
error: detail,
|
|
50341
|
+
message: detail,
|
|
50342
|
+
...quota.rateLimitType || resetsAt ? { rateLimitInfo: {
|
|
50343
|
+
...quota.rateLimitType && { rateLimitType: quota.rateLimitType },
|
|
50344
|
+
...resetsAt && { resetsAt },
|
|
50345
|
+
status: "rejected"
|
|
50346
|
+
} } : {},
|
|
50347
|
+
stderr: detail
|
|
50348
|
+
};
|
|
50349
|
+
}
|
|
50506
50350
|
if (isHeterogeneousAgentAuthRequired(agentType, detail)) return buildHeterogeneousAgentAuthRequiredError({
|
|
50507
50351
|
agentType,
|
|
50508
50352
|
command,
|
|
@@ -50919,16 +50763,16 @@ var AntigravityAcpAdapter = class extends TraeAcpAdapter {
|
|
|
50919
50763
|
uuid: value.uuid
|
|
50920
50764
|
})];
|
|
50921
50765
|
}
|
|
50922
|
-
|
|
50923
|
-
if (value.type !== `${IDENTIFIER}_error`) return events;
|
|
50766
|
+
if (value.type !== `${IDENTIFIER}_error`) return super.adapt(value);
|
|
50924
50767
|
const classified = classifyCliMessageError({
|
|
50925
50768
|
agentType: IDENTIFIER,
|
|
50926
50769
|
detail: typeof value.message === "string" ? value.message : void 0
|
|
50927
50770
|
});
|
|
50928
|
-
|
|
50771
|
+
if (!classified) return super.adapt(value);
|
|
50772
|
+
return [...classified.code === "rate_limit" && this.stream.pendingStepBoundary ? this.stream.ensureStream(true) : [], ...super.adapt(value).map((event) => event.type === "error" ? {
|
|
50929
50773
|
...event,
|
|
50930
50774
|
data: classified
|
|
50931
|
-
} : event)
|
|
50775
|
+
} : event)];
|
|
50932
50776
|
}
|
|
50933
50777
|
toUsageData(usage) {
|
|
50934
50778
|
return toAntigravityUsage(usage);
|
|
@@ -56505,7 +56349,7 @@ const createAdapter = (agentType) => {
|
|
|
56505
56349
|
};
|
|
56506
56350
|
|
|
56507
56351
|
//#endregion
|
|
56508
|
-
//#region node_modules/.pnpm/@lobehub+icons@6.20.0_@lobehub+ui@6.19.
|
|
56352
|
+
//#region node_modules/.pnpm/@lobehub+icons@6.20.0_@lobehub+ui@6.19.2_lucide-react@1.78.0_@types+react@19.2.13_react_0b302560b79dc828ef2bbaba6d030453/node_modules/@lobehub/icons/es/features/getLobeIconCDN/index.mjs
|
|
56509
56353
|
const GITHUB_ICON_CDN = (type) => `https://raw.githubusercontent.com/lobehub/lobe-icons/refs/heads/master/packages/static-${type}`;
|
|
56510
56354
|
const ALIYUN_ICON_CDN = (type) => `https://registry.npmmirror.com/@lobehub/icons-static-${type}/latest/files`;
|
|
56511
56355
|
const UNPKG_ICON_CDN = (type) => `https://unpkg.com/@lobehub/icons-static-${type}@latest`;
|
|
@@ -70220,16 +70064,12 @@ function registerCompletionCommand(program) {
|
|
|
70220
70064
|
//#region src/api/openapi.ts
|
|
70221
70065
|
/**
|
|
70222
70066
|
* The Bearer token for `/api/v1/*`. That API accepts OIDC JWTs and API keys
|
|
70223
|
-
* but refuses a run's `hetero-operation` token outright,
|
|
70224
|
-
* in
|
|
70225
|
-
* account, the same rule `operationTokenFallbackLink` applies to tRPC.
|
|
70067
|
+
* but refuses a run's `hetero-operation` token outright, and `lh` does not
|
|
70068
|
+
* swap in this machine's own login for it (see `operationToken`).
|
|
70226
70069
|
*/
|
|
70227
70070
|
const resolveBearerToken = async () => {
|
|
70228
|
-
|
|
70229
|
-
|
|
70230
|
-
const lookup = await storedLoginFor(envJwt);
|
|
70231
|
-
if ("token" in lookup) return lookup.token;
|
|
70232
|
-
log$15.error(lookup.warning);
|
|
70071
|
+
if (isOperationToken(process.env.LOBEHUB_JWT)) {
|
|
70072
|
+
log$15.error("This command is not available inside an agent run: its LobeHub API does not accept the run's sign-in. Ask the user to run it in a terminal.");
|
|
70233
70073
|
process.exit(1);
|
|
70234
70074
|
}
|
|
70235
70075
|
return (await getAgentStreamAuthInfo()).token;
|
|
@@ -72725,20 +72565,19 @@ const createCodexJwtFile = async (jwt) => {
|
|
|
72725
72565
|
*
|
|
72726
72566
|
* - **Credentials.** The cloud sandbox is handed a user-scoped JWT, and a
|
|
72727
72567
|
* desktop client-mode run is handed the app's own sign-in as
|
|
72728
|
-
* `LOBEHUB_JWT_FILE` (older desktops
|
|
72729
|
-
*
|
|
72730
|
-
*
|
|
72731
|
-
*
|
|
72732
|
-
*
|
|
72733
|
-
*
|
|
72734
|
-
*
|
|
72735
|
-
*
|
|
72736
|
-
*
|
|
72737
|
-
*
|
|
72738
|
-
* (`
|
|
72739
|
-
*
|
|
72740
|
-
*
|
|
72741
|
-
* did not fit.
|
|
72568
|
+
* `LOBEHUB_JWT_FILE` (older desktops passed none). The device-dispatch
|
|
72569
|
+
* paths (desktop gateway, `lh connect`) put the run's `hetero-operation`
|
|
72570
|
+
* token in `LOBEHUB_JWT`. Minted with `caller:act`, it acts as the user who
|
|
72571
|
+
* started the run, only in the run's workspace, only while the run lasts and
|
|
72572
|
+
* only within `HETERO_CALLER_SCOPES` (tasks, documents, files, acceptance,
|
|
72573
|
+
* bot messages, the device list, traces);
|
|
72574
|
+
* `oidcAuth` refuses a token without it there. `lh topic view` reads through
|
|
72575
|
+
* an operation route first, as the run's own principal, limited to this
|
|
72576
|
+
* conversation and the ones the user names in it
|
|
72577
|
+
* (`topic.getTopicTranscriptOperation`). Inside a run `lh` never uses the
|
|
72578
|
+
* machine's own login or API key (`getValidToken`, `readCliApiKeyEnv`): on a
|
|
72579
|
+
* shared workspace device they belong to whoever enrolled it. So the guide
|
|
72580
|
+
* does not teach the agent to clear the variable or log in.
|
|
72742
72581
|
* - **`LOBEHUB_AGENT_ID`.** Desktop client mode sets it through
|
|
72743
72582
|
* `buildLobeHubSessionEnv`. CLI/Desktop dispatch launchers, including
|
|
72744
72583
|
* OpenClaw/Hermes, clear inherited identity and inject the current dispatch's
|
|
@@ -76412,6 +76251,7 @@ const isPromptResponse = (message) => {
|
|
|
76412
76251
|
if (message.error) return message.requestMethod === "session/prompt";
|
|
76413
76252
|
return isRecord$8(message.result) && "stopReason" in message.result;
|
|
76414
76253
|
};
|
|
76254
|
+
const QUOTA_NOTICE = /^(?:⚠️?\s*)?Individual quota reached\.\s+Please upgrade your subscription to increase your limits\.(?:\s+Resets in (?:\d+[dhms]\s*)+\.?)?$/i;
|
|
76415
76255
|
/**
|
|
76416
76256
|
* Antigravity over `agy acp`. One run is one user turn; a message the user
|
|
76417
76257
|
* sends while it runs is steered in with another `session/prompt`: agy ends
|
|
@@ -76421,9 +76261,8 @@ const isPromptResponse = (message) => {
|
|
|
76421
76261
|
var AntigravityAcpSession = class extends AcpAgentSession {
|
|
76422
76262
|
/** Session updates before the prompt (a `session/load` replay) are history, not output. */
|
|
76423
76263
|
acceptUpdates = false;
|
|
76424
|
-
/** Read confirmations, chained so each lands before any update that follows it. */
|
|
76425
|
-
confirmations = Promise.resolve();
|
|
76426
76264
|
launch;
|
|
76265
|
+
writingAnswer = false;
|
|
76427
76266
|
/** Prompt responses handled so far, in stdout order. */
|
|
76428
76267
|
promptResponses = 0;
|
|
76429
76268
|
/** Steered prompts written to agy, in order, that the run has not settled yet. */
|
|
@@ -76455,24 +76294,22 @@ var AntigravityAcpSession = class extends AcpAgentSession {
|
|
|
76455
76294
|
}
|
|
76456
76295
|
/**
|
|
76457
76296
|
* Write a user message into the running turn. `false` when the run takes no
|
|
76458
|
-
* input now (not prompting yet, interrupted, or settling):
|
|
76459
|
-
* written, so the message can wait for the next run. agy confirms it read
|
|
76297
|
+
* input now (not prompting yet, writing an answer, interrupted, or settling):
|
|
76298
|
+
* nothing was written, so the message can wait for the next run. agy confirms it read
|
|
76460
76299
|
* the message when the prompt it interrupts returns, reported as
|
|
76461
76300
|
* `step_complete { phase: 'user_message', uuid }`.
|
|
76462
76301
|
*/
|
|
76463
76302
|
steer(prompt, uuid) {
|
|
76464
76303
|
const sessionId = this.acpSessionId;
|
|
76465
|
-
if (!this.steerable || !sessionId || this.closedByHost) return false;
|
|
76304
|
+
if (!this.steerable || !sessionId || this.closedByHost || this.writingAnswer || this.promptResponses > this.steerCount) return false;
|
|
76466
76305
|
const result = this.client.request("session/prompt", {
|
|
76467
76306
|
prompt,
|
|
76468
76307
|
sessionId
|
|
76469
76308
|
}, false);
|
|
76470
76309
|
result.catch(() => {});
|
|
76471
76310
|
this.steers.push(result);
|
|
76472
|
-
|
|
76473
|
-
|
|
76474
|
-
else this.unconfirmedSteers.push({
|
|
76475
|
-
index,
|
|
76311
|
+
this.unconfirmedSteers.push({
|
|
76312
|
+
index: ++this.steerCount,
|
|
76476
76313
|
uuid
|
|
76477
76314
|
});
|
|
76478
76315
|
return true;
|
|
@@ -76545,7 +76382,6 @@ var AntigravityAcpSession = class extends AcpAgentSession {
|
|
|
76545
76382
|
this.addUsage(last.usage);
|
|
76546
76383
|
}
|
|
76547
76384
|
this.steerable = false;
|
|
76548
|
-
await this.confirmations;
|
|
76549
76385
|
const used = Object.values(this.usage).some((value) => value > 0);
|
|
76550
76386
|
await this.pushToPipeline({
|
|
76551
76387
|
stopReason: last.stopReason,
|
|
@@ -76572,13 +76408,16 @@ var AntigravityAcpSession = class extends AcpAgentSession {
|
|
|
76572
76408
|
this.steerable = false;
|
|
76573
76409
|
}
|
|
76574
76410
|
async handleAgentMessage(message) {
|
|
76575
|
-
await this.confirmations;
|
|
76576
76411
|
if (isPromptResponse(message)) {
|
|
76577
76412
|
this.promptResponses += 1;
|
|
76413
|
+
this.writingAnswer = false;
|
|
76578
76414
|
const next = this.unconfirmedSteers[0];
|
|
76579
|
-
if (next && next.index <= this.promptResponses) {
|
|
76415
|
+
if (!message.error && next && next.index <= this.promptResponses) {
|
|
76580
76416
|
this.unconfirmedSteers.shift();
|
|
76581
|
-
await this.
|
|
76417
|
+
await this.pushToPipeline({
|
|
76418
|
+
type: "antigravity_user_message",
|
|
76419
|
+
uuid: next.uuid
|
|
76420
|
+
});
|
|
76582
76421
|
}
|
|
76583
76422
|
return;
|
|
76584
76423
|
}
|
|
@@ -76586,7 +76425,12 @@ var AntigravityAcpSession = class extends AcpAgentSession {
|
|
|
76586
76425
|
const params = isRecord$8(message.params) ? message.params : void 0;
|
|
76587
76426
|
if (!isRecord$8(params?.update)) return;
|
|
76588
76427
|
if (typeof params.sessionId === "string" && params.sessionId !== this.acpSessionId) return;
|
|
76589
|
-
const { name, sessionUpdate, status } = params.update;
|
|
76428
|
+
const { content, name, sessionUpdate, status } = params.update;
|
|
76429
|
+
if (sessionUpdate === "agent_message_chunk" && isRecord$8(content) && content.type === "text") {
|
|
76430
|
+
const text = typeof content.text === "string" ? content.text.trim() : "";
|
|
76431
|
+
if (QUOTA_NOTICE.test(text)) throw new Error(text);
|
|
76432
|
+
if (text) this.writingAnswer = true;
|
|
76433
|
+
} else if (sessionUpdate === "tool_call") this.writingAnswer = false;
|
|
76590
76434
|
if (this.options.askUserBridge && name === "ask_question" && (sessionUpdate === "tool_call" || sessionUpdate === "tool_call_update") && (status === "in_progress" || status === "pending" || status === void 0)) return;
|
|
76591
76435
|
await this.pushToPipeline(params.update);
|
|
76592
76436
|
}
|
|
@@ -76675,15 +76519,6 @@ var AntigravityAcpSession = class extends AcpAgentSession {
|
|
|
76675
76519
|
const variant = level ? `${family}-${level}` : void 0;
|
|
76676
76520
|
return variant && availableModelIds(sessionResult).has(variant) ? variant : family;
|
|
76677
76521
|
}
|
|
76678
|
-
confirmSteer(uuid) {
|
|
76679
|
-
const confirmed = this.confirmations.then(() => this.pushToPipeline({
|
|
76680
|
-
type: "antigravity_user_message",
|
|
76681
|
-
uuid
|
|
76682
|
-
}));
|
|
76683
|
-
confirmed.catch(() => {});
|
|
76684
|
-
this.confirmations = confirmed;
|
|
76685
|
-
return confirmed;
|
|
76686
|
-
}
|
|
76687
76522
|
addUsage(usage) {
|
|
76688
76523
|
if (!isRecord$8(usage)) return;
|
|
76689
76524
|
for (const field of USAGE_FIELDS) {
|
|
@@ -563144,7 +562979,7 @@ const credentialSource = {
|
|
|
563144
562979
|
};
|
|
563145
562980
|
if (!source.token) {
|
|
563146
562981
|
if (isInsideAgentRun()) return {
|
|
563147
|
-
...
|
|
562982
|
+
...agentRunNoSignInReport(),
|
|
563148
562983
|
evidence,
|
|
563149
562984
|
status: "fail"
|
|
563150
562985
|
};
|
|
@@ -595823,9 +595658,9 @@ const isMissingProcedure = (error) => isTRPCClientError(error) && error.message.
|
|
|
595823
595658
|
* run's own principal, limited to its own conversation and the ones the user
|
|
595824
595659
|
* names in it. When that route cannot serve the read — a server without it, a
|
|
595825
595660
|
* topic outside that boundary, a run that already ended — the ordinary route is
|
|
595826
|
-
* tried, which
|
|
595827
|
-
*
|
|
595828
|
-
*
|
|
595661
|
+
* tried, which a server that accepts the run's token as its caller answers. If
|
|
595662
|
+
* the ordinary route only repeats the operation token refusal (an older server),
|
|
595663
|
+
* the operation route's own answer is the one worth showing.
|
|
595829
595664
|
*
|
|
595830
595665
|
* `--workspace` names a scope the run's token was not minted for, so it always
|
|
595831
595666
|
* takes the ordinary route.
|