codex-to-im 1.0.42 → 1.0.44
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.mjs +37 -9
- package/dist/daemon.mjs +3091 -9102
- package/dist/ui-server.mjs +113 -63
- package/package.json +2 -4
- package/references/setup-guides.md +34 -156
- package/references/token-validation.md +28 -44
- package/references/troubleshooting.md +10 -11
- package/scripts/build.js +2 -7
- package/scripts/daemon.sh +11 -30
- package/scripts/doctor.sh +35 -280
- package/scripts/supervisor-macos.sh +9 -28
package/dist/cli.mjs
CHANGED
|
@@ -29,8 +29,14 @@ function parseReasoningEffort(value) {
|
|
|
29
29
|
}
|
|
30
30
|
return void 0;
|
|
31
31
|
}
|
|
32
|
+
function normalizeChannelId(value) {
|
|
33
|
+
return value.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || "channel";
|
|
34
|
+
}
|
|
32
35
|
|
|
33
36
|
// src/config.ts
|
|
37
|
+
function isSupportedChannelProvider(value) {
|
|
38
|
+
return value === "feishu" || value === "weixin";
|
|
39
|
+
}
|
|
34
40
|
var DEFAULT_CTI_HOME = path.join(os.homedir(), ".codex-to-im");
|
|
35
41
|
var DEFAULT_WORKSPACE_ROOT = path.join(os.homedir(), "cx2im");
|
|
36
42
|
var CTI_HOME = process.env.CTI_HOME || DEFAULT_CTI_HOME;
|
|
@@ -97,6 +103,8 @@ function readConfigV2File() {
|
|
|
97
103
|
try {
|
|
98
104
|
const parsed = JSON.parse(fs.readFileSync(CONFIG_V2_PATH, "utf-8"));
|
|
99
105
|
if (parsed && parsed.schemaVersion === 2 && parsed.runtime && Array.isArray(parsed.channels)) {
|
|
106
|
+
parsed.runtime.provider = normalizeRuntimeProvider(parsed.runtime.provider);
|
|
107
|
+
parsed.channels = normalizeChannelInstances(parsed.channels);
|
|
100
108
|
return parsed;
|
|
101
109
|
}
|
|
102
110
|
return null;
|
|
@@ -116,9 +124,32 @@ function defaultAliasForProvider(provider) {
|
|
|
116
124
|
function buildDefaultChannelId(provider) {
|
|
117
125
|
return `${provider}-default`;
|
|
118
126
|
}
|
|
127
|
+
function normalizeRuntimeProvider(_value) {
|
|
128
|
+
return "codex";
|
|
129
|
+
}
|
|
130
|
+
function normalizeChannelInstances(value) {
|
|
131
|
+
if (!Array.isArray(value)) return [];
|
|
132
|
+
return value.flatMap((entry) => {
|
|
133
|
+
if (!entry || typeof entry !== "object") return [];
|
|
134
|
+
const record = entry;
|
|
135
|
+
if (!isSupportedChannelProvider(record.provider)) return [];
|
|
136
|
+
const provider = record.provider;
|
|
137
|
+
const config = record.config && typeof record.config === "object" ? record.config : {};
|
|
138
|
+
const timestamp = nowIso();
|
|
139
|
+
return [{
|
|
140
|
+
id: normalizeChannelId(
|
|
141
|
+
typeof record.id === "string" && record.id.trim() ? record.id : buildDefaultChannelId(provider)
|
|
142
|
+
),
|
|
143
|
+
alias: typeof record.alias === "string" && record.alias.trim() ? record.alias.trim() : defaultAliasForProvider(provider),
|
|
144
|
+
provider,
|
|
145
|
+
enabled: record.enabled === true,
|
|
146
|
+
createdAt: typeof record.createdAt === "string" ? record.createdAt : timestamp,
|
|
147
|
+
updatedAt: typeof record.updatedAt === "string" ? record.updatedAt : timestamp,
|
|
148
|
+
config
|
|
149
|
+
}];
|
|
150
|
+
});
|
|
151
|
+
}
|
|
119
152
|
function migrateLegacyEnvToV2(env) {
|
|
120
|
-
const rawRuntime = env.get("CTI_RUNTIME") || "codex";
|
|
121
|
-
const runtime = ["claude", "codex", "auto"].includes(rawRuntime) ? rawRuntime : "codex";
|
|
122
153
|
const enabledChannels = splitCsv(env.get("CTI_ENABLED_CHANNELS")) ?? ["feishu"];
|
|
123
154
|
const timestamp = nowIso();
|
|
124
155
|
const channels = [];
|
|
@@ -165,7 +196,7 @@ function migrateLegacyEnvToV2(env) {
|
|
|
165
196
|
return {
|
|
166
197
|
schemaVersion: 2,
|
|
167
198
|
runtime: {
|
|
168
|
-
provider:
|
|
199
|
+
provider: "codex",
|
|
169
200
|
defaultWorkspaceRoot: expandHomePath(env.get("CTI_DEFAULT_WORKSPACE_ROOT")) || void 0,
|
|
170
201
|
defaultModel: env.get("CTI_DEFAULT_MODEL") || void 0,
|
|
171
202
|
defaultMode: env.get("CTI_DEFAULT_MODE") || "code",
|
|
@@ -176,8 +207,7 @@ function migrateLegacyEnvToV2(env) {
|
|
|
176
207
|
codexSandboxMode: parseSandboxMode(env.get("CTI_CODEX_SANDBOX_MODE")) ?? "workspace-write",
|
|
177
208
|
codexReasoningEffort: parseReasoningEffort(env.get("CTI_CODEX_REASONING_EFFORT")) ?? "medium",
|
|
178
209
|
uiAllowLan: env.get("CTI_UI_ALLOW_LAN") === "true",
|
|
179
|
-
uiAccessToken: env.get("CTI_UI_ACCESS_TOKEN") || void 0
|
|
180
|
-
autoApprove: env.get("CTI_AUTO_APPROVE") === "true"
|
|
210
|
+
uiAccessToken: env.get("CTI_UI_ACCESS_TOKEN") || void 0
|
|
181
211
|
},
|
|
182
212
|
channels
|
|
183
213
|
};
|
|
@@ -200,8 +230,7 @@ function expandConfig(v2) {
|
|
|
200
230
|
codexSandboxMode: v2.runtime.codexSandboxMode ?? "workspace-write",
|
|
201
231
|
codexReasoningEffort: v2.runtime.codexReasoningEffort ?? "medium",
|
|
202
232
|
uiAllowLan: v2.runtime.uiAllowLan === true,
|
|
203
|
-
uiAccessToken: v2.runtime.uiAccessToken || void 0
|
|
204
|
-
autoApprove: v2.runtime.autoApprove === true
|
|
233
|
+
uiAccessToken: v2.runtime.uiAccessToken || void 0
|
|
205
234
|
};
|
|
206
235
|
}
|
|
207
236
|
function loadConfig() {
|
|
@@ -225,8 +254,7 @@ function loadConfig() {
|
|
|
225
254
|
codexSkipGitRepoCheck: true,
|
|
226
255
|
codexSandboxMode: "workspace-write",
|
|
227
256
|
codexReasoningEffort: "medium",
|
|
228
|
-
uiAllowLan: false
|
|
229
|
-
autoApprove: false
|
|
257
|
+
uiAllowLan: false
|
|
230
258
|
},
|
|
231
259
|
channels: []
|
|
232
260
|
};
|