@lobehub/cli 0.0.16 → 0.0.18

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 CHANGED
@@ -3028,7 +3028,7 @@ var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3028
3028
  }));
3029
3029
 
3030
3030
  //#endregion
3031
- //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/objectSpread2-BvkFp-_Y.mjs
3031
+ //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/objectSpread2-BvkFp-_Y.mjs
3032
3032
  var import_picocolors = /* @__PURE__ */ __toESM$2(require_picocolors(), 1);
3033
3033
  var __create$1 = Object.create;
3034
3034
  var __defProp$1 = Object.defineProperty;
@@ -3126,7 +3126,7 @@ var require_objectSpread2$1 = __commonJS$1({ "../../node_modules/.pnpm/@oxc-proj
3126
3126
  } });
3127
3127
 
3128
3128
  //#endregion
3129
- //#region node_modules/.pnpm/@trpc+server@11.16.0_typescript@5.9.3/node_modules/@trpc/server/dist/observable-UMO3vUa_.mjs
3129
+ //#region node_modules/.pnpm/@trpc+server@11.17.0_typescript@5.9.3/node_modules/@trpc/server/dist/observable-UMO3vUa_.mjs
3130
3130
  /** @public */
3131
3131
  function observable(subscribe) {
3132
3132
  const self = {
@@ -3209,7 +3209,7 @@ function observableToPromise(observable$1) {
3209
3209
  }
3210
3210
 
3211
3211
  //#endregion
3212
- //#region node_modules/.pnpm/@trpc+server@11.16.0_typescript@5.9.3/node_modules/@trpc/server/dist/observable-CUiPknO-.mjs
3212
+ //#region node_modules/.pnpm/@trpc+server@11.17.0_typescript@5.9.3/node_modules/@trpc/server/dist/observable-CUiPknO-.mjs
3213
3213
  function share(_opts) {
3214
3214
  return (source) => {
3215
3215
  let refCount = 0;
@@ -3289,7 +3289,7 @@ function behaviorSubject(initialValue) {
3289
3289
  }
3290
3290
 
3291
3291
  //#endregion
3292
- //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/splitLink-B7Cuf2c_.mjs
3292
+ //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/splitLink-B7Cuf2c_.mjs
3293
3293
  /** @internal */
3294
3294
  function createChain(opts) {
3295
3295
  return observable((observer) => {
@@ -3308,7 +3308,7 @@ function createChain(opts) {
3308
3308
  }
3309
3309
 
3310
3310
  //#endregion
3311
- //#region node_modules/.pnpm/@trpc+server@11.16.0_typescript@5.9.3/node_modules/@trpc/server/dist/codes-DagpWZLc.mjs
3311
+ //#region node_modules/.pnpm/@trpc+server@11.17.0_typescript@5.9.3/node_modules/@trpc/server/dist/codes-DagpWZLc.mjs
3312
3312
  /**
3313
3313
  * Check that value is object
3314
3314
  * @internal
@@ -3364,7 +3364,7 @@ const retryableRpcCodes = [
3364
3364
  ];
3365
3365
 
3366
3366
  //#endregion
3367
- //#region node_modules/.pnpm/@trpc+server@11.16.0_typescript@5.9.3/node_modules/@trpc/server/dist/getErrorShape-vC8mUXJD.mjs
3367
+ //#region node_modules/.pnpm/@trpc+server@11.17.0_typescript@5.9.3/node_modules/@trpc/server/dist/getErrorShape-BPSzUA7W.mjs
3368
3368
  var __create = Object.create;
3369
3369
  var __defProp = Object.defineProperty;
3370
3370
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -3402,6 +3402,7 @@ function createInnerProxy(callback, path, memo) {
3402
3402
  },
3403
3403
  apply(_1, _2, args) {
3404
3404
  const lastOfPath = path[path.length - 1];
3405
+ if (lastOfPath === "valueOf" || lastOfPath === "toString" || lastOfPath === "toJSON") return `tRPC.proxy(${path.slice(0, -1).join(".")})`;
3405
3406
  let opts = {
3406
3407
  args,
3407
3408
  path
@@ -3512,7 +3513,7 @@ var require_objectSpread2 = __commonJS({ "../../node_modules/.pnpm/@oxc-project+
3512
3513
  var import_objectSpread2$11 = __toESM(require_objectSpread2(), 1);
3513
3514
 
3514
3515
  //#endregion
3515
- //#region node_modules/.pnpm/@trpc+server@11.16.0_typescript@5.9.3/node_modules/@trpc/server/dist/tracked-DiE3uR1B.mjs
3516
+ //#region node_modules/.pnpm/@trpc+server@11.17.0_typescript@5.9.3/node_modules/@trpc/server/dist/tracked-DWInO6EQ.mjs
3516
3517
  var import_defineProperty$6 = __toESM(require_defineProperty(), 1);
3517
3518
  var import_objectSpread2$1$11 = __toESM(require_objectSpread2(), 1);
3518
3519
  /** @internal */
@@ -3555,7 +3556,7 @@ function transformResult(response, transformer) {
3555
3556
  var import_objectSpread2$12 = __toESM(require_objectSpread2(), 1);
3556
3557
 
3557
3558
  //#endregion
3558
- //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/TRPCClientError-apv8gw59.mjs
3559
+ //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/TRPCClientError-apv8gw59.mjs
3559
3560
  var import_defineProperty$5 = __toESM$1(require_defineProperty$1(), 1);
3560
3561
  var import_objectSpread2$10 = __toESM$1(require_objectSpread2$1(), 1);
3561
3562
  function isTRPCClientError(cause) {
@@ -3600,7 +3601,7 @@ var TRPCClientError = class TRPCClientError extends Error {
3600
3601
  };
3601
3602
 
3602
3603
  //#endregion
3603
- //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/unstable-internals-Bg7n9BBj.mjs
3604
+ //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/unstable-internals-Bg7n9BBj.mjs
3604
3605
  /**
3605
3606
  * @internal
3606
3607
  */
@@ -3627,7 +3628,7 @@ function getTransformer(transformer) {
3627
3628
  }
3628
3629
 
3629
3630
  //#endregion
3630
- //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/httpUtils-BNq9QC3d.mjs
3631
+ //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/httpUtils-pyf5RF99.mjs
3631
3632
  const isFunction$1 = (fn) => typeof fn === "function";
3632
3633
  function getFetch(customFetchImpl) {
3633
3634
  if (customFetchImpl) return customFetchImpl;
@@ -3635,7 +3636,7 @@ function getFetch(customFetchImpl) {
3635
3636
  if (typeof globalThis !== "undefined" && isFunction$1(globalThis.fetch)) return globalThis.fetch;
3636
3637
  throw new Error("No fetch implementation found");
3637
3638
  }
3638
- var import_objectSpread2$9 = __toESM$1(require_objectSpread2$1());
3639
+ var import_objectSpread2$9 = __toESM$1(require_objectSpread2$1(), 1);
3639
3640
  function resolveHTTPLinkOptions(opts) {
3640
3641
  return {
3641
3642
  url: opts.url.toString(),
@@ -3737,7 +3738,7 @@ async function httpRequest(opts) {
3737
3738
  }
3738
3739
 
3739
3740
  //#endregion
3740
- //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/httpLink-oiU8eqFi.mjs
3741
+ //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/httpLink-lG_6juPY.mjs
3741
3742
  function isOctetType(input) {
3742
3743
  return input instanceof Uint8Array || input instanceof Blob;
3743
3744
  }
@@ -3813,15 +3814,15 @@ function httpLink(opts) {
3813
3814
  }
3814
3815
 
3815
3816
  //#endregion
3816
- //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/httpBatchLink-CaWjh1oW.mjs
3817
+ //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/httpBatchLink-LhidKAPw.mjs
3817
3818
  var import_objectSpread2$7 = __toESM$1(require_objectSpread2$1(), 1);
3818
3819
 
3819
3820
  //#endregion
3820
- //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/loggerLink-ineCN1PO.mjs
3821
+ //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/loggerLink-ineCN1PO.mjs
3821
3822
  var import_objectSpread2$6 = __toESM$1(require_objectSpread2$1(), 1);
3822
3823
 
3823
3824
  //#endregion
3824
- //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/wsLink-DSf4KOdW.mjs
3825
+ //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/wsLink-DSf4KOdW.mjs
3825
3826
  /**
3826
3827
  * Get the result of a value or function that returns a value
3827
3828
  * It also optionally accepts typesafe arguments for the function
@@ -3997,7 +3998,7 @@ var import_defineProperty$4 = __toESM$1(require_defineProperty$1(), 1);
3997
3998
  var import_objectSpread2$5 = __toESM$1(require_objectSpread2$1(), 1);
3998
3999
 
3999
4000
  //#endregion
4000
- //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/index.mjs
4001
+ //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/index.mjs
4001
4002
  var import_defineProperty = __toESM$1(require_defineProperty$1(), 1);
4002
4003
  var import_objectSpread2$4 = __toESM$1(require_objectSpread2$1(), 1);
4003
4004
  var TRPCUntypedClient = class {
@@ -12723,7 +12724,7 @@ function registerConfigCommand(program) {
12723
12724
  }
12724
12725
 
12725
12726
  //#endregion
12726
- //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/constants.js
12727
+ //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/constants.js
12727
12728
  var require_constants$4 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
12728
12729
  const BINARY_TYPES = [
12729
12730
  "nodebuffer",
@@ -12747,7 +12748,7 @@ var require_constants$4 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
12747
12748
  }));
12748
12749
 
12749
12750
  //#endregion
12750
- //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/buffer-util.js
12751
+ //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/buffer-util.js
12751
12752
  var require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
12752
12753
  const { EMPTY_BUFFER } = require_constants$4();
12753
12754
  const FastBuffer = Buffer[Symbol.species];
@@ -12848,7 +12849,7 @@ var require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
12848
12849
  }));
12849
12850
 
12850
12851
  //#endregion
12851
- //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/limiter.js
12852
+ //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/limiter.js
12852
12853
  var require_limiter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
12853
12854
  const kDone = Symbol("kDone");
12854
12855
  const kRun = Symbol("kRun");
@@ -12900,7 +12901,7 @@ var require_limiter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
12900
12901
  }));
12901
12902
 
12902
12903
  //#endregion
12903
- //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/permessage-deflate.js
12904
+ //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/permessage-deflate.js
12904
12905
  var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
12905
12906
  const zlib$2 = __require("zlib");
12906
12907
  const bufferUtil = require_buffer_util();
@@ -13234,7 +13235,7 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
13234
13235
  }));
13235
13236
 
13236
13237
  //#endregion
13237
- //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/validation.js
13238
+ //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/validation.js
13238
13239
  var require_validation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13239
13240
  const { isUtf8 } = __require("buffer");
13240
13241
  const { hasBlob } = require_constants$4();
@@ -13431,7 +13432,7 @@ var require_validation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13431
13432
  }));
13432
13433
 
13433
13434
  //#endregion
13434
- //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/receiver.js
13435
+ //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/receiver.js
13435
13436
  var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13436
13437
  const { Writable: Writable$2 } = __require("stream");
13437
13438
  const PerMessageDeflate = require_permessage_deflate();
@@ -13879,10 +13880,11 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13879
13880
  }));
13880
13881
 
13881
13882
  //#endregion
13882
- //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/sender.js
13883
+ //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/sender.js
13883
13884
  var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13884
13885
  const { Duplex: Duplex$3 } = __require("stream");
13885
13886
  const { randomFillSync } = __require("crypto");
13887
+ const { types: { isUint8Array } } = __require("util");
13886
13888
  const PerMessageDeflate = require_permessage_deflate();
13887
13889
  const { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants$4();
13888
13890
  const { isBlob, isValidStatusCode } = require_validation();
@@ -14029,7 +14031,8 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14029
14031
  buf = Buffer.allocUnsafe(2 + length);
14030
14032
  buf.writeUInt16BE(code, 0);
14031
14033
  if (typeof data === "string") buf.write(data, 2);
14032
- else buf.set(data, 2);
14034
+ else if (isUint8Array(data)) buf.set(data, 2);
14035
+ else throw new TypeError("Second argument must be a string or a Uint8Array");
14033
14036
  }
14034
14037
  const options = {
14035
14038
  [kByteLength]: buf.length,
@@ -14376,7 +14379,7 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14376
14379
  }));
14377
14380
 
14378
14381
  //#endregion
14379
- //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/event-target.js
14382
+ //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/event-target.js
14380
14383
  var require_event_target = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14381
14384
  const { kForOnEventAttribute, kListener } = require_constants$4();
14382
14385
  const kCode = Symbol("kCode");
@@ -14615,7 +14618,7 @@ var require_event_target = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14615
14618
  }));
14616
14619
 
14617
14620
  //#endregion
14618
- //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/extension.js
14621
+ //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/extension.js
14619
14622
  var require_extension = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14620
14623
  const { tokenChars } = require_validation();
14621
14624
  /**
@@ -14759,7 +14762,7 @@ var require_extension = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14759
14762
  }));
14760
14763
 
14761
14764
  //#endregion
14762
- //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/websocket.js
14765
+ //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/websocket.js
14763
14766
  var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14764
14767
  const EventEmitter$6 = __require("events");
14765
14768
  const https = __require("https");
@@ -15735,7 +15738,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15735
15738
  }));
15736
15739
 
15737
15740
  //#endregion
15738
- //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/stream.js
15741
+ //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/stream.js
15739
15742
  var require_stream$6 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15740
15743
  require_websocket();
15741
15744
  const { Duplex: Duplex$1 } = __require("stream");
@@ -15852,7 +15855,7 @@ var require_stream$6 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15852
15855
  }));
15853
15856
 
15854
15857
  //#endregion
15855
- //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/subprotocol.js
15858
+ //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/subprotocol.js
15856
15859
  var require_subprotocol = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15857
15860
  const { tokenChars } = require_validation();
15858
15861
  /**
@@ -15892,7 +15895,7 @@ var require_subprotocol = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15892
15895
  }));
15893
15896
 
15894
15897
  //#endregion
15895
- //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/websocket-server.js
15898
+ //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/websocket-server.js
15896
15899
  var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15897
15900
  const EventEmitter$5 = __require("events");
15898
15901
  const http = __require("http");
@@ -16271,7 +16274,7 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
16271
16274
  }));
16272
16275
 
16273
16276
  //#endregion
16274
- //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/wrapper.mjs
16277
+ //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/wrapper.mjs
16275
16278
  var import_stream = /* @__PURE__ */ __toESM$2(require_stream$6(), 1);
16276
16279
  var import_extension = /* @__PURE__ */ __toESM$2(require_extension(), 1);
16277
16280
  var import_permessage_deflate = /* @__PURE__ */ __toESM$2(require_permessage_deflate(), 1);
@@ -16851,10 +16854,8 @@ async function runHeteroTask(params) {
16851
16854
  log$7.info(`OpenClaw task started: taskId=${taskId} pid=${pid} agent=${openclawAgent}`);
16852
16855
  child.on("close", (code, signal) => {
16853
16856
  removeTask(taskId);
16854
- if (code !== 0 || signal !== null) {
16855
- sendAutoNotify(topicId, taskId, signal ? `Task cancelled (signal: ${signal})` : `Task failed (exit code: ${code})`, agentId);
16856
- sendDoneSignal(topicId, agentId);
16857
- } else sendDoneSignal(topicId, agentId);
16857
+ if (code !== 0 || signal !== null) sendAutoNotify(topicId, taskId, signal ? `Task cancelled (signal: ${signal})` : `Task failed (exit code: ${code})`, agentId).finally(() => sendDoneSignal(topicId, agentId));
16858
+ else sendDoneSignal(topicId, agentId);
16858
16859
  });
16859
16860
  return JSON.stringify({
16860
16861
  pid,
@@ -205218,29 +205219,24 @@ var require_concat_stream = /* @__PURE__ */ __commonJSMin(((exports, module) =>
205218
205219
  }));
205219
205220
 
205220
205221
  //#endregion
205221
- //#region node_modules/.pnpm/yauzl@3.3.0/node_modules/yauzl/fd-slicer.js
205222
+ //#region node_modules/.pnpm/yauzl@3.3.1/node_modules/yauzl/fd-slicer.js
205222
205223
  var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
205223
205224
  var fs$3 = __require("fs");
205224
205225
  var util$1 = __require("util");
205225
205226
  var stream = __require("stream");
205226
205227
  var Readable = stream.Readable;
205227
- var Writable = stream.Writable;
205228
205228
  var PassThrough = stream.PassThrough;
205229
205229
  var Pend = require_pend();
205230
205230
  var EventEmitter$2 = __require("events").EventEmitter;
205231
- exports.createFromBuffer = createFromBuffer;
205232
- exports.createFromFd = createFromFd;
205233
205231
  exports.BufferSlicer = BufferSlicer;
205234
205232
  exports.FdSlicer = FdSlicer;
205235
205233
  util$1.inherits(FdSlicer, EventEmitter$2);
205236
- function FdSlicer(fd, options) {
205237
- options = options || {};
205234
+ function FdSlicer(fd) {
205238
205235
  EventEmitter$2.call(this);
205239
205236
  this.fd = fd;
205240
205237
  this.pend = new Pend();
205241
205238
  this.pend.max = 1;
205242
205239
  this.refCount = 0;
205243
- this.autoClose = !!options.autoClose;
205244
205240
  }
205245
205241
  FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
205246
205242
  var self = this;
@@ -205251,30 +205247,18 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
205251
205247
  });
205252
205248
  });
205253
205249
  };
205254
- FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
205255
- var self = this;
205256
- self.pend.go(function(cb) {
205257
- fs$3.write(self.fd, buffer, offset, length, position, function(err, written, buffer) {
205258
- cb();
205259
- callback(err, written, buffer);
205260
- });
205261
- });
205262
- };
205263
205250
  FdSlicer.prototype.createReadStream = function(options) {
205264
205251
  return new ReadStream(this, options);
205265
205252
  };
205266
- FdSlicer.prototype.createWriteStream = function(options) {
205267
- return new WriteStream(this, options);
205268
- };
205269
205253
  FdSlicer.prototype.ref = function() {
205270
205254
  this.refCount += 1;
205271
205255
  };
205272
205256
  FdSlicer.prototype.unref = function() {
205273
205257
  var self = this;
205274
205258
  self.refCount -= 1;
205275
- if (self.refCount > 0) return;
205276
205259
  if (self.refCount < 0) throw new Error("invalid unref");
205277
- if (self.autoClose) fs$3.close(self.fd, onCloseDone);
205260
+ if (self.refCount > 0) return;
205261
+ fs$3.close(self.fd, onCloseDone);
205278
205262
  function onCloseDone(err) {
205279
205263
  if (err) self.emit("error", err);
205280
205264
  else self.emit("close");
@@ -205289,28 +205273,23 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
205289
205273
  this.start = options.start || 0;
205290
205274
  this.endOffset = options.end;
205291
205275
  this.pos = this.start;
205292
- this.destroyed = false;
205293
205276
  }
205294
205277
  ReadStream.prototype._read = function(n) {
205295
205278
  var self = this;
205296
- if (self.destroyed) return;
205297
205279
  var toRead = Math.min(self._readableState.highWaterMark, n);
205298
205280
  if (self.endOffset != null) toRead = Math.min(toRead, self.endOffset - self.pos);
205299
205281
  if (toRead <= 0) {
205300
- self.destroyed = true;
205301
205282
  self.push(null);
205302
- self.context.unref();
205283
+ this._cleanup();
205303
205284
  return;
205304
205285
  }
205305
205286
  self.context.pend.go(function(cb) {
205306
- if (self.destroyed) return cb();
205307
205287
  var buffer = Buffer.allocUnsafe(toRead);
205308
205288
  fs$3.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
205309
205289
  if (err) self.destroy(err);
205310
205290
  else if (bytesRead === 0) {
205311
- self.destroyed = true;
205312
205291
  self.push(null);
205313
- self.context.unref();
205292
+ this._cleanup();
205314
205293
  } else {
205315
205294
  self.pos += bytesRead;
205316
205295
  self.push(buffer.slice(0, bytesRead));
@@ -205319,65 +205298,21 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
205319
205298
  });
205320
205299
  });
205321
205300
  };
205322
- ReadStream.prototype.destroy = function(err) {
205323
- if (this.destroyed) return;
205324
- err = err || /* @__PURE__ */ new Error("stream destroyed");
205325
- this.destroyed = true;
205326
- this.emit("error", err);
205327
- this.context.unref();
205301
+ ReadStream.prototype._destroy = function(err, cb) {
205302
+ this._cleanup();
205303
+ cb(err);
205328
205304
  };
205329
- util$1.inherits(WriteStream, Writable);
205330
- function WriteStream(context, options) {
205331
- options = options || {};
205332
- Writable.call(this, options);
205333
- this.context = context;
205334
- this.context.ref();
205335
- this.start = options.start || 0;
205336
- this.endOffset = options.end == null ? Infinity : +options.end;
205337
- this.bytesWritten = 0;
205338
- this.pos = this.start;
205339
- this.destroyed = false;
205340
- this.on("finish", this.destroy.bind(this));
205341
- }
205342
- WriteStream.prototype._write = function(buffer, encoding, callback) {
205343
- var self = this;
205344
- if (self.destroyed) return;
205345
- if (self.pos + buffer.length > self.endOffset) {
205346
- var err = /* @__PURE__ */ new Error("maximum file length exceeded");
205347
- err.code = "ETOOBIG";
205348
- self.destroy();
205349
- callback(err);
205350
- return;
205305
+ ReadStream.prototype._cleanup = function() {
205306
+ if (this.context != null) {
205307
+ this.context.unref();
205308
+ this.context = null;
205351
205309
  }
205352
- self.context.pend.go(function(cb) {
205353
- if (self.destroyed) return cb();
205354
- fs$3.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err, bytes) {
205355
- if (err) {
205356
- self.destroy();
205357
- cb();
205358
- callback(err);
205359
- } else {
205360
- self.bytesWritten += bytes;
205361
- self.pos += bytes;
205362
- self.emit("progress");
205363
- cb();
205364
- callback();
205365
- }
205366
- });
205367
- });
205368
- };
205369
- WriteStream.prototype.destroy = function() {
205370
- if (this.destroyed) return;
205371
- this.destroyed = true;
205372
- this.context.unref();
205373
205310
  };
205374
205311
  util$1.inherits(BufferSlicer, EventEmitter$2);
205375
- function BufferSlicer(buffer, options) {
205312
+ function BufferSlicer(buffer) {
205376
205313
  EventEmitter$2.call(this);
205377
- options = options || {};
205378
205314
  this.refCount = 0;
205379
205315
  this.buffer = buffer;
205380
- this.maxChunkSize = options.maxChunkSize || Number.MAX_SAFE_INTEGER;
205381
205316
  }
205382
205317
  BufferSlicer.prototype.read = function(buffer, offset, length, position, callback) {
205383
205318
  if (!(0 <= offset && offset <= buffer.length)) throw new RangeError("offset outside buffer: 0 <= " + offset + " <= " + buffer.length);
@@ -205395,23 +205330,17 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
205395
205330
  callback(null, length);
205396
205331
  });
205397
205332
  };
205398
- BufferSlicer.prototype.write = function(buffer, offset, length, position, callback) {
205399
- buffer.copy(this.buffer, position, offset, offset + length);
205400
- setImmediate(function() {
205401
- callback(null, length, buffer);
205402
- });
205403
- };
205404
205333
  BufferSlicer.prototype.createReadStream = function(options) {
205405
205334
  options = options || {};
205406
205335
  var readStream = new PassThrough(options);
205407
- readStream.destroyed = false;
205408
205336
  readStream.start = options.start || 0;
205409
205337
  readStream.endOffset = options.end;
205410
205338
  readStream.pos = readStream.endOffset || this.buffer.length;
205411
205339
  var entireSlice = this.buffer.slice(readStream.start, readStream.pos);
205340
+ var maxChunkSize = 65536;
205412
205341
  var offset = 0;
205413
205342
  while (true) {
205414
- var nextOffset = offset + this.maxChunkSize;
205343
+ var nextOffset = offset + maxChunkSize;
205415
205344
  if (nextOffset >= entireSlice.length) {
205416
205345
  if (offset < entireSlice.length) readStream.write(entireSlice.slice(offset, entireSlice.length));
205417
205346
  break;
@@ -205420,41 +205349,8 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
205420
205349
  offset = nextOffset;
205421
205350
  }
205422
205351
  readStream.end();
205423
- readStream.destroy = function() {
205424
- readStream.destroyed = true;
205425
- };
205426
205352
  return readStream;
205427
205353
  };
205428
- BufferSlicer.prototype.createWriteStream = function(options) {
205429
- var bufferSlicer = this;
205430
- options = options || {};
205431
- var writeStream = new Writable(options);
205432
- writeStream.start = options.start || 0;
205433
- writeStream.endOffset = options.end == null ? this.buffer.length : +options.end;
205434
- writeStream.bytesWritten = 0;
205435
- writeStream.pos = writeStream.start;
205436
- writeStream.destroyed = false;
205437
- writeStream._write = function(buffer, encoding, callback) {
205438
- if (writeStream.destroyed) return;
205439
- var end = writeStream.pos + buffer.length;
205440
- if (end > writeStream.endOffset) {
205441
- var err = /* @__PURE__ */ new Error("maximum file length exceeded");
205442
- err.code = "ETOOBIG";
205443
- writeStream.destroyed = true;
205444
- callback(err);
205445
- return;
205446
- }
205447
- buffer.copy(bufferSlicer.buffer, writeStream.pos, 0, buffer.length);
205448
- writeStream.bytesWritten += buffer.length;
205449
- writeStream.pos = end;
205450
- writeStream.emit("progress");
205451
- callback();
205452
- };
205453
- writeStream.destroy = function() {
205454
- writeStream.destroyed = true;
205455
- };
205456
- return writeStream;
205457
- };
205458
205354
  BufferSlicer.prototype.ref = function() {
205459
205355
  this.refCount += 1;
205460
205356
  };
@@ -205462,16 +205358,10 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
205462
205358
  this.refCount -= 1;
205463
205359
  if (this.refCount < 0) throw new Error("invalid unref");
205464
205360
  };
205465
- function createFromBuffer(buffer, options) {
205466
- return new BufferSlicer(buffer, options);
205467
- }
205468
- function createFromFd(fd, options) {
205469
- return new FdSlicer(fd, options);
205470
- }
205471
205361
  }));
205472
205362
 
205473
205363
  //#endregion
205474
- //#region node_modules/.pnpm/yauzl@3.3.0/node_modules/yauzl/index.js
205364
+ //#region node_modules/.pnpm/yauzl@3.3.1/node_modules/yauzl/index.js
205475
205365
  var require_yauzl = /* @__PURE__ */ __commonJSMin(((exports) => {
205476
205366
  var fs$2 = __require("fs");
205477
205367
  var zlib = __require("zlib");
@@ -205518,7 +205408,7 @@ var require_yauzl = /* @__PURE__ */ __commonJSMin(((exports) => {
205518
205408
  if (callback == null) callback = defaultCallback;
205519
205409
  fs$2.fstat(fd, function(err, stats) {
205520
205410
  if (err) return callback(err);
205521
- fromRandomAccessReader(fd_slicer.createFromFd(fd, { autoClose: true }), stats.size, options, callback);
205411
+ fromRandomAccessReader(new fd_slicer.FdSlicer(fd), stats.size, options, callback);
205522
205412
  });
205523
205413
  }
205524
205414
  function fromBuffer(buffer, options, callback) {
@@ -205532,7 +205422,7 @@ var require_yauzl = /* @__PURE__ */ __commonJSMin(((exports) => {
205532
205422
  if (options.decodeStrings == null) options.decodeStrings = true;
205533
205423
  if (options.validateEntrySizes == null) options.validateEntrySizes = true;
205534
205424
  if (options.strictFileNames == null) options.strictFileNames = false;
205535
- fromRandomAccessReader(fd_slicer.createFromBuffer(buffer, { maxChunkSize: 65536 }), buffer.length, options, callback);
205425
+ fromRandomAccessReader(new fd_slicer.BufferSlicer(buffer), buffer.length, options, callback);
205536
205426
  }
205537
205427
  function fromRandomAccessReader(reader, totalSize, options, callback) {
205538
205428
  if (typeof options === "function") {
@@ -207142,6 +207032,68 @@ async function runCommand$1({ command, cwd, description, env: extraEnv, run_in_b
207142
207032
  }
207143
207033
  }
207144
207034
 
207035
+ //#endregion
207036
+ //#region src/tools/getAgentProfile.ts
207037
+ const IDENTITY_FILES$1 = ["IDENTITY.md", "SOUL.md"];
207038
+ /**
207039
+ * Try to extract a description from the workspace identity file.
207040
+ * Looks for Creature / Vibe / Description fields in IDENTITY.md or SOUL.md.
207041
+ */
207042
+ function readDescriptionFromWorkspace(workspacePath) {
207043
+ for (const filename of IDENTITY_FILES$1) {
207044
+ const filePath = path.join(workspacePath, filename);
207045
+ if (!fs.existsSync(filePath)) continue;
207046
+ const match = fs.readFileSync(filePath, "utf8").match(/\*{0,2}(?:Creature|Vibe|Description):?\*{0,2}\s*(.+)/i);
207047
+ if (!match) continue;
207048
+ const value = match[1].trim();
207049
+ if (/^[_*((].*[))*_]$|^(?:tbd|todo|n\/?a|none|待定|未定)$/i.test(value)) continue;
207050
+ return value;
207051
+ }
207052
+ }
207053
+ function getOpenClawProfile(agentId) {
207054
+ let output;
207055
+ try {
207056
+ output = execFileSync("openclaw", [
207057
+ "agents",
207058
+ "list",
207059
+ "--json"
207060
+ ], {
207061
+ encoding: "utf8",
207062
+ timeout: 5e3
207063
+ });
207064
+ } catch {
207065
+ return {};
207066
+ }
207067
+ let agents;
207068
+ try {
207069
+ agents = JSON.parse(output);
207070
+ } catch {
207071
+ return {};
207072
+ }
207073
+ const agent = agentId ? agents.find((a) => a.id === agentId) : agents.find((a) => a.isDefault) ?? agents[0];
207074
+ if (!agent) return {};
207075
+ const title = agent.identityName || void 0;
207076
+ return {
207077
+ avatar: agent.identityEmoji || "🦞",
207078
+ description: agent.workspace ? readDescriptionFromWorkspace(agent.workspace) : void 0,
207079
+ title
207080
+ };
207081
+ }
207082
+ /**
207083
+ * Fetch the agent profile (title, avatar, description) from the platform
207084
+ * installed on this device. Dispatched by the server via `device.getAgentProfile`.
207085
+ *
207086
+ * - openclaw: `openclaw agents list --json` for name + emoji, workspace
207087
+ * IDENTITY.md for description fallback
207088
+ * - hermes: not yet implemented — returns empty profile
207089
+ */
207090
+ async function getAgentProfile(params) {
207091
+ const { platform, agentId } = params;
207092
+ if (platform === "openclaw") return getOpenClawProfile(agentId);
207093
+ if (platform === "hermes") return {};
207094
+ return {};
207095
+ }
207096
+
207145
207097
  //#endregion
207146
207098
  //#region src/tools/shell.ts
207147
207099
  const processManager = new ShellProcessManager();
@@ -207166,6 +207118,7 @@ async function killCommand(params) {
207166
207118
  const methodMap = {
207167
207119
  cancelHeteroTask,
207168
207120
  checkPlatformCapability,
207121
+ getAgentProfile,
207169
207122
  editFile: editLocalFile,
207170
207123
  getCommandOutput,
207171
207124
  globFiles: globLocalFiles,
@@ -208704,6 +208657,11 @@ const CLI_AUTH_REQUIRED_PATTERNS = [
208704
208657
  /\b401\b/
208705
208658
  ];
208706
208659
  const CLI_RATE_LIMIT_PATTERNS = [/you'?ve hit your limit/i, /rate limit/i];
208660
+ const CLI_OVERLOADED_PATTERNS = [
208661
+ /overloaded_error/i,
208662
+ /\boverloaded\b/i,
208663
+ /api error:\s*529\b/i
208664
+ ];
208707
208665
  const getCliResultMessage = (result) => {
208708
208666
  if (typeof result === "string") return result;
208709
208667
  if (result && typeof result === "object" && "message" in result && typeof result.message === "string") return result.message;
@@ -208738,6 +208696,18 @@ const toRateLimitInfo = (value) => {
208738
208696
  status: typeof raw.status === "string" ? raw.status : void 0
208739
208697
  };
208740
208698
  };
208699
+ const getOverloadedTerminalError = (result, apiErrorStatus) => {
208700
+ const rawMessage = getCliResultMessage(result);
208701
+ if (!(apiErrorStatus === 529 || !!rawMessage && CLI_OVERLOADED_PATTERNS.some((pattern) => pattern.test(rawMessage))) || !rawMessage) return;
208702
+ return {
208703
+ agentType: "claude-code",
208704
+ clearEchoedContent: true,
208705
+ code: "overloaded",
208706
+ error: rawMessage,
208707
+ message: rawMessage,
208708
+ stderr: rawMessage
208709
+ };
208710
+ };
208741
208711
  const getRateLimitTerminalError = (result, rateLimitInfo, apiErrorStatus) => {
208742
208712
  const rawMessage = getCliResultMessage(result);
208743
208713
  if (!(apiErrorStatus === 429 || !!rateLimitInfo || !!rawMessage && CLI_RATE_LIMIT_PATTERNS.some((pattern) => pattern.test(rawMessage))) || !rawMessage) return;
@@ -209322,7 +209292,7 @@ var ClaudeCodeAdapter = class {
209322
209292
  }));
209323
209293
  const resultMessage = getCliResultMessage(raw.result) || "Agent execution failed";
209324
209294
  const rateLimitError = getRateLimitTerminalError(raw.result, this.pendingRateLimitInfo, raw.api_error_status);
209325
- const finalEvent = raw.is_error ? this.makeEvent("error", rateLimitError || getAuthRequiredTerminalError(raw.result) || {
209295
+ const finalEvent = raw.is_error ? this.makeEvent("error", rateLimitError || getOverloadedTerminalError(raw.result, raw.api_error_status) || getAuthRequiredTerminalError(raw.result) || {
209326
209296
  error: resultMessage,
209327
209297
  message: resultMessage
209328
209298
  }) : this.makeEvent("agent_runtime_end", {});
@@ -210801,6 +210771,35 @@ var TrpcIngestSink = class {
210801
210771
  //#endregion
210802
210772
  //#region src/commands/hetero.ts
210803
210773
  const SUPPORTED_AGENT_TYPES = new Set(["claude-code", "codex"]);
210774
+ /**
210775
+ * Patterns that indicate a `--resume <sessionId>` run should be retried
210776
+ * without `--resume`. Two classes of failure:
210777
+ *
210778
+ * 1. Session file missing (sandbox recycled): the container is ephemeral
210779
+ * (~1 h idle TTL), so a new sandbox has an empty `~/.claude/projects/`
210780
+ * and the stored session id is stale.
210781
+ *
210782
+ * 2. Context overflow (long conversation): the resumed session carries all
210783
+ * accumulated history; when the combined token count exceeds the model's
210784
+ * context window the API rejects the request immediately after CC
210785
+ * initialises. Starting fresh (no `--resume`) drops the old history and
210786
+ * lets CC respond to the new prompt alone.
210787
+ *
210788
+ * Checked against:
210789
+ * - `error` stream events emitted by the CC adapter from CC's result event
210790
+ * - Accumulated stderr output (fallback when CC exits without a result event)
210791
+ */
210792
+ const RESUME_RETRY_PATTERNS = [
210793
+ /no conversation found/i,
210794
+ /session.*not found/i,
210795
+ /conversation.*not found/i,
210796
+ /resume.*not found/i,
210797
+ /prompt.*too long/i,
210798
+ /context.*too long/i,
210799
+ /context window.*exceed/i,
210800
+ /maximum.*context.*length/i
210801
+ ];
210802
+ const looksLikeNeedsRetryWithoutResume = (text) => RESUME_RETRY_PATTERNS.some((p) => p.test(text));
210804
210803
  const collectImage = (value, previous = []) => [...previous, value];
210805
210804
  const readStdin = async () => {
210806
210805
  const chunks = [];
@@ -210935,83 +210934,150 @@ const exec = async (options) => {
210935
210934
  if (serverIngest) sink = new TrpcIngestSink(await getTrpcClient(), agentType, operationId, options.topic);
210936
210935
  else sink = new NoopIngestSink();
210937
210936
  const ingester = new BatchIngester(sink);
210938
- let handle;
210939
- try {
210940
- handle = await spawnAgent({
210937
+ /**
210938
+ * Spawn one agent process and stream all its events into `ingester`.
210939
+ *
210940
+ * When `interceptResumeErrors` is true, any `error`-type event whose
210941
+ * message matches `RESUME_RETRY_PATTERNS` is withheld from the
210942
+ * ingester and signals a retry instead. This keeps the server's
210943
+ * operation state clean: no terminal error event is pushed, so the
210944
+ * retry's events land on the same operationId without confusing the
210945
+ * renderer.
210946
+ *
210947
+ * Returns:
210948
+ * code / signal — child exit info
210949
+ * sessionId — CC session id from `system.init` (undefined on resume failure)
210950
+ * ingestError — true when a batch could not be flushed after retries
210951
+ * resumeNotFound — true when a resume-not-found error was intercepted
210952
+ * stderrContent — accumulated stderr (only when interceptResumeErrors=true)
210953
+ */
210954
+ const runOneAgent = async (spawnOpts, interceptResumeErrors) => {
210955
+ let handle;
210956
+ try {
210957
+ handle = await spawnAgent(spawnOpts);
210958
+ } catch (err) {
210959
+ log$7.error("Failed to start agent:", err instanceof Error ? err.message : String(err));
210960
+ process.exit(1);
210961
+ }
210962
+ const STDERR_CAP = 8 * 1024;
210963
+ let stderrContent = "";
210964
+ handle.stderr.on("data", (chunk) => {
210965
+ if (stderrContent.length < STDERR_CAP) stderrContent += chunk.toString();
210966
+ });
210967
+ handle.stderr.pipe(process.stderr);
210968
+ let interrupted = false;
210969
+ const onSigint = async () => {
210970
+ if (interrupted) {
210971
+ handle.kill("SIGKILL");
210972
+ return;
210973
+ }
210974
+ interrupted = true;
210975
+ handle.kill("SIGINT");
210976
+ if (serverIngest) try {
210977
+ await ingester.drain();
210978
+ await sink.finish({ result: "cancelled" });
210979
+ } catch {}
210980
+ };
210981
+ const onSigterm = async () => {
210982
+ handle.kill("SIGTERM");
210983
+ if (serverIngest) try {
210984
+ await ingester.drain();
210985
+ await sink.finish({ result: "cancelled" });
210986
+ } catch {}
210987
+ };
210988
+ process.on("SIGINT", onSigint);
210989
+ process.on("SIGTERM", onSigterm);
210990
+ let resumeNotFound = false;
210991
+ let ingestError = false;
210992
+ try {
210993
+ for await (const event of handle.events) {
210994
+ if (interceptResumeErrors && event.type === "error") {
210995
+ const data = event.data;
210996
+ if (looksLikeNeedsRetryWithoutResume(String(data?.message ?? data?.error ?? ""))) {
210997
+ resumeNotFound = true;
210998
+ if (emitJsonl) process.stdout.write(`${JSON.stringify(event)}\n`);
210999
+ continue;
211000
+ }
211001
+ }
211002
+ if (emitJsonl) process.stdout.write(`${JSON.stringify(event)}\n`);
211003
+ ingester.push(event);
211004
+ }
211005
+ } catch (err) {
211006
+ log$7.error("Stream error from agent process:", err instanceof Error ? err.message : String(err));
211007
+ if (serverIngest) try {
211008
+ await ingester.drain();
211009
+ await sink.finish({
211010
+ error: {
211011
+ message: String(err),
211012
+ type: "stream_error"
211013
+ },
211014
+ result: "error"
211015
+ });
211016
+ } catch {}
211017
+ process.exit(1);
211018
+ } finally {
211019
+ process.off("SIGINT", onSigint);
211020
+ process.off("SIGTERM", onSigterm);
211021
+ }
211022
+ const { code, signal } = await handle.exit;
211023
+ if (interceptResumeErrors && !resumeNotFound && code !== 0 && looksLikeNeedsRetryWithoutResume(stderrContent)) resumeNotFound = true;
211024
+ return {
211025
+ code,
211026
+ ingestError,
211027
+ resumeNotFound,
211028
+ sessionId: handle.sessionId,
211029
+ signal,
211030
+ stderrContent
211031
+ };
211032
+ };
211033
+ const interceptResume = !!options.resume;
211034
+ const first = await runOneAgent({
211035
+ agentType: options.type,
211036
+ command: options.command,
211037
+ cwd: options.cwd || process.cwd(),
211038
+ operationId,
211039
+ prompt: resolved.prompt,
211040
+ resumeSessionId: options.resume
211041
+ }, interceptResume);
211042
+ let result = first;
211043
+ if (first.resumeNotFound) {
211044
+ log$7.info("Resume failed (session not found or context overflow) — retrying without --resume");
211045
+ result = await runOneAgent({
210941
211046
  agentType: options.type,
210942
211047
  command: options.command,
210943
211048
  cwd: options.cwd || process.cwd(),
210944
211049
  operationId,
210945
- prompt: resolved.prompt,
210946
- resumeSessionId: options.resume
210947
- });
210948
- } catch (err) {
210949
- log$7.error("Failed to start agent:", err instanceof Error ? err.message : String(err));
210950
- process.exit(1);
210951
- }
210952
- handle.stderr.pipe(process.stderr);
210953
- let interrupted = false;
210954
- const onSigint = async () => {
210955
- if (interrupted) {
210956
- handle.kill("SIGKILL");
210957
- return;
210958
- }
210959
- interrupted = true;
210960
- handle.kill("SIGINT");
210961
- if (serverIngest) try {
210962
- await ingester.drain();
210963
- await sink.finish({ result: "cancelled" });
210964
- } catch {}
210965
- };
210966
- process.on("SIGINT", onSigint);
210967
- process.on("SIGTERM", async () => {
210968
- handle.kill("SIGTERM");
210969
- if (serverIngest) try {
210970
- await ingester.drain();
210971
- await sink.finish({ result: "cancelled" });
210972
- } catch {}
210973
- });
210974
- let ingestError = false;
210975
- try {
210976
- for await (const event of handle.events) {
210977
- if (emitJsonl) process.stdout.write(`${JSON.stringify(event)}\n`);
210978
- ingester.push(event);
210979
- }
210980
- } catch (err) {
210981
- log$7.error("Stream error from agent process:", err instanceof Error ? err.message : String(err));
210982
- if (serverIngest) try {
210983
- await ingester.drain();
210984
- await sink.finish({
210985
- result: "error",
210986
- error: {
210987
- message: String(err),
210988
- type: "stream_error"
210989
- }
210990
- });
210991
- } catch {}
210992
- process.exit(1);
210993
- } finally {
210994
- process.off("SIGINT", onSigint);
211050
+ prompt: resolved.prompt
211051
+ }, false);
210995
211052
  }
210996
- const { code, signal } = await handle.exit;
211053
+ const { code, signal, sessionId } = result;
210997
211054
  if (serverIngest) {
210998
211055
  try {
210999
211056
  await ingester.drain();
211000
211057
  } catch (err) {
211001
211058
  log$7.error("Failed to flush events to server:", err instanceof Error ? err.message : String(err));
211002
- ingestError = true;
211059
+ result = {
211060
+ ...result,
211061
+ ingestError: true
211062
+ };
211003
211063
  }
211004
- const exitedClean = !ingestError && (code === 0 || signal === "SIGTERM");
211064
+ const exitedClean = !result.ingestError && (code === 0 || signal === "SIGTERM");
211065
+ const stderrTail = result.stderrContent.trim();
211066
+ const finishError = !exitedClean && stderrTail ? {
211067
+ message: stderrTail.slice(-1024),
211068
+ type: "AgentRuntimeError"
211069
+ } : void 0;
211005
211070
  try {
211006
211071
  await sink.finish({
211072
+ error: finishError,
211007
211073
  result: exitedClean ? "success" : "error",
211008
- sessionId: handle.sessionId
211074
+ sessionId
211009
211075
  });
211010
211076
  } catch (err) {
211011
211077
  log$7.error("Failed to send heteroFinish:", err instanceof Error ? err.message : String(err));
211012
211078
  }
211013
211079
  }
211014
- if (code !== null) process.exit(ingestError ? 1 : code);
211080
+ if (code !== null) process.exit(result.ingestError ? 1 : code);
211015
211081
  if (signal === "SIGINT") process.exit(130);
211016
211082
  if (signal === "SIGTERM") process.exit(143);
211017
211083
  if (signal === "SIGKILL") process.exit(137);
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.16" "User Commands"
3
+ .TH LH 1 "" "@lobehub/cli 0.0.18" "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.16",
3
+ "version": "0.0.18",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "lh": "./dist/index.js",