@modelzen/feishu-codex-bridge 0.1.1 → 0.1.2
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 +27 -16
- package/package.json +3 -2
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// src/cli/index.ts
|
|
2
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
3
|
+
import { dirname as dirname8, resolve as resolve3 } from "path";
|
|
4
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
2
5
|
import { Command } from "commander";
|
|
3
6
|
|
|
4
7
|
// src/cli/commands/doctor.ts
|
|
@@ -525,7 +528,7 @@ async function spawnExecProvider(pc, ref) {
|
|
|
525
528
|
const timeoutMs = pc.noOutputTimeoutMs ?? DEFAULT_EXEC_TIMEOUT_MS;
|
|
526
529
|
const maxOutput = pc.maxOutputBytes ?? DEFAULT_EXEC_MAX_OUTPUT;
|
|
527
530
|
const providerName = ref.provider ?? DEFAULT_PROVIDER;
|
|
528
|
-
return new Promise((
|
|
531
|
+
return new Promise((resolve4, reject) => {
|
|
529
532
|
const env = {};
|
|
530
533
|
if (pc.passEnv) for (const k of pc.passEnv) {
|
|
531
534
|
const v = process.env[k];
|
|
@@ -570,7 +573,7 @@ async function spawnExecProvider(pc, ref) {
|
|
|
570
573
|
try {
|
|
571
574
|
const parsed = JSON.parse(stdout);
|
|
572
575
|
const value = parsed.values?.[ref.id];
|
|
573
|
-
if (typeof value === "string") return
|
|
576
|
+
if (typeof value === "string") return resolve4(value);
|
|
574
577
|
const err = parsed.errors?.[ref.id]?.message;
|
|
575
578
|
reject(new Error(`exec provider did not return secret for ${ref.id}${err ? `: ${err}` : ""}`));
|
|
576
579
|
} catch (err) {
|
|
@@ -1097,7 +1100,7 @@ var AsyncQueue = class {
|
|
|
1097
1100
|
continue;
|
|
1098
1101
|
}
|
|
1099
1102
|
if (this.closed) return;
|
|
1100
|
-
const next = await new Promise((
|
|
1103
|
+
const next = await new Promise((resolve4) => this.waiters.push(resolve4));
|
|
1101
1104
|
if (next.done) return;
|
|
1102
1105
|
yield next.value;
|
|
1103
1106
|
}
|
|
@@ -1148,8 +1151,8 @@ var AppServerClient = class {
|
|
|
1148
1151
|
const id = ++this.nextId;
|
|
1149
1152
|
const payload = `${JSON.stringify({ jsonrpc: "2.0", id, method, params: params ?? {} })}
|
|
1150
1153
|
`;
|
|
1151
|
-
return new Promise((
|
|
1152
|
-
this.pending.set(id, { resolve:
|
|
1154
|
+
return new Promise((resolve4, reject) => {
|
|
1155
|
+
this.pending.set(id, { resolve: resolve4, reject });
|
|
1153
1156
|
this.child.stdin.write(payload, (err) => {
|
|
1154
1157
|
if (err) {
|
|
1155
1158
|
this.pending.delete(id);
|
|
@@ -1173,14 +1176,14 @@ var AppServerClient = class {
|
|
|
1173
1176
|
const child = this.child;
|
|
1174
1177
|
if (!child || child.exitCode !== null) return;
|
|
1175
1178
|
child.kill("SIGTERM");
|
|
1176
|
-
await new Promise((
|
|
1179
|
+
await new Promise((resolve4) => {
|
|
1177
1180
|
const t = setTimeout(() => {
|
|
1178
1181
|
if (child.exitCode === null) child.kill("SIGKILL");
|
|
1179
|
-
|
|
1182
|
+
resolve4();
|
|
1180
1183
|
}, graceMs);
|
|
1181
1184
|
child.once("exit", () => {
|
|
1182
1185
|
clearTimeout(t);
|
|
1183
|
-
|
|
1186
|
+
resolve4();
|
|
1184
1187
|
});
|
|
1185
1188
|
});
|
|
1186
1189
|
}
|
|
@@ -1299,12 +1302,12 @@ var APPROVAL_POLICY = "never";
|
|
|
1299
1302
|
var SANDBOX = "danger-full-access";
|
|
1300
1303
|
var READ_HISTORY_TIMEOUT_MS = 2e4;
|
|
1301
1304
|
function withDeadline(p, ms, label) {
|
|
1302
|
-
return new Promise((
|
|
1305
|
+
return new Promise((resolve4, reject) => {
|
|
1303
1306
|
const t = setTimeout(() => reject(new Error(`${label} timed out after ${ms}ms`)), ms);
|
|
1304
1307
|
p.then(
|
|
1305
1308
|
(v) => {
|
|
1306
1309
|
clearTimeout(t);
|
|
1307
|
-
|
|
1310
|
+
resolve4(v);
|
|
1308
1311
|
},
|
|
1309
1312
|
(e) => {
|
|
1310
1313
|
clearTimeout(t);
|
|
@@ -1344,11 +1347,11 @@ var CodexThread = class {
|
|
|
1344
1347
|
if (self.model) params.model = self.model;
|
|
1345
1348
|
if (self.effort) params.effort = self.effort;
|
|
1346
1349
|
let startError;
|
|
1347
|
-
const startFailed = new Promise((
|
|
1350
|
+
const startFailed = new Promise((resolve4) => {
|
|
1348
1351
|
self.client.request("turn/start", params).then(void 0, (err) => {
|
|
1349
1352
|
startError = err instanceof Error ? err : new Error(String(err));
|
|
1350
1353
|
log.fail("agent", startError, { phase: "turn/start" });
|
|
1351
|
-
|
|
1354
|
+
resolve4("start-failed");
|
|
1352
1355
|
});
|
|
1353
1356
|
});
|
|
1354
1357
|
const stream2 = self.client.stream()[Symbol.asyncIterator]();
|
|
@@ -4615,21 +4618,29 @@ async function secretsRemove(id) {
|
|
|
4615
4618
|
console.log(ok ? `\u2713 \u5DF2\u5220\u9664: ${id}` : `\u672A\u627E\u5230: ${id}`);
|
|
4616
4619
|
}
|
|
4617
4620
|
function readStdin() {
|
|
4618
|
-
return new Promise((
|
|
4621
|
+
return new Promise((resolve4) => {
|
|
4619
4622
|
let data = "";
|
|
4620
4623
|
if (process.stdin.isTTY) {
|
|
4621
|
-
|
|
4624
|
+
resolve4("");
|
|
4622
4625
|
return;
|
|
4623
4626
|
}
|
|
4624
4627
|
process.stdin.setEncoding("utf8");
|
|
4625
4628
|
process.stdin.on("data", (c) => data += c);
|
|
4626
|
-
process.stdin.on("end", () =>
|
|
4629
|
+
process.stdin.on("end", () => resolve4(data));
|
|
4627
4630
|
});
|
|
4628
4631
|
}
|
|
4629
4632
|
|
|
4630
4633
|
// src/cli/index.ts
|
|
4631
4634
|
var program = new Command();
|
|
4632
|
-
|
|
4635
|
+
function readVersion() {
|
|
4636
|
+
try {
|
|
4637
|
+
const pkgPath = resolve3(dirname8(fileURLToPath2(import.meta.url)), "..", "package.json");
|
|
4638
|
+
return JSON.parse(readFileSync2(pkgPath, "utf8")).version ?? "0.0.0";
|
|
4639
|
+
} catch {
|
|
4640
|
+
return "0.0.0";
|
|
4641
|
+
}
|
|
4642
|
+
}
|
|
4643
|
+
program.name("feishu-codex-bridge").description("\u628A\u98DE\u4E66/Lark \u6865\u63A5\u5230\u672C\u673A Codex\uFF08\u9879\u76EE=\u7FA4, \u8BDD\u9898=\u4F1A\u8BDD\uFF09").version(readVersion());
|
|
4633
4644
|
program.command("run").description("\u524D\u53F0\u542F\u52A8 bot\uFF08\u6CA1\u914D\u7F6E\u5219\u5148\u626B\u7801 init\uFF1BCtrl+C \u4F18\u96C5\u9000\u51FA\uFF09").action(async () => {
|
|
4634
4645
|
await runRun();
|
|
4635
4646
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modelzen/feishu-codex-bridge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Bridge Feishu/Lark messenger with local Codex via app-server (project=group, thread=session)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"typecheck": "tsc --noEmit",
|
|
25
25
|
"test": "vitest run",
|
|
26
26
|
"start": "node bin/feishu-codex-bridge.mjs run",
|
|
27
|
-
"prepare": "npm run build"
|
|
27
|
+
"prepare": "npm run build",
|
|
28
|
+
"release": "bash scripts/release.sh"
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
30
31
|
"@larksuiteoapi/node-sdk": "^1.65.0",
|