aai-lark-bridge 0.2.8 → 0.2.9

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/cli.js CHANGED
@@ -4,7 +4,7 @@ import { Command } from "commander";
4
4
  // package.json
5
5
  var package_default = {
6
6
  name: "aai-lark-bridge",
7
- version: "0.2.8",
7
+ version: "0.2.9",
8
8
  description: "Lark AI Native Bridge - Lark\u57FA\u7840\u8BBE\u65BD\u5C42\u548CCLI\u96C6\u6210",
9
9
  type: "module",
10
10
  main: "./dist/index.js",
@@ -1541,15 +1541,31 @@ var log = {
1541
1541
  const stack = err instanceof Error ? err.stack : void 0;
1542
1542
  const apiData = err?.response?.data;
1543
1543
  const apiStatus = err?.response?.status;
1544
+ const code = err?.code;
1545
+ const cause = err instanceof Error && "cause" in err && err.cause !== void 0 ? describeCause(err.cause) : void 0;
1544
1546
  emit("error", phase, "fail", {
1545
1547
  ...fields,
1546
1548
  err: message,
1549
+ ...typeof code === "string" ? { code } : {},
1547
1550
  apiStatus,
1548
1551
  apiData,
1549
- stack
1552
+ stack,
1553
+ ...cause !== void 0 ? { cause } : {}
1550
1554
  });
1551
1555
  }
1552
1556
  };
1557
+ function describeCause(cause) {
1558
+ if (!(cause instanceof Error)) return String(cause);
1559
+ const c = cause;
1560
+ return {
1561
+ name: c.name,
1562
+ message: c.message,
1563
+ ...c.code !== void 0 ? { code: c.code } : {},
1564
+ ...c.errno !== void 0 ? { errno: c.errno } : {},
1565
+ ...c.syscall !== void 0 ? { syscall: c.syscall } : {},
1566
+ ...c.stack ? { stack: c.stack } : {}
1567
+ };
1568
+ }
1553
1569
  function configureLogger(opts) {
1554
1570
  if (stream) {
1555
1571
  try {
@@ -1569,6 +1585,9 @@ function withTrace(ctx, fn) {
1569
1585
  const traceId = ctx.traceId ?? newTraceId();
1570
1586
  return als.run({ ...ctx, traceId }, fn);
1571
1587
  }
1588
+ function currentTraceId() {
1589
+ return als.getStore()?.traceId;
1590
+ }
1572
1591
  function newTraceId() {
1573
1592
  return Math.random().toString(36).slice(2, 10);
1574
1593
  }
@@ -15283,6 +15302,10 @@ function dmBinding(controls, msg, scope, opts = {}) {
15283
15302
  }
15284
15303
  return result;
15285
15304
  }
15305
+ function spawnFailedReply() {
15306
+ const traceId = currentTraceId();
15307
+ return "\u26A0\uFE0F \u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u4EA4\u7ED9 agent\uFF1Abridge \u6CA1\u80FD\u542F\u52A8 agent\u3002\u8BF7\u7A0D\u540E\u91CD\u53D1\uFF1B\u8FDE\u7EED\u5931\u8D25\u8BF7\u8054\u7CFB bridge \u7BA1\u7406\u5458\u91CD\u542F bridge" + (traceId ? `\uFF0C\u5E76\u9644\u4E0A\u6392\u67E5\u7F16\u53F7 ${traceId}\u3002` : "\u3002");
15308
+ }
15286
15309
  async function runAgentBatch(deps) {
15287
15310
  const {
15288
15311
  channel,
@@ -15428,6 +15451,13 @@ async function runAgentBatch(deps) {
15428
15451
  source: "im",
15429
15452
  stage: "submit"
15430
15453
  }
15454
+ }).catch(async (err) => {
15455
+ if (err instanceof SpawnFailed) {
15456
+ await channel.send(chatId, { markdown: spawnFailedReply() }, sendOpts).catch((replyErr) => {
15457
+ log.fail("flush", replyErr, { step: "postSpawnFailedReply" });
15458
+ });
15459
+ }
15460
+ throw err;
15431
15461
  });
15432
15462
  if (!flow.ok) {
15433
15463
  log.info("run-flow", "rejected", { scope, code: flow.rejectReason.code });