codex-to-im 1.0.21 → 1.0.23
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/README.md +1 -1
- package/README_EN.md +105 -172
- package/SECURITY.md +3 -7
- package/dist/cli.mjs +100 -8
- package/dist/daemon.mjs +30 -90
- package/dist/ui-server.mjs +201 -593
- package/docs/codex-to-im-prd.md +1 -1
- package/docs/codex-to-im-shared-thread-design.md +8 -8
- package/docs/install-windows.md +5 -9
- package/package.json +1 -1
- package/references/troubleshooting.md +1 -1
- package/scripts/daemon.sh +6 -6
- package/scripts/doctor.sh +2 -2
- package/scripts/supervisor-macos.sh +1 -1
- package/scripts/supervisor-windows.ps1 +8 -8
package/dist/daemon.mjs
CHANGED
|
@@ -5096,15 +5096,9 @@ function toFeishuConfig(channel) {
|
|
|
5096
5096
|
function toWeixinConfig(channel) {
|
|
5097
5097
|
return channel?.provider === "weixin" ? channel.config : void 0;
|
|
5098
5098
|
}
|
|
5099
|
-
var LEGACY_CTI_HOME = path.join(os.homedir(), ".claude-to-im");
|
|
5100
5099
|
var DEFAULT_CTI_HOME = path.join(os.homedir(), ".codex-to-im");
|
|
5101
5100
|
var DEFAULT_WORKSPACE_ROOT = path.join(os.homedir(), "cx2im");
|
|
5102
|
-
|
|
5103
|
-
if (fs.existsSync(DEFAULT_CTI_HOME)) return DEFAULT_CTI_HOME;
|
|
5104
|
-
if (fs.existsSync(LEGACY_CTI_HOME)) return LEGACY_CTI_HOME;
|
|
5105
|
-
return DEFAULT_CTI_HOME;
|
|
5106
|
-
}
|
|
5107
|
-
var CTI_HOME = process.env.CTI_HOME || resolveDefaultCtiHome();
|
|
5101
|
+
var CTI_HOME = process.env.CTI_HOME || DEFAULT_CTI_HOME;
|
|
5108
5102
|
var CONFIG_PATH = path.join(CTI_HOME, "config.env");
|
|
5109
5103
|
var CONFIG_V2_PATH = path.join(CTI_HOME, "config.v2.json");
|
|
5110
5104
|
function expandHomePath(value) {
|
|
@@ -15305,7 +15299,7 @@ function assertBindingTargetAvailable(store, current, opts) {
|
|
|
15305
15299
|
function getSessionMode(store, session) {
|
|
15306
15300
|
return session.preferred_mode || store.getSetting("bridge_default_mode") || "code";
|
|
15307
15301
|
}
|
|
15308
|
-
function bindStoreToSession(store, channelType, chatId, sessionId) {
|
|
15302
|
+
function bindStoreToSession(store, channelType, chatId, sessionId, chatMeta) {
|
|
15309
15303
|
const session = store.getSession(sessionId);
|
|
15310
15304
|
if (!session) return null;
|
|
15311
15305
|
assertBindingTargetAvailable(
|
|
@@ -15319,6 +15313,8 @@ function bindStoreToSession(store, channelType, chatId, sessionId) {
|
|
|
15319
15313
|
channelProvider: meta.provider,
|
|
15320
15314
|
channelAlias: meta.alias,
|
|
15321
15315
|
chatId,
|
|
15316
|
+
chatUserId: chatMeta?.chatUserId,
|
|
15317
|
+
chatDisplayName: chatMeta?.chatDisplayName,
|
|
15322
15318
|
codepilotSessionId: session.id,
|
|
15323
15319
|
sdkSessionId: session.sdk_session_id || "",
|
|
15324
15320
|
workingDirectory: session.working_directory,
|
|
@@ -15340,6 +15336,8 @@ function bindStoreToSdkSession(store, channelType, chatId, sdkSessionId, opts) {
|
|
|
15340
15336
|
channelProvider: meta.provider,
|
|
15341
15337
|
channelAlias: meta.alias,
|
|
15342
15338
|
chatId,
|
|
15339
|
+
chatUserId: opts?.chatUserId,
|
|
15340
|
+
chatDisplayName: opts?.chatDisplayName,
|
|
15343
15341
|
codepilotSessionId: existing.id,
|
|
15344
15342
|
sdkSessionId,
|
|
15345
15343
|
workingDirectory: opts?.workingDirectory || existing.working_directory,
|
|
@@ -15363,6 +15361,8 @@ function bindStoreToSdkSession(store, channelType, chatId, sdkSessionId, opts) {
|
|
|
15363
15361
|
channelProvider: meta.provider,
|
|
15364
15362
|
channelAlias: meta.alias,
|
|
15365
15363
|
chatId,
|
|
15364
|
+
chatUserId: opts?.chatUserId,
|
|
15365
|
+
chatDisplayName: opts?.chatDisplayName,
|
|
15366
15366
|
codepilotSessionId: session.id,
|
|
15367
15367
|
sdkSessionId,
|
|
15368
15368
|
workingDirectory: workingDirectory || session.working_directory,
|
|
@@ -15504,10 +15504,23 @@ function createBinding(address, workingDirectory) {
|
|
|
15504
15504
|
});
|
|
15505
15505
|
}
|
|
15506
15506
|
function bindToSession(address, codepilotSessionId) {
|
|
15507
|
-
return bindStoreToSession(
|
|
15507
|
+
return bindStoreToSession(
|
|
15508
|
+
getBridgeContext().store,
|
|
15509
|
+
address.channelType,
|
|
15510
|
+
address.chatId,
|
|
15511
|
+
codepilotSessionId,
|
|
15512
|
+
{
|
|
15513
|
+
chatUserId: address.userId,
|
|
15514
|
+
chatDisplayName: address.displayName
|
|
15515
|
+
}
|
|
15516
|
+
);
|
|
15508
15517
|
}
|
|
15509
15518
|
function bindToSdkSession(address, sdkSessionId, opts) {
|
|
15510
|
-
return bindStoreToSdkSession(getBridgeContext().store, address.channelType, address.chatId, sdkSessionId,
|
|
15519
|
+
return bindStoreToSdkSession(getBridgeContext().store, address.channelType, address.chatId, sdkSessionId, {
|
|
15520
|
+
...opts,
|
|
15521
|
+
chatUserId: address.userId,
|
|
15522
|
+
chatDisplayName: address.displayName
|
|
15523
|
+
});
|
|
15511
15524
|
}
|
|
15512
15525
|
function updateBinding(id, updates) {
|
|
15513
15526
|
getBridgeContext().store.updateChannelBinding(id, updates);
|
|
@@ -17114,18 +17127,6 @@ function parseDesktopThreadListArgs(args) {
|
|
|
17114
17127
|
if (!Number.isInteger(limit) || limit < 1) return null;
|
|
17115
17128
|
return { showAll: false, limit };
|
|
17116
17129
|
}
|
|
17117
|
-
function getDisplayedBridgeSessions(currentSessionId) {
|
|
17118
|
-
const { store } = getBridgeContext();
|
|
17119
|
-
const sessions = store.listSessions().filter((session) => session.hidden !== true).toReversed();
|
|
17120
|
-
return sessions.sort((a, b) => {
|
|
17121
|
-
if (a.id === currentSessionId && b.id !== currentSessionId) return -1;
|
|
17122
|
-
if (b.id === currentSessionId && a.id !== currentSessionId) return 1;
|
|
17123
|
-
const aShared = a.sdk_session_id ? 1 : 0;
|
|
17124
|
-
const bShared = b.sdk_session_id ? 1 : 0;
|
|
17125
|
-
if (aShared !== bShared) return bShared - aShared;
|
|
17126
|
-
return a.name?.localeCompare(b.name || "") || 0;
|
|
17127
|
-
});
|
|
17128
|
-
}
|
|
17129
17130
|
function getSessionDisplayName(session, fallbackDirectory) {
|
|
17130
17131
|
if (session?.name?.trim()) return session.name.trim();
|
|
17131
17132
|
const cwd = session?.working_directory || fallbackDirectory || "";
|
|
@@ -19471,43 +19472,6 @@ async function handleCommand(adapter, msg, text2) {
|
|
|
19471
19472
|
);
|
|
19472
19473
|
break;
|
|
19473
19474
|
}
|
|
19474
|
-
case "/use": {
|
|
19475
|
-
if (!args) {
|
|
19476
|
-
response = "\u7528\u6CD5\uFF1A/use <session-id | \u5E8F\u53F7>";
|
|
19477
|
-
break;
|
|
19478
|
-
}
|
|
19479
|
-
const displayedSessions = getDisplayedBridgeSessions(currentBinding?.codepilotSessionId);
|
|
19480
|
-
const sessionPick = resolveByIndexOrPrefix(args, displayedSessions, (session) => session.id);
|
|
19481
|
-
if (sessionPick.ambiguous) {
|
|
19482
|
-
response = "\u5339\u914D\u5230\u591A\u4E2A\u5185\u90E8\u4F1A\u8BDD\uFF0C\u8BF7\u4F7F\u7528\u66F4\u957F\u7684\u7F16\u53F7\u3002";
|
|
19483
|
-
break;
|
|
19484
|
-
}
|
|
19485
|
-
if (!sessionPick.match) {
|
|
19486
|
-
response = "\u6CA1\u6709\u627E\u5230\u5BF9\u5E94\u7684\u5185\u90E8\u4F1A\u8BDD\u3002\u5148\u53D1\u9001 /sessions \u67E5\u770B\u53EF\u9009\u9879\u3002";
|
|
19487
|
-
break;
|
|
19488
|
-
}
|
|
19489
|
-
let binding;
|
|
19490
|
-
try {
|
|
19491
|
-
binding = bindToSession(msg.address, sessionPick.match.id);
|
|
19492
|
-
} catch (error) {
|
|
19493
|
-
response = toUserVisibleBindingError(error, "\u5207\u6362\u4F1A\u8BDD\u5931\u8D25\u3002");
|
|
19494
|
-
break;
|
|
19495
|
-
}
|
|
19496
|
-
if (!binding) {
|
|
19497
|
-
response = "\u5207\u6362\u5931\u8D25\uFF0C\u8BE5\u4F1A\u8BDD\u4E0D\u5B58\u5728\u3002";
|
|
19498
|
-
break;
|
|
19499
|
-
}
|
|
19500
|
-
response = buildCommandFields(
|
|
19501
|
-
"\u5DF2\u5207\u6362\u4F1A\u8BDD\uFF08\u517C\u5BB9\u547D\u4EE4\uFF09",
|
|
19502
|
-
[
|
|
19503
|
-
["\u6807\u9898", getSessionDisplayName(sessionPick.match, binding.workingDirectory)],
|
|
19504
|
-
["\u76EE\u5F55", formatCommandPath(binding.workingDirectory)]
|
|
19505
|
-
],
|
|
19506
|
-
["\u666E\u901A\u4F7F\u7528\u5EFA\u8BAE\u76F4\u63A5\u901A\u8FC7 `/t` \u5207\u6362\u684C\u9762\u4F1A\u8BDD\u3002"],
|
|
19507
|
-
responseParseMode === "Markdown"
|
|
19508
|
-
);
|
|
19509
|
-
break;
|
|
19510
|
-
}
|
|
19511
19475
|
case "/reasoning": {
|
|
19512
19476
|
if (!currentBinding) {
|
|
19513
19477
|
response = "\u5F53\u524D\u804A\u5929\u8FD8\u6CA1\u6709\u7ED1\u5B9A\u4F1A\u8BDD\u3002\u5148\u53D1\u9001\u6D88\u606F\u521B\u5EFA\u4F1A\u8BDD\uFF0C\u6216\u5148\u7528 `/t 1` \u63A5\u7BA1\u684C\u9762\u4F1A\u8BDD\u3002";
|
|
@@ -19549,7 +19513,7 @@ async function handleCommand(adapter, msg, text2) {
|
|
|
19549
19513
|
break;
|
|
19550
19514
|
}
|
|
19551
19515
|
case "/cwd": {
|
|
19552
|
-
response = "\u5F53\u524D\u7248\u672C\u5DF2\u4E0D\u652F\u6301 /cwd\u3002\u8BF7\u4F7F\u7528 /new \u65B0\u5EFA\u4F1A\u8BDD\uFF0C\u6216\u4F7F\u7528 /
|
|
19516
|
+
response = "\u5F53\u524D\u7248\u672C\u5DF2\u4E0D\u652F\u6301 /cwd\u3002\u8BF7\u4F7F\u7528 /new \u65B0\u5EFA\u4F1A\u8BDD\uFF0C\u6216\u4F7F\u7528 /t \u5207\u6362\u5230\u5DF2\u6709\u684C\u9762\u4F1A\u8BDD\u3002";
|
|
19553
19517
|
break;
|
|
19554
19518
|
}
|
|
19555
19519
|
case "/mode": {
|
|
@@ -19746,32 +19710,6 @@ ${truncateHistoryContent(formatStoredMessageContent(message.content))}`;
|
|
|
19746
19710
|
response = [header, summary].join("\n\n").trim();
|
|
19747
19711
|
break;
|
|
19748
19712
|
}
|
|
19749
|
-
case "/sessions": {
|
|
19750
|
-
const sessions = getDisplayedBridgeSessions(currentBinding?.codepilotSessionId);
|
|
19751
|
-
if (sessions.length === 0) {
|
|
19752
|
-
response = "\u5F53\u524D\u6CA1\u6709\u5185\u90E8\u4F1A\u8BDD\u3002\u666E\u901A\u4F7F\u7528\u5EFA\u8BAE\u76F4\u63A5\u53D1\u9001\u6D88\u606F\u521B\u5EFA\u4F1A\u8BDD\uFF0C\u6216\u5148\u7528 `/t 1` \u63A5\u7BA1\u684C\u9762\u4F1A\u8BDD\u3002";
|
|
19753
|
-
} else {
|
|
19754
|
-
response = buildIndexedCommandList(
|
|
19755
|
-
"\u53EF\u5207\u6362\u7684\u5185\u90E8\u4F1A\u8BDD\uFF08\u517C\u5BB9\u547D\u4EE4\uFF09",
|
|
19756
|
-
sessions.slice(0, 10).map((session) => {
|
|
19757
|
-
const threadTitle = session.sdk_session_id ? getDesktopThreadTitle(session.sdk_session_id) : null;
|
|
19758
|
-
return {
|
|
19759
|
-
heading: `${getSessionDisplayName(session, session.working_directory)}${session.id === currentBinding?.codepilotSessionId ? " [\u5F53\u524D]" : ""}`,
|
|
19760
|
-
details: [
|
|
19761
|
-
`\u72B6\u6001\uFF1A${formatRuntimeStatus(session)}`,
|
|
19762
|
-
`\u76EE\u5F55\uFF1A${formatCommandPath(session.working_directory)}`
|
|
19763
|
-
]
|
|
19764
|
-
};
|
|
19765
|
-
}),
|
|
19766
|
-
[
|
|
19767
|
-
"\u666E\u901A\u4F7F\u7528\u5EFA\u8BAE\u76F4\u63A5\u901A\u8FC7 `/t` \u5207\u6362\u684C\u9762\u4F1A\u8BDD\u3002",
|
|
19768
|
-
"\u517C\u5BB9\u547D\u4EE4\u4ECD\u53EF\u7528\uFF0C\u4F8B\u5982 `/use 2`\u3002"
|
|
19769
|
-
],
|
|
19770
|
-
responseParseMode === "Markdown"
|
|
19771
|
-
);
|
|
19772
|
-
}
|
|
19773
|
-
break;
|
|
19774
|
-
}
|
|
19775
19713
|
case "/stop": {
|
|
19776
19714
|
const binding = resolve(msg.address);
|
|
19777
19715
|
const st = getState();
|
|
@@ -19926,10 +19864,12 @@ function defaultAliasForProvider2(provider) {
|
|
|
19926
19864
|
if (provider === "weixin") return "\u5FAE\u4FE1";
|
|
19927
19865
|
return void 0;
|
|
19928
19866
|
}
|
|
19929
|
-
function
|
|
19867
|
+
function upgradeLegacyBinding(binding) {
|
|
19930
19868
|
const config2 = loadConfig();
|
|
19931
|
-
const
|
|
19932
|
-
const
|
|
19869
|
+
const exactInstance = findChannelInstance(binding.channelType, config2);
|
|
19870
|
+
const hasInstanceMetadata = Boolean(binding.channelProvider || binding.channelAlias);
|
|
19871
|
+
const legacyProvider = !exactInstance && !hasInstanceMetadata && (binding.channelType === "feishu" || binding.channelType === "weixin") ? binding.channelType : void 0;
|
|
19872
|
+
const resolvedInstance = exactInstance || (legacyProvider ? (config2.channels || []).find((channel) => channel.provider === legacyProvider) : void 0);
|
|
19933
19873
|
if (!resolvedInstance && !legacyProvider) {
|
|
19934
19874
|
return {
|
|
19935
19875
|
...binding,
|
|
@@ -20010,7 +19950,7 @@ var JsonFileStore = class {
|
|
|
20010
19950
|
const normalized = /* @__PURE__ */ new Map();
|
|
20011
19951
|
let changed = false;
|
|
20012
19952
|
for (const binding of Object.values(bindings)) {
|
|
20013
|
-
const normalizedBinding =
|
|
19953
|
+
const normalizedBinding = upgradeLegacyBinding(binding);
|
|
20014
19954
|
if (didBindingChange(binding, normalizedBinding)) {
|
|
20015
19955
|
changed = true;
|
|
20016
19956
|
}
|