@fangyb/ahchat-bridge 0.1.34 → 0.1.36
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.cjs +902 -184
- package/dist/feedbackWorkerCli.cjs +99 -9
- package/dist/index.js +894 -184
- package/dist/seedanceMcpCli.cjs +1785 -134
- package/dist/seedreamMcpCli.cjs +1801 -144
- package/package.json +3 -2
|
@@ -4385,9 +4385,14 @@ ${entry.error.stack}` : ""}`
|
|
|
4385
4385
|
return `${ts} ${level} ${scope} ${entry.msg}${data}${trace}${errPart}`;
|
|
4386
4386
|
};
|
|
4387
4387
|
|
|
4388
|
+
// ../logger/src/fallback.ts
|
|
4389
|
+
init_cjs_shims();
|
|
4390
|
+
|
|
4388
4391
|
// ../logger/src/transports/console.ts
|
|
4389
4392
|
init_cjs_shims();
|
|
4390
4393
|
var protectedStreams = /* @__PURE__ */ new WeakSet();
|
|
4394
|
+
function ignoreWriteError(_error) {
|
|
4395
|
+
}
|
|
4391
4396
|
function defaultStream(kind) {
|
|
4392
4397
|
const maybeGlobal = globalThis;
|
|
4393
4398
|
return maybeGlobal.process?.[kind];
|
|
@@ -4400,12 +4405,13 @@ function safeWriteLine(stream, line, fallback) {
|
|
|
4400
4405
|
if (stream.destroyed || stream.writableEnded) return;
|
|
4401
4406
|
if (typeof stream === "object" && typeof stream.on === "function" && !protectedStreams.has(stream)) {
|
|
4402
4407
|
protectedStreams.add(stream);
|
|
4403
|
-
stream.on("error",
|
|
4408
|
+
stream.on("error", ignoreWriteError);
|
|
4404
4409
|
}
|
|
4405
4410
|
try {
|
|
4406
4411
|
stream.write(`${line}
|
|
4407
|
-
`,
|
|
4408
|
-
} catch {
|
|
4412
|
+
`, ignoreWriteError);
|
|
4413
|
+
} catch (e) {
|
|
4414
|
+
ignoreWriteError(e);
|
|
4409
4415
|
}
|
|
4410
4416
|
}
|
|
4411
4417
|
function consoleTransport(opts) {
|
|
@@ -5040,8 +5046,31 @@ function parseSize(maxSize) {
|
|
|
5040
5046
|
return trimmed;
|
|
5041
5047
|
}
|
|
5042
5048
|
var streamCache = /* @__PURE__ */ new Map();
|
|
5049
|
+
var droppedEntryCount = 0;
|
|
5050
|
+
var lastReportedDroppedTotal = 0;
|
|
5051
|
+
function buildLogDroppedSentinel(fmt, source, droppedTotal) {
|
|
5052
|
+
const entry = {
|
|
5053
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5054
|
+
level: "WARN",
|
|
5055
|
+
source,
|
|
5056
|
+
module: "logger.file",
|
|
5057
|
+
msg: "log_dropped",
|
|
5058
|
+
data: { droppedTotal }
|
|
5059
|
+
};
|
|
5060
|
+
return fmt(entry);
|
|
5061
|
+
}
|
|
5062
|
+
function writeWithDroppedSentinel(stream, fmt, line, source) {
|
|
5063
|
+
stream.write(`${line}
|
|
5064
|
+
`);
|
|
5065
|
+
if (droppedEntryCount > lastReportedDroppedTotal) {
|
|
5066
|
+
lastReportedDroppedTotal = droppedEntryCount;
|
|
5067
|
+
stream.write(`${buildLogDroppedSentinel(fmt, source, droppedEntryCount)}
|
|
5068
|
+
`);
|
|
5069
|
+
}
|
|
5070
|
+
}
|
|
5043
5071
|
function fileTransport(opts) {
|
|
5044
5072
|
const fmt = opts.formatter ?? jsonFormatter;
|
|
5073
|
+
const logSource = opts.source ?? "server";
|
|
5045
5074
|
const resolved = import_node_path.default.resolve(opts.path);
|
|
5046
5075
|
let cached = streamCache.get(resolved);
|
|
5047
5076
|
if (!cached) {
|
|
@@ -5056,11 +5085,14 @@ function fileTransport(opts) {
|
|
|
5056
5085
|
streamCache.set(resolved, cached);
|
|
5057
5086
|
}
|
|
5058
5087
|
return (entry) => {
|
|
5059
|
-
if (cached.closed || cached.stream.destroyed || cached.stream.writableEnded)
|
|
5088
|
+
if (cached.closed || cached.stream.destroyed || cached.stream.writableEnded) {
|
|
5089
|
+
droppedEntryCount += 1;
|
|
5090
|
+
return;
|
|
5091
|
+
}
|
|
5060
5092
|
try {
|
|
5061
|
-
cached.stream
|
|
5062
|
-
`);
|
|
5093
|
+
writeWithDroppedSentinel(cached.stream, fmt, fmt(entry), logSource);
|
|
5063
5094
|
} catch {
|
|
5095
|
+
droppedEntryCount += 1;
|
|
5064
5096
|
}
|
|
5065
5097
|
};
|
|
5066
5098
|
}
|
|
@@ -5116,6 +5148,8 @@ var DEFAULT_QUERY_CONFIG = {
|
|
|
5116
5148
|
maxActive: 5040,
|
|
5117
5149
|
idleTimeoutMs: 6e5,
|
|
5118
5150
|
workingSilenceTimeoutMs: 12e5,
|
|
5151
|
+
replyStallTimeoutMs: 3e5,
|
|
5152
|
+
busySilenceTimeoutMs: 18e5,
|
|
5119
5153
|
evictionIntervalMs: 6e4,
|
|
5120
5154
|
statusReportIntervalMs: 6e4,
|
|
5121
5155
|
allowBuiltinWebSearch: false,
|
|
@@ -5173,6 +5207,14 @@ function mergeQueryConfig(file) {
|
|
|
5173
5207
|
"AHCHAT_BRIDGE_WORKING_SILENCE_TIMEOUT_MS",
|
|
5174
5208
|
q?.workingSilenceTimeoutMs ?? DEFAULT_QUERY_CONFIG.workingSilenceTimeoutMs
|
|
5175
5209
|
),
|
|
5210
|
+
replyStallTimeoutMs: readEnvInt(
|
|
5211
|
+
"AHCHAT_BRIDGE_REPLY_STALL_TIMEOUT_MS",
|
|
5212
|
+
q?.replyStallTimeoutMs ?? DEFAULT_QUERY_CONFIG.replyStallTimeoutMs
|
|
5213
|
+
),
|
|
5214
|
+
busySilenceTimeoutMs: readEnvInt(
|
|
5215
|
+
"AHCHAT_BRIDGE_BUSY_SILENCE_TIMEOUT_MS",
|
|
5216
|
+
q?.busySilenceTimeoutMs ?? DEFAULT_QUERY_CONFIG.busySilenceTimeoutMs ?? 18e5
|
|
5217
|
+
),
|
|
5176
5218
|
evictionIntervalMs: readEnvInt(
|
|
5177
5219
|
"AHCHAT_BRIDGE_EVICTION_INTERVAL_MS",
|
|
5178
5220
|
q?.evictionIntervalMs ?? DEFAULT_QUERY_CONFIG.evictionIntervalMs
|
|
@@ -5253,7 +5295,11 @@ function loadBridgeConfig(opts) {
|
|
|
5253
5295
|
) || null,
|
|
5254
5296
|
logUploadIntervalMs: readEnvInt(
|
|
5255
5297
|
"AHCHAT_LOG_UPLOAD_INTERVAL_MS",
|
|
5256
|
-
|
|
5298
|
+
// Flush every 60s instead of once a day. Daily flushing let logs pile up for hours,
|
|
5299
|
+
// then dumped tens of thousands of entries in one cycle on the next process start,
|
|
5300
|
+
// blowing past the server's per-minute upload quota (3000 entries / 3MB) and getting
|
|
5301
|
+
// 429'd. Small frequent batches stay well under that ceiling.
|
|
5302
|
+
fileConfig.logUploadIntervalMs ?? 6e4
|
|
5257
5303
|
),
|
|
5258
5304
|
queryConfig: mergeQueryConfig(fileConfig)
|
|
5259
5305
|
};
|
|
@@ -5779,6 +5825,9 @@ init_cjs_shims();
|
|
|
5779
5825
|
// ../shared/src/types/index.ts
|
|
5780
5826
|
init_cjs_shims();
|
|
5781
5827
|
|
|
5828
|
+
// ../shared/src/types/usage.ts
|
|
5829
|
+
init_cjs_shims();
|
|
5830
|
+
|
|
5782
5831
|
// ../shared/src/types/message.ts
|
|
5783
5832
|
init_cjs_shims();
|
|
5784
5833
|
|
|
@@ -5857,6 +5906,24 @@ function assertNumberPayloadField(type, payload, field) {
|
|
|
5857
5906
|
throw invalidWsMessage(type, field);
|
|
5858
5907
|
}
|
|
5859
5908
|
}
|
|
5909
|
+
function assertOptionalNumberPayloadField(type, payload, field) {
|
|
5910
|
+
if (payload[field] === void 0) return;
|
|
5911
|
+
assertNumberPayloadField(type, payload, field);
|
|
5912
|
+
}
|
|
5913
|
+
function assertNullableStringPayloadField(type, payload, field) {
|
|
5914
|
+
if (payload[field] === null) return;
|
|
5915
|
+
assertStringPayloadField(type, payload, field);
|
|
5916
|
+
}
|
|
5917
|
+
function assertStringPayloadOneOf(type, payload, field, allowed) {
|
|
5918
|
+
assertStringPayloadField(type, payload, field);
|
|
5919
|
+
if (!allowed.includes(payload[field])) {
|
|
5920
|
+
throw invalidWsMessage(type, field);
|
|
5921
|
+
}
|
|
5922
|
+
}
|
|
5923
|
+
function assertOptionalStringPayloadOneOf(type, payload, field, allowed) {
|
|
5924
|
+
if (payload[field] === void 0) return;
|
|
5925
|
+
assertStringPayloadOneOf(type, payload, field, allowed);
|
|
5926
|
+
}
|
|
5860
5927
|
function assertArrayPayloadField(type, payload, field) {
|
|
5861
5928
|
if (!Array.isArray(payload[field])) {
|
|
5862
5929
|
throw invalidWsMessage(type, field);
|
|
@@ -5937,6 +6004,25 @@ function validateWSMessageShape(msg) {
|
|
|
5937
6004
|
case "agent:error": {
|
|
5938
6005
|
assertPayloadRecord(type, payload);
|
|
5939
6006
|
validateRequiredStrings(type, payload, ["ackId", "agentId", "conversationId", "error", "traceId"]);
|
|
6007
|
+
assertOptionalStringPayloadOneOf(type, payload, "reason", ["user_quota_exceeded", "company_quota_exceeded"]);
|
|
6008
|
+
return;
|
|
6009
|
+
}
|
|
6010
|
+
case "directory:register": {
|
|
6011
|
+
assertPayloadRecord(type, payload);
|
|
6012
|
+
validateRequiredStrings(type, payload, ["handle", "viaChild", "traceId"]);
|
|
6013
|
+
assertStringPayloadOneOf(type, payload, "op", ["add", "remove", "move"]);
|
|
6014
|
+
return;
|
|
6015
|
+
}
|
|
6016
|
+
case "directory:resolve": {
|
|
6017
|
+
assertPayloadRecord(type, payload);
|
|
6018
|
+
validateRequiredStrings(type, payload, ["handle", "fromNode", "traceId"]);
|
|
6019
|
+
assertOptionalNumberPayloadField(type, payload, "hop");
|
|
6020
|
+
return;
|
|
6021
|
+
}
|
|
6022
|
+
case "directory:resolve_result": {
|
|
6023
|
+
assertPayloadRecord(type, payload);
|
|
6024
|
+
validateRequiredStrings(type, payload, ["handle", "traceId"]);
|
|
6025
|
+
assertNullableStringPayloadField(type, payload, "canonicalAddress");
|
|
5940
6026
|
return;
|
|
5941
6027
|
}
|
|
5942
6028
|
default:
|
|
@@ -6801,6 +6887,9 @@ init_cjs_shims();
|
|
|
6801
6887
|
// ../shared/src/utils/serverUrl.ts
|
|
6802
6888
|
init_cjs_shims();
|
|
6803
6889
|
|
|
6890
|
+
// ../shared/src/utils/phone.ts
|
|
6891
|
+
init_cjs_shims();
|
|
6892
|
+
|
|
6804
6893
|
// ../shared/src/utils/mediaPreviewHtml.ts
|
|
6805
6894
|
init_cjs_shims();
|
|
6806
6895
|
|
|
@@ -7261,8 +7350,8 @@ var VOLCENGINE_SEEDANCE_MCP_PROVIDER = {
|
|
|
7261
7350
|
};
|
|
7262
7351
|
var OFFICIAL_MCP_PROVIDERS = [
|
|
7263
7352
|
...ALIYUN_IQS_MCP_PROVIDERS,
|
|
7264
|
-
|
|
7265
|
-
|
|
7353
|
+
VOLCENGINE_SEEDREAM_MCP_PROVIDER,
|
|
7354
|
+
VOLCENGINE_SEEDANCE_MCP_PROVIDER
|
|
7266
7355
|
];
|
|
7267
7356
|
var MCP_STORE_PROVIDERS = [
|
|
7268
7357
|
{
|
|
@@ -7754,6 +7843,7 @@ var ServerConnector = class {
|
|
|
7754
7843
|
case "agent:terminate":
|
|
7755
7844
|
case "agent:runtime_reload":
|
|
7756
7845
|
case "agent:terminate_scope":
|
|
7846
|
+
case "spectate:set":
|
|
7757
7847
|
case "agent:created":
|
|
7758
7848
|
case "agent:updated":
|
|
7759
7849
|
case "agent:workdir-updated":
|