engine7 7.1.148 → 7.1.149
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/bg-worker.mjs +141 -36
- package/dist/cli.mjs +2175 -1348
- package/dist/engine-startup.mjs +1362 -992
- package/dist/main.mjs +1374 -996
- package/dist/recall-worker.mjs +135 -29
- package/dist/topics-worker.mjs +123 -28
- package/dist/travel-gateway.mjs +265 -100
- package/dist/travel-host.mjs +63 -47
- package/dist/travel-node.mjs +2 -3
- package/dist/travel-oss-bundle-stream.mjs +1 -1
- package/dist/travel-pairing.mjs +271 -106
- package/dist/travel-sync-worker.mjs +223 -114
- package/dist/web-console.mjs +298 -50
- package/package.json +1 -1
package/dist/travel-gateway.mjs
CHANGED
|
@@ -6077,16 +6077,15 @@ function stripInjectedContext(text2) {
|
|
|
6077
6077
|
function escapeRegExp(s) {
|
|
6078
6078
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6079
6079
|
}
|
|
6080
|
-
var
|
|
6080
|
+
var SYSTEM_REMINDER_BLOCK, INJECT_SECTION_HEADS, KNOWN_INJECTED_TEXT, INJECTED_LINE_PREFIXES, XML_BLOCK;
|
|
6081
6081
|
var init_strip_injected = __esm({
|
|
6082
6082
|
"src/messages/strip-injected.ts"() {
|
|
6083
6083
|
"use strict";
|
|
6084
|
-
SKILL_GATE_HINT_PREFIX = "\u8FD9\u6761\u6D88\u606F\u662F\u5F00\u53D1\u4EFB\u52A1";
|
|
6085
6084
|
SYSTEM_REMINDER_BLOCK = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
|
|
6086
6085
|
INJECT_SECTION_HEADS = /^(本轮对话|当前情绪状态|当前模式)/;
|
|
6087
6086
|
KNOWN_INJECTED_TEXT = [
|
|
6088
|
-
|
|
6089
|
-
// skill-gate
|
|
6087
|
+
"\u8FD9\u6761\u6D88\u606F\u662F\u5F00\u53D1\u4EFB\u52A1",
|
|
6088
|
+
// 旧版 skill-gate 提示前缀,兼容未打标签的历史
|
|
6090
6089
|
"\u5F00\u53D1\u4EFB\u52A1\u8DEF\u6807\uFF0C\u6309\u573A\u666F\u5BF9\u53F7\u5165\u5EA7",
|
|
6091
6090
|
// skill-gate hint(0912 老文案,历史 JSONL 兼容)
|
|
6092
6091
|
"\u3010\u5B9A\u65F6\u5FC3\u8DF3\u3011\u8BF7 read HEARTBEAT.md"
|
|
@@ -10711,32 +10710,32 @@ CREATE TABLE IF NOT EXISTS cluster_members (
|
|
|
10711
10710
|
return { built: !hasStats, ms: Date.now() - started };
|
|
10712
10711
|
}
|
|
10713
10712
|
async close() {
|
|
10714
|
-
const
|
|
10713
|
+
const errors3 = [];
|
|
10715
10714
|
try {
|
|
10716
10715
|
this.capture?.close();
|
|
10717
10716
|
} catch (error) {
|
|
10718
|
-
|
|
10717
|
+
errors3.push(error);
|
|
10719
10718
|
}
|
|
10720
10719
|
try {
|
|
10721
10720
|
this.db.close();
|
|
10722
10721
|
} catch (error) {
|
|
10723
|
-
|
|
10722
|
+
errors3.push(error);
|
|
10724
10723
|
}
|
|
10725
10724
|
try {
|
|
10726
10725
|
await this.vectors?.close();
|
|
10727
10726
|
} catch (error) {
|
|
10728
|
-
|
|
10727
|
+
errors3.push(error);
|
|
10729
10728
|
} finally {
|
|
10730
10729
|
this.vectors = null;
|
|
10731
10730
|
}
|
|
10732
10731
|
try {
|
|
10733
10732
|
this.releaseRuntimeWriter?.();
|
|
10734
10733
|
} catch (error) {
|
|
10735
|
-
|
|
10734
|
+
errors3.push(error);
|
|
10736
10735
|
} finally {
|
|
10737
10736
|
this.releaseRuntimeWriter = void 0;
|
|
10738
10737
|
}
|
|
10739
|
-
if (
|
|
10738
|
+
if (errors3.length) throw new AggregateError(errors3, "MEM7_CLOSE_FAILED");
|
|
10740
10739
|
}
|
|
10741
10740
|
// ── memcell 账本 ──────────────────────────────────────────
|
|
10742
10741
|
insertMemcell(cell) {
|
|
@@ -14641,6 +14640,159 @@ var init_router = __esm({
|
|
|
14641
14640
|
}
|
|
14642
14641
|
});
|
|
14643
14642
|
|
|
14643
|
+
// src/services/adaptive-proxy.ts
|
|
14644
|
+
var adaptive_proxy_exports = {};
|
|
14645
|
+
__export(adaptive_proxy_exports, {
|
|
14646
|
+
createProxySocketAgent: () => createProxySocketAgent,
|
|
14647
|
+
getProxyDispatcher: () => getProxyDispatcher,
|
|
14648
|
+
isAdaptiveProxy: () => isAdaptiveProxy
|
|
14649
|
+
});
|
|
14650
|
+
import net from "node:net";
|
|
14651
|
+
import tls from "node:tls";
|
|
14652
|
+
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
14653
|
+
import { Agent as Agent2, Client, ProxyAgent, errors as errors2 } from "undici";
|
|
14654
|
+
function proxyAddress(value) {
|
|
14655
|
+
const bareLoopback = /^(?:localhost\.?|127(?:\.\d{1,3}){3}|\[::1\]):\d+$/i;
|
|
14656
|
+
return new URL(bareLoopback.test(value) ? `http://${value}` : value);
|
|
14657
|
+
}
|
|
14658
|
+
function localProxyKey(url) {
|
|
14659
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return;
|
|
14660
|
+
const host = url.hostname.replace(/\.$/, "");
|
|
14661
|
+
if (host !== "localhost" && host !== "[::1]" && !/^127\./.test(host)) return;
|
|
14662
|
+
return `${host}:${url.port || (url.protocol === "https:" ? 443 : 80)}`;
|
|
14663
|
+
}
|
|
14664
|
+
function isAdaptiveProxy(proxy) {
|
|
14665
|
+
return localProxyKey(proxyAddress(proxy.trim())) !== void 0;
|
|
14666
|
+
}
|
|
14667
|
+
function proxyUnavailable(key4) {
|
|
14668
|
+
return (unreachableUntil.get(key4) ?? -Infinity) > Date.now();
|
|
14669
|
+
}
|
|
14670
|
+
function markUnavailable(key4) {
|
|
14671
|
+
unreachableUntil.set(key4, Date.now() + RETRY_PROXY_AFTER_MS);
|
|
14672
|
+
}
|
|
14673
|
+
function isTcpDialFailure(error) {
|
|
14674
|
+
if (error instanceof AggregateError) {
|
|
14675
|
+
return error.errors.length > 0 && error.errors.every(isTcpDialFailure);
|
|
14676
|
+
}
|
|
14677
|
+
const err = error;
|
|
14678
|
+
return err?.syscall === "connect" && dialFailureCodes.has(err.code ?? "");
|
|
14679
|
+
}
|
|
14680
|
+
function getProxyDispatcher(value) {
|
|
14681
|
+
const raw = value?.trim();
|
|
14682
|
+
if (!raw) return;
|
|
14683
|
+
const cached2 = dispatchers.get(raw);
|
|
14684
|
+
if (cached2) return cached2;
|
|
14685
|
+
const url = proxyAddress(raw);
|
|
14686
|
+
const key4 = localProxyKey(url);
|
|
14687
|
+
const dispatcher = key4 ? new AdaptiveProxyDispatcher(url.href, key4) : new ProxyAgent({ uri: url.href });
|
|
14688
|
+
dispatchers.set(raw, dispatcher);
|
|
14689
|
+
return dispatcher;
|
|
14690
|
+
}
|
|
14691
|
+
function createProxySocketAgent(value) {
|
|
14692
|
+
const url = proxyAddress(value.trim());
|
|
14693
|
+
const key4 = localProxyKey(url);
|
|
14694
|
+
return key4 ? new AdaptiveProxySocketAgent(url, key4) : new HttpsProxyAgent(url);
|
|
14695
|
+
}
|
|
14696
|
+
var RETRY_PROXY_AFTER_MS, LOCAL_CONNECT_TIMEOUT_MS, unreachableUntil, failedProxyDials, dispatchers, direct, dialFailureCodes, AdaptiveProxyDispatcher, AdaptiveProxySocketAgent;
|
|
14697
|
+
var init_adaptive_proxy = __esm({
|
|
14698
|
+
"src/services/adaptive-proxy.ts"() {
|
|
14699
|
+
"use strict";
|
|
14700
|
+
RETRY_PROXY_AFTER_MS = 5e3;
|
|
14701
|
+
LOCAL_CONNECT_TIMEOUT_MS = 1e3;
|
|
14702
|
+
unreachableUntil = /* @__PURE__ */ new Map();
|
|
14703
|
+
failedProxyDials = /* @__PURE__ */ new WeakSet();
|
|
14704
|
+
dispatchers = /* @__PURE__ */ new Map();
|
|
14705
|
+
direct = new Agent2();
|
|
14706
|
+
dialFailureCodes = /* @__PURE__ */ new Set(["ECONNREFUSED", "ETIMEDOUT", "ENETUNREACH", "EHOSTUNREACH", "EADDRNOTAVAIL"]);
|
|
14707
|
+
AdaptiveProxyDispatcher = class extends ProxyAgent {
|
|
14708
|
+
constructor(uri, key4) {
|
|
14709
|
+
super({
|
|
14710
|
+
uri,
|
|
14711
|
+
proxyTls: { timeout: LOCAL_CONNECT_TIMEOUT_MS },
|
|
14712
|
+
clientFactory(origin, opts) {
|
|
14713
|
+
const { connect } = opts;
|
|
14714
|
+
return new Client(origin, {
|
|
14715
|
+
connect(options, callback) {
|
|
14716
|
+
let tcpConnected = false;
|
|
14717
|
+
const socket = connect(options, (...result) => {
|
|
14718
|
+
const [error] = result;
|
|
14719
|
+
if (error && !tcpConnected && (isTcpDialFailure(error) || error.code === "UND_ERR_CONNECT_TIMEOUT")) {
|
|
14720
|
+
markUnavailable(key4);
|
|
14721
|
+
failedProxyDials.add(error);
|
|
14722
|
+
}
|
|
14723
|
+
callback(...result);
|
|
14724
|
+
});
|
|
14725
|
+
socket.once("connect", () => {
|
|
14726
|
+
tcpConnected = true;
|
|
14727
|
+
});
|
|
14728
|
+
return socket;
|
|
14729
|
+
}
|
|
14730
|
+
});
|
|
14731
|
+
}
|
|
14732
|
+
});
|
|
14733
|
+
this.key = key4;
|
|
14734
|
+
}
|
|
14735
|
+
dispatch(options, handler) {
|
|
14736
|
+
if (!this.closed && !this.destroyed && proxyUnavailable(this.key)) {
|
|
14737
|
+
const headers = options.headers;
|
|
14738
|
+
const keys = !headers ? [] : Array.isArray(headers) ? headers.filter((_, index) => index % 2 === 0) : Symbol.iterator in headers ? Array.from(headers, ([name]) => name) : Object.keys(headers);
|
|
14739
|
+
if (keys.some((name) => name.toLowerCase() === "proxy-authorization")) {
|
|
14740
|
+
throw new errors2.InvalidArgumentError("Proxy-Authorization should be sent in ProxyAgent constructor");
|
|
14741
|
+
}
|
|
14742
|
+
return direct.dispatch(options, handler);
|
|
14743
|
+
}
|
|
14744
|
+
let connected = false;
|
|
14745
|
+
const extended = handler;
|
|
14746
|
+
const guarded = {
|
|
14747
|
+
onConnect: (abort) => {
|
|
14748
|
+
connected = true;
|
|
14749
|
+
handler.onConnect?.(abort);
|
|
14750
|
+
},
|
|
14751
|
+
onError: (error) => {
|
|
14752
|
+
if (!connected && failedProxyDials.has(error)) {
|
|
14753
|
+
direct.dispatch(options, handler);
|
|
14754
|
+
} else {
|
|
14755
|
+
handler.onError?.(error);
|
|
14756
|
+
}
|
|
14757
|
+
},
|
|
14758
|
+
onHeaders: handler.onHeaders?.bind(handler),
|
|
14759
|
+
onData: handler.onData?.bind(handler),
|
|
14760
|
+
onComplete: handler.onComplete?.bind(handler),
|
|
14761
|
+
onUpgrade: handler.onUpgrade?.bind(handler),
|
|
14762
|
+
onResponseStarted: handler.onResponseStarted?.bind(handler),
|
|
14763
|
+
onBodySent: handler.onBodySent?.bind(handler),
|
|
14764
|
+
onRequestSent: extended.onRequestSent?.bind(handler)
|
|
14765
|
+
};
|
|
14766
|
+
return super.dispatch(options, guarded);
|
|
14767
|
+
}
|
|
14768
|
+
};
|
|
14769
|
+
AdaptiveProxySocketAgent = class extends HttpsProxyAgent {
|
|
14770
|
+
constructor(url, key4) {
|
|
14771
|
+
super(url);
|
|
14772
|
+
this.key = key4;
|
|
14773
|
+
}
|
|
14774
|
+
async connect(req, opts) {
|
|
14775
|
+
if (!proxyUnavailable(this.key)) {
|
|
14776
|
+
try {
|
|
14777
|
+
return await super.connect(req, opts);
|
|
14778
|
+
} catch (error) {
|
|
14779
|
+
if (!isTcpDialFailure(error)) throw error;
|
|
14780
|
+
markUnavailable(this.key);
|
|
14781
|
+
if (req.destroyed) throw error;
|
|
14782
|
+
}
|
|
14783
|
+
}
|
|
14784
|
+
if (!opts.secureEndpoint) return net.connect({ ...opts, path: void 0 });
|
|
14785
|
+
const { host, servername } = opts;
|
|
14786
|
+
return tls.connect({
|
|
14787
|
+
...opts,
|
|
14788
|
+
path: void 0,
|
|
14789
|
+
servername: servername ?? (host && !net.isIP(host) ? host : void 0)
|
|
14790
|
+
});
|
|
14791
|
+
}
|
|
14792
|
+
};
|
|
14793
|
+
}
|
|
14794
|
+
});
|
|
14795
|
+
|
|
14644
14796
|
// src/calendar/dispatches.ts
|
|
14645
14797
|
var dispatches_exports = {};
|
|
14646
14798
|
__export(dispatches_exports, {
|
|
@@ -14701,10 +14853,10 @@ function installSQLiteWriteCapture(db2, source) {
|
|
|
14701
14853
|
if (db2.isTransaction) throw new Error("REPLICATION_TRANSACTION_ALREADY_OPEN");
|
|
14702
14854
|
const exec = db2.exec, prepare = db2.prepare;
|
|
14703
14855
|
let active, failed = false, closed = false, reading = false;
|
|
14704
|
-
let
|
|
14856
|
+
let direct2;
|
|
14705
14857
|
const check = () => {
|
|
14706
14858
|
if (closed) throw new Error("REPLICATION_TRANSACTION_CLOSED");
|
|
14707
|
-
|
|
14859
|
+
direct2?.assertOpen();
|
|
14708
14860
|
};
|
|
14709
14861
|
const wrappedExec = function(sql) {
|
|
14710
14862
|
check();
|
|
@@ -14775,10 +14927,10 @@ function installSQLiteWriteCapture(db2, source) {
|
|
|
14775
14927
|
db2.prepare = checkedPrepare;
|
|
14776
14928
|
const transaction = (operation) => {
|
|
14777
14929
|
check();
|
|
14778
|
-
if (db2.isTransaction) return
|
|
14930
|
+
if (db2.isTransaction) return direct2.scope(operation);
|
|
14779
14931
|
db2.exec("BEGIN IMMEDIATE");
|
|
14780
14932
|
try {
|
|
14781
|
-
const result =
|
|
14933
|
+
const result = direct2.scope(operation);
|
|
14782
14934
|
if (result && typeof result.then === "function") throw new Error("REPLICATION_ASYNC_TRANSACTION");
|
|
14783
14935
|
db2.exec("COMMIT");
|
|
14784
14936
|
return result;
|
|
@@ -14787,10 +14939,10 @@ function installSQLiteWriteCapture(db2, source) {
|
|
|
14787
14939
|
throw error;
|
|
14788
14940
|
}
|
|
14789
14941
|
};
|
|
14790
|
-
|
|
14942
|
+
direct2 = installAutocommitCapture(db2, transaction);
|
|
14791
14943
|
return {
|
|
14792
14944
|
assertOpen: check,
|
|
14793
|
-
scope: (operation) =>
|
|
14945
|
+
scope: (operation) => direct2.scope(operation),
|
|
14794
14946
|
transaction,
|
|
14795
14947
|
close() {
|
|
14796
14948
|
if (closed) return;
|
|
@@ -14799,7 +14951,7 @@ function installSQLiteWriteCapture(db2, source) {
|
|
|
14799
14951
|
source.endCapture(active);
|
|
14800
14952
|
active = void 0;
|
|
14801
14953
|
}
|
|
14802
|
-
|
|
14954
|
+
direct2.close();
|
|
14803
14955
|
db2.prepare = prepare;
|
|
14804
14956
|
db2.exec = exec;
|
|
14805
14957
|
closed = true;
|
|
@@ -17329,7 +17481,7 @@ __export(voice_chat_tts_daemon_exports, {
|
|
|
17329
17481
|
stopTtsDaemon: () => stopTtsDaemon
|
|
17330
17482
|
});
|
|
17331
17483
|
import { spawn } from "child_process";
|
|
17332
|
-
import
|
|
17484
|
+
import net2 from "net";
|
|
17333
17485
|
import path13 from "path";
|
|
17334
17486
|
import fs10 from "fs";
|
|
17335
17487
|
function _log(msg2) {
|
|
@@ -17337,7 +17489,7 @@ function _log(msg2) {
|
|
|
17337
17489
|
}
|
|
17338
17490
|
function _healthOnce() {
|
|
17339
17491
|
return new Promise((resolve12) => {
|
|
17340
|
-
const sock =
|
|
17492
|
+
const sock = net2.connect(SOCK_PATH);
|
|
17341
17493
|
sock.setTimeout(2e3);
|
|
17342
17494
|
sock.on("connect", () => {
|
|
17343
17495
|
sock.write(JSON.stringify({ action: "health" }) + "\n");
|
|
@@ -17390,9 +17542,6 @@ async function startTtsDaemon(warmupCfg) {
|
|
|
17390
17542
|
_log(`spawning ${script}`);
|
|
17391
17543
|
const env = {
|
|
17392
17544
|
...process.env,
|
|
17393
|
-
// 显式注入代理(dashscope SDK 不自动读系统代理)
|
|
17394
|
-
HTTP_PROXY: process.env.HTTP_PROXY || "http://127.0.0.1:7892",
|
|
17395
|
-
HTTPS_PROXY: process.env.HTTPS_PROXY || "http://127.0.0.1:7892",
|
|
17396
17545
|
TTS_DAEMON_SOCK: SOCK_PATH,
|
|
17397
17546
|
...warmupCfg?.apiKey ? { ALIYUN_API_KEY: warmupCfg.apiKey } : {},
|
|
17398
17547
|
...warmupCfg?.model ? { TTS_MODEL: warmupCfg.model } : {},
|
|
@@ -17462,7 +17611,6 @@ __export(withRetry_exports, {
|
|
|
17462
17611
|
getRetryDelay: () => getRetryDelay,
|
|
17463
17612
|
readWithTimeout: () => readWithTimeout
|
|
17464
17613
|
});
|
|
17465
|
-
import { ProxyAgent } from "undici";
|
|
17466
17614
|
function sleep2(ms, signal) {
|
|
17467
17615
|
return new Promise((resolve12, reject) => {
|
|
17468
17616
|
if (signal?.aborted) {
|
|
@@ -17530,15 +17678,6 @@ function shouldRetry(status, errorBody) {
|
|
|
17530
17678
|
if (errorBody?.includes('"type":"overloaded_error"')) return true;
|
|
17531
17679
|
return false;
|
|
17532
17680
|
}
|
|
17533
|
-
function getProxyDispatcher(proxyUrl) {
|
|
17534
|
-
if (!proxyUrl) return void 0;
|
|
17535
|
-
let agent = proxyAgentCache.get(proxyUrl);
|
|
17536
|
-
if (!agent) {
|
|
17537
|
-
agent = new ProxyAgent({ uri: proxyUrl });
|
|
17538
|
-
proxyAgentCache.set(proxyUrl, agent);
|
|
17539
|
-
}
|
|
17540
|
-
return agent;
|
|
17541
|
-
}
|
|
17542
17681
|
async function* fetchWithRetry(url, init, providerLabel, proxy, beforeRequest, retryPolicy) {
|
|
17543
17682
|
const configuredRetries = getMaxRetries();
|
|
17544
17683
|
const maxRetries = retryPolicy?.maxRetries === void 0 ? configuredRetries : Math.min(configuredRetries, Math.max(0, Math.floor(retryPolicy.maxRetries)));
|
|
@@ -17676,10 +17815,11 @@ function readWithTimeout(reader, timeoutMs, signal) {
|
|
|
17676
17815
|
if (onAbort) signal?.removeEventListener("abort", onAbort);
|
|
17677
17816
|
});
|
|
17678
17817
|
}
|
|
17679
|
-
var DEFAULT_MAX_RETRIES, BASE_DELAY_MS, MAX_DELAY_MS, DEFAULT_TIMEOUT_MS, READ_TIMEOUT_MS, FIRST_READ_TIMEOUT_MS, NO_PROGRESS_TIMEOUT_MS
|
|
17818
|
+
var DEFAULT_MAX_RETRIES, BASE_DELAY_MS, MAX_DELAY_MS, DEFAULT_TIMEOUT_MS, READ_TIMEOUT_MS, FIRST_READ_TIMEOUT_MS, NO_PROGRESS_TIMEOUT_MS;
|
|
17680
17819
|
var init_withRetry = __esm({
|
|
17681
17820
|
"src/services/withRetry.ts"() {
|
|
17682
17821
|
"use strict";
|
|
17822
|
+
init_adaptive_proxy();
|
|
17683
17823
|
DEFAULT_MAX_RETRIES = 10;
|
|
17684
17824
|
BASE_DELAY_MS = 500;
|
|
17685
17825
|
MAX_DELAY_MS = 32e3;
|
|
@@ -17687,7 +17827,6 @@ var init_withRetry = __esm({
|
|
|
17687
17827
|
READ_TIMEOUT_MS = 6e4;
|
|
17688
17828
|
FIRST_READ_TIMEOUT_MS = parseInt(process.env.API_TIMEOUT_MS || "", 10) || 6e5;
|
|
17689
17829
|
NO_PROGRESS_TIMEOUT_MS = parseInt(process.env.STREAM_NO_PROGRESS_TIMEOUT_MS || "", 10) || 3e5;
|
|
17690
|
-
proxyAgentCache = /* @__PURE__ */ new Map();
|
|
17691
17830
|
}
|
|
17692
17831
|
});
|
|
17693
17832
|
|
|
@@ -19140,7 +19279,7 @@ function validManagement(input) {
|
|
|
19140
19279
|
return true;
|
|
19141
19280
|
}
|
|
19142
19281
|
function createTravelAuthorityServer(options) {
|
|
19143
|
-
const { authority, proxyFingerprints = [], allowedPeers = {}, managementPeers = {}, recoveryPeers = {}, retirementPeers = {}, bootstrapPeers = {}, maximumInFlight = 16, requestTimeoutMs = 8e3, ...
|
|
19282
|
+
const { authority, proxyFingerprints = [], allowedPeers = {}, managementPeers = {}, recoveryPeers = {}, retirementPeers = {}, bootstrapPeers = {}, maximumInFlight = 16, requestTimeoutMs = 8e3, ...tls3 } = options;
|
|
19144
19283
|
const proxies = /* @__PURE__ */ new Set(), peers = /* @__PURE__ */ new Map(), managers = /* @__PURE__ */ new Map();
|
|
19145
19284
|
const fingerprint = (value) => {
|
|
19146
19285
|
const normalized = value.replaceAll(":", "").toLowerCase();
|
|
@@ -19185,7 +19324,7 @@ function createTravelAuthorityServer(options) {
|
|
|
19185
19324
|
retirees.set(fp, new Set(credentials.map((credential) => authority.authenticateRetirement(credential).credentialHash)));
|
|
19186
19325
|
}
|
|
19187
19326
|
const reports = /* @__PURE__ */ new Set(), management = /* @__PURE__ */ new Set();
|
|
19188
|
-
const server = createServer({ ...
|
|
19327
|
+
const server = createServer({ ...tls3, minVersion: "TLSv1.3", requestCert: true, rejectUnauthorized: true }, async (req, res) => {
|
|
19189
19328
|
res.setHeader("Content-Type", "application/json");
|
|
19190
19329
|
res.setHeader("Cache-Control", "no-store");
|
|
19191
19330
|
const reply = (status, value) => {
|
|
@@ -20040,7 +20179,7 @@ function decodeBody(value, maximum = 16 * 1024 * 1024) {
|
|
|
20040
20179
|
return body;
|
|
20041
20180
|
}
|
|
20042
20181
|
function createTravelGatewayServer(options) {
|
|
20043
|
-
const { authority, store, allowedPeers, recoveryPeers = {}, platform, assertReady, ...
|
|
20182
|
+
const { authority, store, allowedPeers, recoveryPeers = {}, platform, assertReady, ...tls3 } = options, peers = /* @__PURE__ */ new Map(), recovery = /* @__PURE__ */ new Map();
|
|
20044
20183
|
for (const [fingerprint, credential] of Object.entries(allowedPeers)) {
|
|
20045
20184
|
const normalized = fingerprint.replaceAll(":", "").toLowerCase();
|
|
20046
20185
|
if (!/^[a-f0-9]{64}$/.test(normalized) || peers.has(normalized)) throw new Error("TRAVEL_GATEWAY_INVALID_LISTENER");
|
|
@@ -20053,7 +20192,7 @@ function createTravelGatewayServer(options) {
|
|
|
20053
20192
|
}
|
|
20054
20193
|
if (!peers.size || typeof platform.deliver !== "function") throw new Error("TRAVEL_GATEWAY_INVALID_LISTENER");
|
|
20055
20194
|
let inFlight = 0;
|
|
20056
|
-
const server = createServer2({ ...
|
|
20195
|
+
const server = createServer2({ ...tls3, minVersion: "TLSv1.3", requestCert: true, rejectUnauthorized: true }, async (req, res) => {
|
|
20057
20196
|
res.setHeader("Cache-Control", "no-store");
|
|
20058
20197
|
res.setHeader("Content-Type", "application/json");
|
|
20059
20198
|
const reply = (status, value) => {
|
|
@@ -20434,12 +20573,55 @@ var AgentRegistryImpl = class {
|
|
|
20434
20573
|
var agentRegistry = new AgentRegistryImpl();
|
|
20435
20574
|
|
|
20436
20575
|
// src/channels/discord.ts
|
|
20437
|
-
|
|
20438
|
-
import {
|
|
20439
|
-
|
|
20576
|
+
init_adaptive_proxy();
|
|
20577
|
+
import { Client as Client2, GatewayIntentBits, MessageFlags, Partials, ApplicationCommandOptionType } from "discord.js";
|
|
20578
|
+
|
|
20579
|
+
// src/channels/discord-gateway-proxy.ts
|
|
20580
|
+
init_adaptive_proxy();
|
|
20581
|
+
import { AsyncLocalStorage as AsyncLocalStorage4 } from "node:async_hooks";
|
|
20582
|
+
import https from "node:https";
|
|
20583
|
+
import { SimpleShardingStrategy } from "@discordjs/ws";
|
|
20584
|
+
var gatewayRoute = new AsyncLocalStorage4();
|
|
20585
|
+
function gatewayDestination(url) {
|
|
20586
|
+
const { hostname, port } = new URL(url);
|
|
20587
|
+
return `${hostname.replace(/^\[|\]$/g, "")}:${port || 443}`;
|
|
20588
|
+
}
|
|
20589
|
+
var installed = false;
|
|
20590
|
+
function discordGatewayProxy(proxy) {
|
|
20591
|
+
if (!installed) {
|
|
20592
|
+
installed = true;
|
|
20593
|
+
const request4 = https.request;
|
|
20594
|
+
https.request = (...args) => {
|
|
20595
|
+
const route = gatewayRoute.getStore();
|
|
20596
|
+
const [options] = args;
|
|
20597
|
+
if (route && options && typeof options === "object" && !(options instanceof URL) && options.agent === void 0 && options.headers?.Upgrade === "websocket" && route.destinations.has(`${options.hostname ?? options.host}:${options.port ?? 443}`)) {
|
|
20598
|
+
args[0] = { ...options, agent: route.agent };
|
|
20599
|
+
}
|
|
20600
|
+
return Reflect.apply(request4, https, args);
|
|
20601
|
+
};
|
|
20602
|
+
}
|
|
20603
|
+
const agent = createProxySocketAgent(proxy);
|
|
20604
|
+
return (manager) => {
|
|
20605
|
+
const strategy = new SimpleShardingStrategy(manager);
|
|
20606
|
+
const destinations = /* @__PURE__ */ new Set();
|
|
20607
|
+
const retrieveSession = manager.options.retrieveSessionInfo.bind(manager.options);
|
|
20608
|
+
manager.options.retrieveSessionInfo = async (shardId) => {
|
|
20609
|
+
const session = await retrieveSession(shardId);
|
|
20610
|
+
if (session?.resumeURL) destinations.add(gatewayDestination(session.resumeURL));
|
|
20611
|
+
return session;
|
|
20612
|
+
};
|
|
20613
|
+
const connect = strategy.connect.bind(strategy);
|
|
20614
|
+
strategy.connect = async () => {
|
|
20615
|
+
const { url } = await manager.fetchGatewayInformation();
|
|
20616
|
+
destinations.add(gatewayDestination(url));
|
|
20617
|
+
return gatewayRoute.run({ agent, destinations }, connect);
|
|
20618
|
+
};
|
|
20619
|
+
return strategy;
|
|
20620
|
+
};
|
|
20621
|
+
}
|
|
20440
20622
|
|
|
20441
20623
|
// src/memory/external-effect.ts
|
|
20442
|
-
import { AsyncLocalStorage as
|
|
20624
|
+
import { AsyncLocalStorage as AsyncLocalStorage6 } from "node:async_hooks";
|
|
20443
20625
|
import { createHash as createHash25 } from "node:crypto";
|
|
20444
20626
|
import { join as join17 } from "node:path";
|
|
20445
20627
|
|
|
@@ -20559,8 +20741,8 @@ function assertMemoryExecution(stateDir, workspace, context) {
|
|
|
20559
20741
|
// src/mem7/host-turn.ts
|
|
20560
20742
|
init_store();
|
|
20561
20743
|
init_host_turns();
|
|
20562
|
-
import { AsyncLocalStorage as
|
|
20563
|
-
var turns = new
|
|
20744
|
+
import { AsyncLocalStorage as AsyncLocalStorage5 } from "node:async_hooks";
|
|
20745
|
+
var turns = new AsyncLocalStorage5();
|
|
20564
20746
|
function hasHostTurnContext() {
|
|
20565
20747
|
return Boolean(turns.getStore());
|
|
20566
20748
|
}
|
|
@@ -20604,8 +20786,8 @@ function beginHostTurnEffect() {
|
|
|
20604
20786
|
|
|
20605
20787
|
// src/memory/external-effect.ts
|
|
20606
20788
|
init_runtime_authority();
|
|
20607
|
-
var effects = new
|
|
20608
|
-
var externalFences = new
|
|
20789
|
+
var effects = new AsyncLocalStorage6();
|
|
20790
|
+
var externalFences = new AsyncLocalStorage6();
|
|
20609
20791
|
function withExternalEffectFence(check, run) {
|
|
20610
20792
|
return externalFences.run(check, run);
|
|
20611
20793
|
}
|
|
@@ -20894,7 +21076,7 @@ var DiscordAdapter = class _DiscordAdapter {
|
|
|
20894
21076
|
// 🔴 P0: 消息去重 — Discord RESUME 重连会重放 messageCreate
|
|
20895
21077
|
recentMessageIds = /* @__PURE__ */ new Set();
|
|
20896
21078
|
constructor(clientOrConfig, config) {
|
|
20897
|
-
if (clientOrConfig instanceof
|
|
21079
|
+
if (clientOrConfig instanceof Client2) {
|
|
20898
21080
|
this.client = clientOrConfig;
|
|
20899
21081
|
this.config = config ?? {};
|
|
20900
21082
|
this.ownsClient = false;
|
|
@@ -20912,24 +21094,10 @@ var DiscordAdapter = class _DiscordAdapter {
|
|
|
20912
21094
|
partials: [Partials.Channel, Partials.Message]
|
|
20913
21095
|
};
|
|
20914
21096
|
if (this.config.proxy) {
|
|
20915
|
-
|
|
20916
|
-
clientOptions.
|
|
20917
|
-
const httpsAgent = new HttpsProxyAgent(proxyUrl);
|
|
20918
|
-
const https = __require("https");
|
|
20919
|
-
const origRequest = https.request;
|
|
20920
|
-
if (!origRequest.__discordProxyPatched) {
|
|
20921
|
-
https.request = function(opts, cb) {
|
|
20922
|
-
const host = typeof opts === "string" ? "" : opts?.hostname || opts?.host || "";
|
|
20923
|
-
if ((host.includes("discord") || host.includes("gateway")) && typeof opts === "object" && !opts.agent) {
|
|
20924
|
-
opts.agent = httpsAgent;
|
|
20925
|
-
}
|
|
20926
|
-
return origRequest.call(this, opts, cb);
|
|
20927
|
-
};
|
|
20928
|
-
https.request.__discordProxyPatched = true;
|
|
20929
|
-
console.log(`[discord] https.request patched for Discord gateway \u2192 ${proxyUrl}`);
|
|
20930
|
-
}
|
|
21097
|
+
clientOptions.rest = { agent: getProxyDispatcher(this.config.proxy) };
|
|
21098
|
+
clientOptions.ws = { buildStrategy: discordGatewayProxy(this.config.proxy) };
|
|
20931
21099
|
}
|
|
20932
|
-
this.client = new
|
|
21100
|
+
this.client = new Client2(clientOptions);
|
|
20933
21101
|
this.ownsClient = true;
|
|
20934
21102
|
}
|
|
20935
21103
|
this.progressCards = new DiscordProgressCards({
|
|
@@ -20990,7 +21158,7 @@ var DiscordAdapter = class _DiscordAdapter {
|
|
|
20990
21158
|
}
|
|
20991
21159
|
try {
|
|
20992
21160
|
const init = { signal: AbortSignal.timeout(HISTORY_ATTACH_TIMEOUT_MS) };
|
|
20993
|
-
if (this.config.proxy) init.dispatcher =
|
|
21161
|
+
if (this.config.proxy) init.dispatcher = getProxyDispatcher(this.config.proxy);
|
|
20994
21162
|
const res = await fetch(att.url, init);
|
|
20995
21163
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
20996
21164
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
@@ -23783,7 +23951,7 @@ import { promisify as promisify3 } from "node:util";
|
|
|
23783
23951
|
init_voice_chat_tts_daemon();
|
|
23784
23952
|
import * as path14 from "node:path";
|
|
23785
23953
|
import * as os6 from "node:os";
|
|
23786
|
-
import
|
|
23954
|
+
import net3 from "net";
|
|
23787
23955
|
var execFileAsync = promisify3(execFile);
|
|
23788
23956
|
var VOICE_DIR = path14.join(os6.tmpdir(), "engine-voice");
|
|
23789
23957
|
async function ttsCosyvoiceWorker(text2, cfg, onChunk) {
|
|
@@ -23795,7 +23963,7 @@ async function ttsCosyvoiceWorker(text2, cfg, onChunk) {
|
|
|
23795
23963
|
}
|
|
23796
23964
|
}
|
|
23797
23965
|
return new Promise((resolve12, reject) => {
|
|
23798
|
-
const sock =
|
|
23966
|
+
const sock = net3.connect(getSockPath());
|
|
23799
23967
|
let buf = "";
|
|
23800
23968
|
const finish = (err) => {
|
|
23801
23969
|
try {
|
|
@@ -24007,8 +24175,8 @@ var DeskBuddyAdapter = class {
|
|
|
24007
24175
|
startAsr() {
|
|
24008
24176
|
if (this.asrSock) return;
|
|
24009
24177
|
const port = this.asrBackend === "sensevoice" ? 9790 : 9791;
|
|
24010
|
-
const
|
|
24011
|
-
const sock =
|
|
24178
|
+
const net4 = __require("node:net");
|
|
24179
|
+
const sock = net4.connect(port, "127.0.0.1");
|
|
24012
24180
|
sock.setNoDelay(true);
|
|
24013
24181
|
this.asrSock = sock;
|
|
24014
24182
|
this.asrBuf = "";
|
|
@@ -24560,7 +24728,7 @@ var CcBridgeAdapter = class {
|
|
|
24560
24728
|
|
|
24561
24729
|
// src/channels/telegram.ts
|
|
24562
24730
|
import fs13 from "node:fs";
|
|
24563
|
-
import { AsyncLocalStorage as
|
|
24731
|
+
import { AsyncLocalStorage as AsyncLocalStorage7 } from "node:async_hooks";
|
|
24564
24732
|
import path17 from "node:path";
|
|
24565
24733
|
|
|
24566
24734
|
// src/channels/telegram-offset.ts
|
|
@@ -24752,7 +24920,7 @@ var PreviewEditThrottle = class {
|
|
|
24752
24920
|
/** 提交一次编辑;返回的 promise 在"该内容(或其后覆盖它的更新内容)真实落盘"后 settle,失败 reject */
|
|
24753
24921
|
submit(key4, req, run) {
|
|
24754
24922
|
const s = this.st.get(key4) ?? { lastEditAt: -Infinity, timer: null, pending: null, pendingRun: null, waiters: [] };
|
|
24755
|
-
const guardedRun =
|
|
24923
|
+
const guardedRun = AsyncLocalStorage7.bind(run);
|
|
24756
24924
|
this.st.set(key4, s);
|
|
24757
24925
|
return new Promise((resolve12, reject) => {
|
|
24758
24926
|
const waiter = { resolve: resolve12, reject };
|
|
@@ -25938,9 +26106,6 @@ var QrManager = class {
|
|
|
25938
26106
|
}
|
|
25939
26107
|
};
|
|
25940
26108
|
|
|
25941
|
-
// src/channels/whatsapp/socket.ts
|
|
25942
|
-
import { HttpsProxyAgent as HttpsProxyAgent2 } from "https-proxy-agent";
|
|
25943
|
-
|
|
25944
26109
|
// src/version.ts
|
|
25945
26110
|
import { readFileSync as readFileSync12 } from "node:fs";
|
|
25946
26111
|
import { dirname as dirname10, join as join21 } from "node:path";
|
|
@@ -25967,7 +26132,7 @@ function readEngineVersion() {
|
|
|
25967
26132
|
}
|
|
25968
26133
|
|
|
25969
26134
|
// src/channels/whatsapp/socket.ts
|
|
25970
|
-
|
|
26135
|
+
init_adaptive_proxy();
|
|
25971
26136
|
var VERSION_SOURCE_URL = "https://raw.githubusercontent.com/WhiskeySockets/Baileys/master/src/Defaults/index.ts";
|
|
25972
26137
|
var VERSION_FETCH_TIMEOUT_MS = 3e3;
|
|
25973
26138
|
var VERSION_FALLBACK_TIMEOUT_MS = 5e3;
|
|
@@ -26061,7 +26226,7 @@ async function makeWaSocket(opts) {
|
|
|
26061
26226
|
connectTimeoutMs: 6e4,
|
|
26062
26227
|
defaultQueryTimeoutMs: 6e4,
|
|
26063
26228
|
// ws 层代理(https-proxy-agent,baileys 原生支持)
|
|
26064
|
-
agent: opts.proxy ?
|
|
26229
|
+
agent: opts.proxy ? createProxySocketAgent(opts.proxy) : void 0,
|
|
26065
26230
|
// 媒体上传/下载走 native fetch,只认 undici dispatcher(防线 4,见文件头)
|
|
26066
26231
|
fetchAgent: opts.proxy ? getProxyDispatcher(opts.proxy) : void 0,
|
|
26067
26232
|
auth: { creds: auth.state.creds, keys },
|
|
@@ -27091,9 +27256,9 @@ function isPlanMode() {
|
|
|
27091
27256
|
init_runtime_authority();
|
|
27092
27257
|
|
|
27093
27258
|
// src/continuity/gateway-context.ts
|
|
27094
|
-
import { AsyncLocalStorage as
|
|
27095
|
-
var contexts = new
|
|
27096
|
-
var outputKinds = new
|
|
27259
|
+
import { AsyncLocalStorage as AsyncLocalStorage8 } from "node:async_hooks";
|
|
27260
|
+
var contexts = new AsyncLocalStorage8();
|
|
27261
|
+
var outputKinds = new AsyncLocalStorage8();
|
|
27097
27262
|
var travelOutputKind = () => outputKinds.getStore() ?? "REPLY";
|
|
27098
27263
|
function withTravelOutputKind(kind, run) {
|
|
27099
27264
|
return outputKinds.run(kind, run);
|
|
@@ -27228,7 +27393,9 @@ function emitHookResponse(data) {
|
|
|
27228
27393
|
|
|
27229
27394
|
// src/skills/skill-gate.ts
|
|
27230
27395
|
init_strip_injected();
|
|
27396
|
+
init_writer();
|
|
27231
27397
|
var USER_CHANNELS = /* @__PURE__ */ new Set(["discord", "feishu", "wechat", "telegram", "cli", "console", "voice-chat", "deskBuddy", "ccBridge"]);
|
|
27398
|
+
var SKILL_CHANNELS = /* @__PURE__ */ new Set([...USER_CHANNELS, "chan7", "webhook"]);
|
|
27232
27399
|
var loadedBySession = /* @__PURE__ */ new Map();
|
|
27233
27400
|
var MAX_TRACKED_SESSIONS = 100;
|
|
27234
27401
|
function beginSkillGate(sessionId) {
|
|
@@ -30728,12 +30895,12 @@ var QueryEngine = class _QueryEngine {
|
|
|
30728
30895
|
try {
|
|
30729
30896
|
const url = "https://localhost:8116/voice-reply";
|
|
30730
30897
|
if (url.startsWith("https://")) {
|
|
30731
|
-
const
|
|
30898
|
+
const https2 = await import("node:https");
|
|
30732
30899
|
const postData = JSON.stringify({ text: line, isPlaceholder: true });
|
|
30733
30900
|
assertExternalEffectCurrent();
|
|
30734
30901
|
beginHostTurnEffect();
|
|
30735
30902
|
await new Promise((resolve12, reject) => {
|
|
30736
|
-
const req =
|
|
30903
|
+
const req = https2.request(url, {
|
|
30737
30904
|
method: "POST",
|
|
30738
30905
|
headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(postData) },
|
|
30739
30906
|
rejectUnauthorized: false
|
|
@@ -33680,11 +33847,10 @@ var DingTalkAdapter = class _DingTalkAdapter {
|
|
|
33680
33847
|
throw new Error("dingtalk clientId/clientSecret \u672A\u914D\u7F6E\uFF08\u5F00\u53D1\u8005\u540E\u53F0 \u2192 \u5E94\u7528 \u2192 \u51ED\u8BC1\uFF09");
|
|
33681
33848
|
}
|
|
33682
33849
|
if (this.cfg.proxy) {
|
|
33683
|
-
const { getProxyDispatcher: getProxyDispatcher2 } = await Promise.resolve().then(() => (
|
|
33850
|
+
const { createProxySocketAgent: createProxySocketAgent2, getProxyDispatcher: getProxyDispatcher2 } = await Promise.resolve().then(() => (init_adaptive_proxy(), adaptive_proxy_exports));
|
|
33684
33851
|
const dispatcher = getProxyDispatcher2(this.cfg.proxy);
|
|
33685
33852
|
this.baseFetch = (url, init) => this.fetchImpl(url, { ...init, dispatcher });
|
|
33686
|
-
|
|
33687
|
-
this.wsAgent = new HttpsProxyAgent3(this.cfg.proxy);
|
|
33853
|
+
this.wsAgent = createProxySocketAgent2(this.cfg.proxy);
|
|
33688
33854
|
this.token = new DingTalkTokenManager(this.cfg.clientId, this.cfg.clientSecret, (u, i) => this.baseFetch(u, i), this.now);
|
|
33689
33855
|
console.log(`[dingtalk] outbound via proxy ${this.cfg.proxy}`);
|
|
33690
33856
|
}
|
|
@@ -34245,7 +34411,7 @@ var DING_EDIT_INTERVAL_MS = 300;
|
|
|
34245
34411
|
|
|
34246
34412
|
// src/channels/wecom-stream.ts
|
|
34247
34413
|
import { EventEmitter as EventEmitter2 } from "node:events";
|
|
34248
|
-
import { AsyncLocalStorage as
|
|
34414
|
+
import { AsyncLocalStorage as AsyncLocalStorage9 } from "node:async_hooks";
|
|
34249
34415
|
import { createHash as createHash35 } from "node:crypto";
|
|
34250
34416
|
var WECOM_WS_URL = "wss://openws.work.weixin.qq.com";
|
|
34251
34417
|
var HEARTBEAT_MS2 = 3e4;
|
|
@@ -34571,7 +34737,7 @@ var WecomStreamClient = class extends EventEmitter2 {
|
|
|
34571
34737
|
const item = {
|
|
34572
34738
|
frame,
|
|
34573
34739
|
// The ack event which pumps this queue has another async context. Keep the sender's guards.
|
|
34574
|
-
send:
|
|
34740
|
+
send: AsyncLocalStorage9.bind((ws) => {
|
|
34575
34741
|
assertExternalEffectCurrent();
|
|
34576
34742
|
ws.send(JSON.stringify(frame));
|
|
34577
34743
|
}),
|
|
@@ -34881,12 +35047,11 @@ var WecomAdapter = class {
|
|
|
34881
35047
|
this.loadRoutes();
|
|
34882
35048
|
let wsAgent;
|
|
34883
35049
|
if (this.cfg.proxy) {
|
|
34884
|
-
const { getProxyDispatcher: getProxyDispatcher2 } = await Promise.resolve().then(() => (
|
|
35050
|
+
const { createProxySocketAgent: createProxySocketAgent2, getProxyDispatcher: getProxyDispatcher2 } = await Promise.resolve().then(() => (init_adaptive_proxy(), adaptive_proxy_exports));
|
|
34885
35051
|
const dispatcher = getProxyDispatcher2(this.cfg.proxy);
|
|
34886
35052
|
const base = this.fetchImpl;
|
|
34887
35053
|
this.fetchImpl = (url, init) => base(url, { ...init, dispatcher });
|
|
34888
|
-
|
|
34889
|
-
wsAgent = new HttpsProxyAgent3(this.cfg.proxy);
|
|
35054
|
+
wsAgent = createProxySocketAgent2(this.cfg.proxy);
|
|
34890
35055
|
}
|
|
34891
35056
|
let wsCtor = this.cfg.wsCtor;
|
|
34892
35057
|
if (!wsCtor) {
|
|
@@ -35521,7 +35686,7 @@ async function deliverChannelGatewayEffect(adapter, effect, body, assertCurrent)
|
|
|
35521
35686
|
// src/continuity/gateway-feishu.ts
|
|
35522
35687
|
init_gateway_media();
|
|
35523
35688
|
import * as lark2 from "@larksuiteoapi/node-sdk";
|
|
35524
|
-
import { AsyncLocalStorage as
|
|
35689
|
+
import { AsyncLocalStorage as AsyncLocalStorage10 } from "node:async_hooks";
|
|
35525
35690
|
import { basename as basename6 } from "node:path";
|
|
35526
35691
|
|
|
35527
35692
|
// src/continuity/gateway-feishu-render.ts
|
|
@@ -35554,7 +35719,7 @@ var quiet = { error: () => {
|
|
|
35554
35719
|
}, debug: () => {
|
|
35555
35720
|
}, trace: () => {
|
|
35556
35721
|
} };
|
|
35557
|
-
var dispatchContext = new
|
|
35722
|
+
var dispatchContext = new AsyncLocalStorage10();
|
|
35558
35723
|
var format = "engine7-feishu-gateway-inbound-v1";
|
|
35559
35724
|
function createFeishuGatewayDispatcher(options) {
|
|
35560
35725
|
return new lark2.EventDispatcher({ verificationToken: options.verificationToken, encryptKey: options.encryptKey, logger: quiet }).register({
|
|
@@ -35740,9 +35905,9 @@ import { basename as basename7 } from "node:path";
|
|
|
35740
35905
|
function createRemoteTravelChannel(block, stateDir, channel = "feishu") {
|
|
35741
35906
|
if (!stateDir || !runtimeAuthorityFor(stateDir)) throw new Error("TRAVEL_GATEWAY_RUNTIME_REQUIRED");
|
|
35742
35907
|
validateTravelChannels(stateDir, { [channel]: block });
|
|
35743
|
-
const
|
|
35744
|
-
if (!
|
|
35745
|
-
const client = new TravelGatewayClient({ url: block.gatewayUrl, ca: readPrivateFile(
|
|
35908
|
+
const tls3 = block.gatewayTls;
|
|
35909
|
+
if (!tls3 || ["caFile", "certFile", "keyFile"].some((key4) => typeof tls3[key4] !== "string" || !tls3[key4])) throw new Error("TRAVEL_GATEWAY_REMOTE_CONFIG_REQUIRED");
|
|
35910
|
+
const client = new TravelGatewayClient({ url: block.gatewayUrl, ca: readPrivateFile(tls3.caFile, 1024 * 1024), cert: readPrivateFile(tls3.certFile, 1024 * 1024), key: readPrivateFile(tls3.keyFile, 16384) });
|
|
35746
35911
|
return new RemoteTravelChannel({ client, channel, permit: () => runtimeAuthorityFor(stateDir).assert("INPUT"), pollIntervalMs: block.gatewayPollIntervalMs });
|
|
35747
35912
|
}
|
|
35748
35913
|
var RemoteTravelChannel = class {
|
|
@@ -36339,8 +36504,8 @@ var ChannelManager = class {
|
|
|
36339
36504
|
/** 停止所有 adapter */
|
|
36340
36505
|
async stopAll() {
|
|
36341
36506
|
const results = await Promise.allSettled(this.adapters.map(async (adapter) => adapter.disconnect()));
|
|
36342
|
-
const
|
|
36343
|
-
if (
|
|
36507
|
+
const errors3 = results.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
36508
|
+
if (errors3.length) throw new AggregateError(errors3, "CHANNEL_STOP_FAILED");
|
|
36344
36509
|
}
|
|
36345
36510
|
/** 通道是否有已注册 adapter(投递前置判断用;1105 inbox-poller route 白名单替代硬编码) */
|
|
36346
36511
|
hasChannel(channelName) {
|
|
@@ -36453,7 +36618,7 @@ function path35(value) {
|
|
|
36453
36618
|
if (typeof value !== "string" || !isAbsolute5(value)) throw new Error("TRAVEL_GATEWAY_ABSOLUTE_PATH_REQUIRED");
|
|
36454
36619
|
return resolve11(value);
|
|
36455
36620
|
}
|
|
36456
|
-
function
|
|
36621
|
+
function tls2(config) {
|
|
36457
36622
|
return { ca: readPrivateFile(path35(config?.caFile), 1024 * 1024), cert: readPrivateFile(path35(config?.certFile), 1024 * 1024), key: readPrivateFile(path35(config?.keyFile), 16384) };
|
|
36458
36623
|
}
|
|
36459
36624
|
async function startTravelGateway(config) {
|
|
@@ -36462,7 +36627,7 @@ async function startTravelGateway(config) {
|
|
|
36462
36627
|
for (const [name, value] of Object.entries(config.channels ?? {})) if (value?.enabled && !["feishu", "discord", "wechat"].includes(name)) throw new Error("TRAVEL_CHANNEL_NOT_CONTROLLED");
|
|
36463
36628
|
const feishuIngress = config.ingressEnabled !== false && config.feishu?.ingressEnabled !== false && config.channels?.feishu?.enabled !== false;
|
|
36464
36629
|
if (feishuIngress && !/^cli_[0-9a-fA-F]{16}$/.test(config.feishu?.appId)) throw new Error("TRAVEL_FEISHU_INVALID_CONFIG");
|
|
36465
|
-
const keyConfig = { url: config.keyService.url, identity: config.keyService.identity, minimumDeletionWatermark: config.keyService.minimumDeletionWatermark, ...
|
|
36630
|
+
const keyConfig = { url: config.keyService.url, identity: config.keyService.identity, minimumDeletionWatermark: config.keyService.minimumDeletionWatermark, ...tls2(config.keyService.tls), timeoutMs: 1e4 };
|
|
36466
36631
|
const material = await fetchTravelKey(keyConfig);
|
|
36467
36632
|
const keyDigest = createHash37("sha256").update(material.key).digest("hex");
|
|
36468
36633
|
let keyWatermark = material.deletionWatermark;
|
|
@@ -36516,7 +36681,7 @@ async function startTravelGateway(config) {
|
|
|
36516
36681
|
await store.migrateStoredInputs();
|
|
36517
36682
|
if (config.previouslyProcessedPlatformIds) store.importProcessedInputs(config.previouslyProcessedPlatformIds);
|
|
36518
36683
|
platform = createFeishuGatewayPlatform(config.feishu);
|
|
36519
|
-
server = createTravelGatewayServer({ ...
|
|
36684
|
+
server = createTravelGatewayServer({ ...tls2(config.tls), store, authority, allowedPeers: config.allowedPeers, recoveryPeers: config.recoveryPeers, assertReady: assertKey, platform: { deliver: async (effect, body, assertCurrent) => {
|
|
36520
36685
|
const packet = effect.kind === "MEDIA" ? (await Promise.resolve().then(() => (init_gateway_media(), gateway_media_exports))).decodeGatewayMedia(body).metadata : JSON.parse(body.toString());
|
|
36521
36686
|
const channel = packet.channel ?? "feishu";
|
|
36522
36687
|
if (channel === "feishu") return platform.deliver(effect, body, () => {
|
|
@@ -36537,7 +36702,7 @@ async function startTravelGateway(config) {
|
|
|
36537
36702
|
if (config.control) {
|
|
36538
36703
|
if (!Number.isSafeInteger(config.control.port) || config.control.port < 0 || config.control.port > 65535 || typeof config.control.host !== "string" || !config.control.host) throw new Error("TRAVEL_CONTROL_INVALID_LISTENER");
|
|
36539
36704
|
controlServer = createTravelAuthorityServer({
|
|
36540
|
-
...
|
|
36705
|
+
...tls2(config.control.tls ?? config.tls),
|
|
36541
36706
|
authority,
|
|
36542
36707
|
proxyFingerprints: config.control.proxyFingerprints,
|
|
36543
36708
|
allowedPeers: config.control.allowedPeers,
|