codex-to-im 1.0.12 → 1.0.13

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/daemon.mjs CHANGED
@@ -14984,6 +14984,9 @@ function readDesktopSessionEventStream(threadId) {
14984
14984
  function formatChannelLabel(channelType) {
14985
14985
  return channelType === "weixin" ? "\u5FAE\u4FE1" : channelType === "feishu" ? "\u98DE\u4E66" : channelType;
14986
14986
  }
14987
+ function formatBindingChatTarget(binding) {
14988
+ return binding.chatDisplayName?.trim() || binding.chatId;
14989
+ }
14987
14990
  function findConflictingBinding(store, current, match2) {
14988
14991
  return store.listChannelBindings().find((binding) => {
14989
14992
  if (binding.channelType === current.channelType && binding.chatId === current.chatId) {
@@ -15000,7 +15003,7 @@ function assertBindingTargetAvailable(store, current, opts) {
15000
15003
  );
15001
15004
  if (!conflict) return;
15002
15005
  throw new Error(
15003
- `\u8BE5\u4F1A\u8BDD\u5DF2\u7ED1\u5B9A\u5230 ${formatChannelLabel(conflict.channelType)} \u804A\u5929 ${conflict.chatId}\u3002\u4E00\u4E2A\u4F1A\u8BDD\u53EA\u80FD\u7ED1\u5B9A\u4E00\u4E2A\u804A\u5929\u3002`
15006
+ `\u8BE5\u4F1A\u8BDD\u5DF2\u7ED1\u5B9A\u5230 ${formatChannelLabel(conflict.channelType)} \u804A\u5929 ${formatBindingChatTarget(conflict)}\u3002\u4E00\u4E2A\u4F1A\u8BDD\u53EA\u80FD\u7ED1\u5B9A\u4E00\u4E2A\u804A\u5929\u3002`
15004
15007
  );
15005
15008
  }
15006
15009
  function getSessionMode(store, session) {
@@ -16891,6 +16894,33 @@ function renderFeedbackText(text2, parseMode) {
16891
16894
  function renderFeedbackTextForChannel(channelType, text2) {
16892
16895
  return renderFeedbackText(text2, getFeedbackParseMode(channelType));
16893
16896
  }
16897
+ function toUserVisibleBindingError(error, fallback) {
16898
+ if (error instanceof Error) {
16899
+ const message = error.message?.trim();
16900
+ if (message) return message;
16901
+ }
16902
+ return fallback;
16903
+ }
16904
+ function formatBindingChatLabel(binding) {
16905
+ const channelLabel = binding.channelType === "weixin" ? "\u5FAE\u4FE1" : binding.channelType === "feishu" ? "\u98DE\u4E66" : binding.channelType;
16906
+ const chatLabel = binding.chatDisplayName?.trim() || binding.chatId;
16907
+ return `${channelLabel} \u804A\u5929 ${chatLabel}`;
16908
+ }
16909
+ function toUserVisibleCommandError(command, error) {
16910
+ if (error instanceof Error) {
16911
+ const message = error.message?.trim();
16912
+ if (message && /一个会话只能绑定一个聊天|已绑定到/.test(message)) {
16913
+ return message;
16914
+ }
16915
+ }
16916
+ if (command === "/history") {
16917
+ return "\u6574\u7406\u5386\u53F2\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\uFF1B\u4E5F\u53EF\u4EE5\u53D1\u9001 /history raw \u67E5\u770B\u539F\u59CB\u8BB0\u5F55\u3002";
16918
+ }
16919
+ if (command === "/new") {
16920
+ return "\u65B0\u5EFA\u4F1A\u8BDD\u5931\u8D25\u3002\u8BF7\u68C0\u67E5\u76EE\u5F55\u662F\u5426\u53EF\u5199\uFF0C\u6216\u6539\u7528 /new \u7EDD\u5BF9\u8DEF\u5F84\u3002";
16921
+ }
16922
+ return `${command} \u6267\u884C\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002`;
16923
+ }
16894
16924
  function resolveEffectiveReasoningEffort(session) {
16895
16925
  const { store } = getBridgeContext();
16896
16926
  const configured = session?.reasoning_effort || store.getSetting("bridge_codex_reasoning_effort");
@@ -18321,7 +18351,21 @@ async function handleMessage(adapter, msg) {
18321
18351
  }
18322
18352
  }
18323
18353
  if (rawText.startsWith("/")) {
18324
- await handleCommand(adapter, msg, rawText);
18354
+ const parts = rawText.split(/\s+/);
18355
+ const rawCommand = parts[0].split("@")[0].toLowerCase();
18356
+ const args = parts.slice(1).join(" ").trim();
18357
+ const resolvedCommand = resolveCommandAlias(rawCommand, args);
18358
+ try {
18359
+ await handleCommand(adapter, msg, rawText);
18360
+ } catch (error) {
18361
+ console.error(`[bridge-manager] Command failed: ${resolvedCommand}`, error);
18362
+ await deliver(adapter, {
18363
+ address: msg.address,
18364
+ text: toUserVisibleCommandError(resolvedCommand, error),
18365
+ parseMode: getFeedbackParseMode(adapter.channelType),
18366
+ replyToMessageId: msg.messageId
18367
+ });
18368
+ }
18325
18369
  ack();
18326
18370
  return;
18327
18371
  }
@@ -18585,10 +18629,16 @@ async function handleCommand(adapter, msg, text2) {
18585
18629
  if (prefersThreadList) {
18586
18630
  const threadPick2 = resolveByIndexOrPrefix(args, displayedThreads, (session) => session.threadId);
18587
18631
  if (threadPick2.match) {
18588
- const importedBinding2 = bindToSdkSession(msg.address, threadPick2.match.threadId, {
18589
- workingDirectory: threadPick2.match.cwd,
18590
- displayName: threadPick2.match.title
18591
- });
18632
+ let importedBinding2;
18633
+ try {
18634
+ importedBinding2 = bindToSdkSession(msg.address, threadPick2.match.threadId, {
18635
+ workingDirectory: threadPick2.match.cwd,
18636
+ displayName: threadPick2.match.title
18637
+ });
18638
+ } catch (error) {
18639
+ response = toUserVisibleBindingError(error, "\u7ED1\u5B9A\u684C\u9762\u4F1A\u8BDD\u5931\u8D25\u3002");
18640
+ break;
18641
+ }
18592
18642
  const session = store.getSession(importedBinding2.codepilotSessionId);
18593
18643
  response = buildCommandFields(
18594
18644
  "\u5DF2\u7ED1\u5B9A\u684C\u9762\u4F1A\u8BDD",
@@ -18609,7 +18659,13 @@ async function handleCommand(adapter, msg, text2) {
18609
18659
  break;
18610
18660
  }
18611
18661
  if (sessionPick.match) {
18612
- const binding = bindToSession(msg.address, sessionPick.match.id);
18662
+ let binding;
18663
+ try {
18664
+ binding = bindToSession(msg.address, sessionPick.match.id);
18665
+ } catch (error) {
18666
+ response = toUserVisibleBindingError(error, "\u5207\u6362\u4F1A\u8BDD\u5931\u8D25\u3002");
18667
+ break;
18668
+ }
18613
18669
  if (binding) {
18614
18670
  response = buildCommandFields(
18615
18671
  "\u5DF2\u5207\u6362\u4F1A\u8BDD\uFF08\u517C\u5BB9\u547D\u4EE4\uFF09",
@@ -18632,10 +18688,16 @@ async function handleCommand(adapter, msg, text2) {
18632
18688
  response = "\u6CA1\u6709\u627E\u5230\u5BF9\u5E94\u76EE\u6807\u3002\u5148\u53D1\u9001 `/t` \u67E5\u770B\u684C\u9762\u4F1A\u8BDD\uFF0C\u518D\u6309\u5E8F\u53F7\u5207\u6362\u3002";
18633
18689
  break;
18634
18690
  }
18635
- const importedBinding = bindToSdkSession(msg.address, threadPick.match.threadId, {
18636
- workingDirectory: threadPick.match.cwd,
18637
- displayName: threadPick.match.title
18638
- });
18691
+ let importedBinding;
18692
+ try {
18693
+ importedBinding = bindToSdkSession(msg.address, threadPick.match.threadId, {
18694
+ workingDirectory: threadPick.match.cwd,
18695
+ displayName: threadPick.match.title
18696
+ });
18697
+ } catch (error) {
18698
+ response = toUserVisibleBindingError(error, "\u7ED1\u5B9A\u684C\u9762\u4F1A\u8BDD\u5931\u8D25\u3002");
18699
+ break;
18700
+ }
18639
18701
  const importedSession = store.getSession(importedBinding.codepilotSessionId);
18640
18702
  response = buildCommandFields(
18641
18703
  "\u5DF2\u7ED1\u5B9A\u684C\u9762\u4F1A\u8BDD",
@@ -18687,10 +18749,16 @@ async function handleCommand(adapter, msg, text2) {
18687
18749
  if (!threadPick.match) {
18688
18750
  if (validateSessionId(args)) {
18689
18751
  const desktop = getDesktopSessionByThreadId(args);
18690
- const binding2 = bindToSdkSession(msg.address, args, desktop ? {
18691
- workingDirectory: desktop.cwd,
18692
- displayName: desktop.title
18693
- } : void 0);
18752
+ let binding2;
18753
+ try {
18754
+ binding2 = bindToSdkSession(msg.address, args, desktop ? {
18755
+ workingDirectory: desktop.cwd,
18756
+ displayName: desktop.title
18757
+ } : void 0);
18758
+ } catch (error) {
18759
+ response = toUserVisibleBindingError(error, "\u5207\u6362\u684C\u9762\u4F1A\u8BDD\u5931\u8D25\u3002");
18760
+ break;
18761
+ }
18694
18762
  const session = store.getSession(binding2.codepilotSessionId);
18695
18763
  response = buildCommandFields(
18696
18764
  "\u5DF2\u5207\u6362\u5230\u684C\u9762\u4F1A\u8BDD",
@@ -18706,10 +18774,16 @@ async function handleCommand(adapter, msg, text2) {
18706
18774
  response = "\u6CA1\u6709\u627E\u5230\u5BF9\u5E94\u7684\u684C\u9762\u4F1A\u8BDD\u3002\u5148\u53D1\u9001 `/t` \u67E5\u770B\u6700\u8FD1\u4F1A\u8BDD\uFF0C\u518D\u7528 `/t 1` \u63A5\u7BA1\u3002";
18707
18775
  break;
18708
18776
  }
18709
- const binding = bindToSdkSession(msg.address, threadPick.match.threadId, {
18710
- workingDirectory: threadPick.match.cwd,
18711
- displayName: threadPick.match.title
18712
- });
18777
+ let binding;
18778
+ try {
18779
+ binding = bindToSdkSession(msg.address, threadPick.match.threadId, {
18780
+ workingDirectory: threadPick.match.cwd,
18781
+ displayName: threadPick.match.title
18782
+ });
18783
+ } catch (error) {
18784
+ response = toUserVisibleBindingError(error, "\u5207\u6362\u684C\u9762\u4F1A\u8BDD\u5931\u8D25\u3002");
18785
+ break;
18786
+ }
18713
18787
  response = buildCommandFields(
18714
18788
  "\u5DF2\u5207\u6362\u5230\u684C\u9762\u4F1A\u8BDD",
18715
18789
  [
@@ -18759,7 +18833,13 @@ async function handleCommand(adapter, msg, text2) {
18759
18833
  response = "\u6CA1\u6709\u627E\u5230\u5BF9\u5E94\u7684\u5185\u90E8\u4F1A\u8BDD\u3002\u5148\u53D1\u9001 /sessions \u67E5\u770B\u53EF\u9009\u9879\u3002";
18760
18834
  break;
18761
18835
  }
18762
- const binding = bindToSession(msg.address, sessionPick.match.id);
18836
+ let binding;
18837
+ try {
18838
+ binding = bindToSession(msg.address, sessionPick.match.id);
18839
+ } catch (error) {
18840
+ response = toUserVisibleBindingError(error, "\u5207\u6362\u4F1A\u8BDD\u5931\u8D25\u3002");
18841
+ break;
18842
+ }
18763
18843
  if (!binding) {
18764
18844
  response = "\u5207\u6362\u5931\u8D25\uFF0C\u8BE5\u4F1A\u8BDD\u4E0D\u5B58\u5728\u3002";
18765
18845
  break;
@@ -19087,7 +19167,7 @@ ${truncateHistoryContent(formatStoredMessageContent(message.content))}`;
19087
19167
  response = buildCommandFields(
19088
19168
  "\u5DF2\u89E3\u7ED1\u5F53\u524D\u804A\u5929",
19089
19169
  [
19090
- ["\u804A\u5929", msg.address.chatId]
19170
+ ["\u804A\u5929", formatBindingChatLabel(currentBinding)]
19091
19171
  ],
19092
19172
  [
19093
19173
  "\u8FD9\u4E2A\u804A\u5929\u5DF2\u91CA\u653E\u5F53\u524D\u4F1A\u8BDD\u7ED1\u5B9A\u3002",
@@ -5563,6 +5563,9 @@ import path4 from "node:path";
5563
5563
  function formatChannelLabel(channelType) {
5564
5564
  return channelType === "weixin" ? "\u5FAE\u4FE1" : channelType === "feishu" ? "\u98DE\u4E66" : channelType;
5565
5565
  }
5566
+ function formatBindingChatTarget(binding) {
5567
+ return binding.chatDisplayName?.trim() || binding.chatId;
5568
+ }
5566
5569
  function findConflictingBinding(store, current, match) {
5567
5570
  return store.listChannelBindings().find((binding) => {
5568
5571
  if (binding.channelType === current.channelType && binding.chatId === current.chatId) {
@@ -5579,7 +5582,7 @@ function assertBindingTargetAvailable(store, current, opts) {
5579
5582
  );
5580
5583
  if (!conflict) return;
5581
5584
  throw new Error(
5582
- `\u8BE5\u4F1A\u8BDD\u5DF2\u7ED1\u5B9A\u5230 ${formatChannelLabel(conflict.channelType)} \u804A\u5929 ${conflict.chatId}\u3002\u4E00\u4E2A\u4F1A\u8BDD\u53EA\u80FD\u7ED1\u5B9A\u4E00\u4E2A\u804A\u5929\u3002`
5585
+ `\u8BE5\u4F1A\u8BDD\u5DF2\u7ED1\u5B9A\u5230 ${formatChannelLabel(conflict.channelType)} \u804A\u5929 ${formatBindingChatTarget(conflict)}\u3002\u4E00\u4E2A\u4F1A\u8BDD\u53EA\u80FD\u7ED1\u5B9A\u4E00\u4E2A\u804A\u5929\u3002`
5583
5586
  );
5584
5587
  }
5585
5588
  function getSessionName(session) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-to-im",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "Installable Codex-to-IM bridge with local setup UI and background service",
5
5
  "license": "MIT",
6
6
  "type": "module",