engine7 7.1.57 → 7.1.59
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 +33 -6
- package/dist/engine-startup.mjs +35 -9
- package/dist/main.mjs +35 -9
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -3120,10 +3120,26 @@ var init_anthropic_provider = __esm({
|
|
|
3120
3120
|
}
|
|
3121
3121
|
}
|
|
3122
3122
|
}
|
|
3123
|
+
if (process.env.ENGINE_DUMP_REQUEST === "1") {
|
|
3124
|
+
try {
|
|
3125
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
3126
|
+
const dumpPath = __require("node:path").join(process.env.ENGINE_STATE_DIR || ".", "logs", `req-${params.model.replace(/[\/:]/g, "_")}-${ts}.json`);
|
|
3127
|
+
__require("node:fs").writeFileSync(dumpPath, JSON.stringify({ url, headers, body }, null, 1));
|
|
3128
|
+
console.log(`[anthropic] \u{1F4F8} request dumped \u2192 ${__require("node:path").basename(dumpPath)} (${(JSON.stringify(body).length / 1024).toFixed(0)}KB)`);
|
|
3129
|
+
} catch {
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
let bodyStr = JSON.stringify(body);
|
|
3133
|
+
if (this.config.wafSingleQuoteWorkaround) {
|
|
3134
|
+
const before = bodyStr.length;
|
|
3135
|
+
bodyStr = bodyStr.replace(/'/g, "\u2019");
|
|
3136
|
+
if (bodyStr.length !== before) {
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3123
3139
|
const retryGen = fetchWithRetry(url, {
|
|
3124
3140
|
method: "POST",
|
|
3125
3141
|
headers,
|
|
3126
|
-
body:
|
|
3142
|
+
body: bodyStr,
|
|
3127
3143
|
signal: params.signal
|
|
3128
3144
|
}, "anthropic", this.config.proxy);
|
|
3129
3145
|
let response;
|
|
@@ -3638,7 +3654,9 @@ function createProvider(config) {
|
|
|
3638
3654
|
baseUrl: config.baseUrl,
|
|
3639
3655
|
apiKey: config.apiKey,
|
|
3640
3656
|
thinking: config.thinking,
|
|
3641
|
-
proxy
|
|
3657
|
+
proxy,
|
|
3658
|
+
wafSingleQuoteWorkaround: config.wafSingleQuoteWorkaround
|
|
3659
|
+
// 0902 agentrouter WAF 引号规避
|
|
3642
3660
|
});
|
|
3643
3661
|
case "gemini":
|
|
3644
3662
|
return new GeminiProvider({
|
|
@@ -9404,13 +9422,17 @@ function isDestructiveCommand(command) {
|
|
|
9404
9422
|
function sanitizeEnv(env) {
|
|
9405
9423
|
const result = {};
|
|
9406
9424
|
for (const [k, v] of Object.entries(env)) {
|
|
9425
|
+
if (ENV_ALLOW_KEYS.includes(k)) {
|
|
9426
|
+
result[k] = v;
|
|
9427
|
+
continue;
|
|
9428
|
+
}
|
|
9407
9429
|
if (!BLOCKED_ENV_KEYS.some((b) => k.toUpperCase().includes(b))) {
|
|
9408
9430
|
result[k] = v;
|
|
9409
9431
|
}
|
|
9410
9432
|
}
|
|
9411
9433
|
return result;
|
|
9412
9434
|
}
|
|
9413
|
-
var DANGEROUS_COMMANDS, DESTRUCTIVE_PATTERNS, BLOCKED_ENV_KEYS;
|
|
9435
|
+
var DANGEROUS_COMMANDS, DESTRUCTIVE_PATTERNS, BLOCKED_ENV_KEYS, ENV_ALLOW_KEYS;
|
|
9414
9436
|
var init_bashSecurity = __esm({
|
|
9415
9437
|
"src/tools/BashTool/bashSecurity.ts"() {
|
|
9416
9438
|
"use strict";
|
|
@@ -9461,6 +9483,7 @@ var init_bashSecurity = __esm({
|
|
|
9461
9483
|
"PASSWORD",
|
|
9462
9484
|
"PRIVATE_KEY"
|
|
9463
9485
|
];
|
|
9486
|
+
ENV_ALLOW_KEYS = ["MULTICA_TOKEN"];
|
|
9464
9487
|
}
|
|
9465
9488
|
});
|
|
9466
9489
|
|
|
@@ -18707,11 +18730,15 @@ var init_autoDream = __esm({
|
|
|
18707
18730
|
var handle_query_exports = {};
|
|
18708
18731
|
__export(handle_query_exports, {
|
|
18709
18732
|
handleQuery: () => handleQuery,
|
|
18710
|
-
resetSessionStartInjection: () => resetSessionStartInjection
|
|
18733
|
+
resetSessionStartInjection: () => resetSessionStartInjection,
|
|
18734
|
+
resolveSystemPrompt: () => resolveSystemPrompt
|
|
18711
18735
|
});
|
|
18712
18736
|
import { readFileSync as readFileSync25, existsSync as existsSync22 } from "node:fs";
|
|
18713
18737
|
import { join as join33, resolve as resolve8 } from "node:path";
|
|
18714
18738
|
import * as path27 from "node:path";
|
|
18739
|
+
function resolveSystemPrompt(v) {
|
|
18740
|
+
return typeof v === "function" ? v() : v || "";
|
|
18741
|
+
}
|
|
18715
18742
|
function resetSessionStartInjection(sessionId) {
|
|
18716
18743
|
sessionStartDone.delete(sessionId);
|
|
18717
18744
|
}
|
|
@@ -19028,8 +19055,8 @@ ${text}` : text });
|
|
|
19028
19055
|
model,
|
|
19029
19056
|
parentMessages: messages,
|
|
19030
19057
|
// 对齐 CC: fork subagent 继承父对话历史
|
|
19031
|
-
parentSystemPrompt: deps.systemPrompt,
|
|
19032
|
-
// 对齐 CC: fork 共享 prompt cache
|
|
19058
|
+
parentSystemPrompt: resolveSystemPrompt(deps.systemPrompt),
|
|
19059
|
+
// 对齐 CC: fork 共享 prompt cache(0902 每消息现取)
|
|
19033
19060
|
features: liveConfig.get("agents.defaults.features"),
|
|
19034
19061
|
// engine config features(AgentTool 读 agentTool.showProgress)
|
|
19035
19062
|
channelTarget: channelTarget ?? "",
|
package/dist/engine-startup.mjs
CHANGED
|
@@ -4124,13 +4124,17 @@ function isDestructiveCommand(command) {
|
|
|
4124
4124
|
function sanitizeEnv(env) {
|
|
4125
4125
|
const result = {};
|
|
4126
4126
|
for (const [k, v] of Object.entries(env)) {
|
|
4127
|
+
if (ENV_ALLOW_KEYS.includes(k)) {
|
|
4128
|
+
result[k] = v;
|
|
4129
|
+
continue;
|
|
4130
|
+
}
|
|
4127
4131
|
if (!BLOCKED_ENV_KEYS.some((b) => k.toUpperCase().includes(b))) {
|
|
4128
4132
|
result[k] = v;
|
|
4129
4133
|
}
|
|
4130
4134
|
}
|
|
4131
4135
|
return result;
|
|
4132
4136
|
}
|
|
4133
|
-
var DANGEROUS_COMMANDS, DESTRUCTIVE_PATTERNS, BLOCKED_ENV_KEYS;
|
|
4137
|
+
var DANGEROUS_COMMANDS, DESTRUCTIVE_PATTERNS, BLOCKED_ENV_KEYS, ENV_ALLOW_KEYS;
|
|
4134
4138
|
var init_bashSecurity = __esm({
|
|
4135
4139
|
"src/tools/BashTool/bashSecurity.ts"() {
|
|
4136
4140
|
"use strict";
|
|
@@ -4181,6 +4185,7 @@ var init_bashSecurity = __esm({
|
|
|
4181
4185
|
"PASSWORD",
|
|
4182
4186
|
"PRIVATE_KEY"
|
|
4183
4187
|
];
|
|
4188
|
+
ENV_ALLOW_KEYS = ["MULTICA_TOKEN"];
|
|
4184
4189
|
}
|
|
4185
4190
|
});
|
|
4186
4191
|
|
|
@@ -13570,10 +13575,26 @@ var AnthropicProvider = class {
|
|
|
13570
13575
|
}
|
|
13571
13576
|
}
|
|
13572
13577
|
}
|
|
13578
|
+
if (process.env.ENGINE_DUMP_REQUEST === "1") {
|
|
13579
|
+
try {
|
|
13580
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
13581
|
+
const dumpPath = __require("node:path").join(process.env.ENGINE_STATE_DIR || ".", "logs", `req-${params.model.replace(/[\/:]/g, "_")}-${ts}.json`);
|
|
13582
|
+
__require("node:fs").writeFileSync(dumpPath, JSON.stringify({ url, headers, body }, null, 1));
|
|
13583
|
+
console.log(`[anthropic] \u{1F4F8} request dumped \u2192 ${__require("node:path").basename(dumpPath)} (${(JSON.stringify(body).length / 1024).toFixed(0)}KB)`);
|
|
13584
|
+
} catch {
|
|
13585
|
+
}
|
|
13586
|
+
}
|
|
13587
|
+
let bodyStr = JSON.stringify(body);
|
|
13588
|
+
if (this.config.wafSingleQuoteWorkaround) {
|
|
13589
|
+
const before = bodyStr.length;
|
|
13590
|
+
bodyStr = bodyStr.replace(/'/g, "\u2019");
|
|
13591
|
+
if (bodyStr.length !== before) {
|
|
13592
|
+
}
|
|
13593
|
+
}
|
|
13573
13594
|
const retryGen = fetchWithRetry(url, {
|
|
13574
13595
|
method: "POST",
|
|
13575
13596
|
headers,
|
|
13576
|
-
body:
|
|
13597
|
+
body: bodyStr,
|
|
13577
13598
|
signal: params.signal
|
|
13578
13599
|
}, "anthropic", this.config.proxy);
|
|
13579
13600
|
let response;
|
|
@@ -14076,7 +14097,9 @@ function createProvider(config) {
|
|
|
14076
14097
|
baseUrl: config.baseUrl,
|
|
14077
14098
|
apiKey: config.apiKey,
|
|
14078
14099
|
thinking: config.thinking,
|
|
14079
|
-
proxy
|
|
14100
|
+
proxy,
|
|
14101
|
+
wafSingleQuoteWorkaround: config.wafSingleQuoteWorkaround
|
|
14102
|
+
// 0902 agentrouter WAF 引号规避
|
|
14080
14103
|
});
|
|
14081
14104
|
case "gemini":
|
|
14082
14105
|
return new GeminiProvider({
|
|
@@ -20180,6 +20203,9 @@ function buildConversationAnchor(inboundMeta, channelName, source, workspace) {
|
|
|
20180
20203
|
|
|
20181
20204
|
// src/handle-query.ts
|
|
20182
20205
|
var sessionStartDone = /* @__PURE__ */ new Set();
|
|
20206
|
+
function resolveSystemPrompt(v) {
|
|
20207
|
+
return typeof v === "function" ? v() : v || "";
|
|
20208
|
+
}
|
|
20183
20209
|
function resetSessionStartInjection(sessionId) {
|
|
20184
20210
|
sessionStartDone.delete(sessionId);
|
|
20185
20211
|
}
|
|
@@ -20497,8 +20523,8 @@ ${text}` : text });
|
|
|
20497
20523
|
model,
|
|
20498
20524
|
parentMessages: messages,
|
|
20499
20525
|
// 对齐 CC: fork subagent 继承父对话历史
|
|
20500
|
-
parentSystemPrompt: deps.systemPrompt,
|
|
20501
|
-
// 对齐 CC: fork 共享 prompt cache
|
|
20526
|
+
parentSystemPrompt: resolveSystemPrompt(deps.systemPrompt),
|
|
20527
|
+
// 对齐 CC: fork 共享 prompt cache(0902 每消息现取)
|
|
20502
20528
|
features: liveConfig.get("agents.defaults.features"),
|
|
20503
20529
|
// engine config features(AgentTool 读 agentTool.showProgress)
|
|
20504
20530
|
channelTarget: channelTarget ?? "",
|
|
@@ -25271,7 +25297,7 @@ var VoiceChatPlugin = class _VoiceChatPlugin {
|
|
|
25271
25297
|
- \u5982\u679C\u5B9E\u5728\u9700\u8981\u67E5\uFF1A\u5148\u8BF4"\u7B49\u6211\u67E5\u4E0B"\u5E76\u6781\u7B80\u8C03\u7528\uFF0C\u67E5\u5B8C\u7ACB\u523B\u603B\u7ED3\u6210\u4E00\u53E5\u8BDD`;
|
|
25272
25298
|
const engine = new QueryEngine(llmProvider, {
|
|
25273
25299
|
model: modelId,
|
|
25274
|
-
systemPrompt: (ctx.deps.systemPrompt
|
|
25300
|
+
systemPrompt: resolveSystemPrompt(ctx.deps.systemPrompt) + voiceChatRules,
|
|
25275
25301
|
maxTokens: 4096,
|
|
25276
25302
|
temperature: 0.7,
|
|
25277
25303
|
disableThinking: !this.config.thinking,
|
|
@@ -29771,8 +29797,8 @@ registerCommand({
|
|
|
29771
29797
|
sessionManager: deps.sessions,
|
|
29772
29798
|
sessionId: sid,
|
|
29773
29799
|
model: deps.config.model,
|
|
29774
|
-
contextWindow: deps.compactConfig.contextWindow || 2e5,
|
|
29775
|
-
systemPrompt: deps.systemPrompt,
|
|
29800
|
+
contextWindow: (typeof deps.compactConfig === "function" ? deps.compactConfig() : deps.compactConfig).contextWindow || 2e5,
|
|
29801
|
+
systemPrompt: resolveSystemPrompt(deps.systemPrompt),
|
|
29776
29802
|
toolDefs: registry.definitions(),
|
|
29777
29803
|
workspace: deps.config.workspace
|
|
29778
29804
|
});
|
|
@@ -29820,7 +29846,7 @@ ${question}`;
|
|
|
29820
29846
|
const stream = deps.provider.streamChat({
|
|
29821
29847
|
model: deps.config.model,
|
|
29822
29848
|
messages: [{ role: "user", content: wrappedQuestion }],
|
|
29823
|
-
systemPrompt: deps.systemPrompt,
|
|
29849
|
+
systemPrompt: resolveSystemPrompt(deps.systemPrompt),
|
|
29824
29850
|
maxTokens: 2048,
|
|
29825
29851
|
signal: void 0
|
|
29826
29852
|
});
|
package/dist/main.mjs
CHANGED
|
@@ -4124,13 +4124,17 @@ function isDestructiveCommand(command) {
|
|
|
4124
4124
|
function sanitizeEnv(env) {
|
|
4125
4125
|
const result = {};
|
|
4126
4126
|
for (const [k, v] of Object.entries(env)) {
|
|
4127
|
+
if (ENV_ALLOW_KEYS.includes(k)) {
|
|
4128
|
+
result[k] = v;
|
|
4129
|
+
continue;
|
|
4130
|
+
}
|
|
4127
4131
|
if (!BLOCKED_ENV_KEYS.some((b) => k.toUpperCase().includes(b))) {
|
|
4128
4132
|
result[k] = v;
|
|
4129
4133
|
}
|
|
4130
4134
|
}
|
|
4131
4135
|
return result;
|
|
4132
4136
|
}
|
|
4133
|
-
var DANGEROUS_COMMANDS, DESTRUCTIVE_PATTERNS, BLOCKED_ENV_KEYS;
|
|
4137
|
+
var DANGEROUS_COMMANDS, DESTRUCTIVE_PATTERNS, BLOCKED_ENV_KEYS, ENV_ALLOW_KEYS;
|
|
4134
4138
|
var init_bashSecurity = __esm({
|
|
4135
4139
|
"src/tools/BashTool/bashSecurity.ts"() {
|
|
4136
4140
|
"use strict";
|
|
@@ -4181,6 +4185,7 @@ var init_bashSecurity = __esm({
|
|
|
4181
4185
|
"PASSWORD",
|
|
4182
4186
|
"PRIVATE_KEY"
|
|
4183
4187
|
];
|
|
4188
|
+
ENV_ALLOW_KEYS = ["MULTICA_TOKEN"];
|
|
4184
4189
|
}
|
|
4185
4190
|
});
|
|
4186
4191
|
|
|
@@ -13944,10 +13949,26 @@ var AnthropicProvider = class {
|
|
|
13944
13949
|
}
|
|
13945
13950
|
}
|
|
13946
13951
|
}
|
|
13952
|
+
if (process.env.ENGINE_DUMP_REQUEST === "1") {
|
|
13953
|
+
try {
|
|
13954
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
13955
|
+
const dumpPath = __require("node:path").join(process.env.ENGINE_STATE_DIR || ".", "logs", `req-${params.model.replace(/[\/:]/g, "_")}-${ts}.json`);
|
|
13956
|
+
__require("node:fs").writeFileSync(dumpPath, JSON.stringify({ url, headers, body }, null, 1));
|
|
13957
|
+
console.log(`[anthropic] \u{1F4F8} request dumped \u2192 ${__require("node:path").basename(dumpPath)} (${(JSON.stringify(body).length / 1024).toFixed(0)}KB)`);
|
|
13958
|
+
} catch {
|
|
13959
|
+
}
|
|
13960
|
+
}
|
|
13961
|
+
let bodyStr = JSON.stringify(body);
|
|
13962
|
+
if (this.config.wafSingleQuoteWorkaround) {
|
|
13963
|
+
const before = bodyStr.length;
|
|
13964
|
+
bodyStr = bodyStr.replace(/'/g, "\u2019");
|
|
13965
|
+
if (bodyStr.length !== before) {
|
|
13966
|
+
}
|
|
13967
|
+
}
|
|
13947
13968
|
const retryGen = fetchWithRetry(url, {
|
|
13948
13969
|
method: "POST",
|
|
13949
13970
|
headers,
|
|
13950
|
-
body:
|
|
13971
|
+
body: bodyStr,
|
|
13951
13972
|
signal: params.signal
|
|
13952
13973
|
}, "anthropic", this.config.proxy);
|
|
13953
13974
|
let response;
|
|
@@ -14450,7 +14471,9 @@ function createProvider(config2) {
|
|
|
14450
14471
|
baseUrl: config2.baseUrl,
|
|
14451
14472
|
apiKey: config2.apiKey,
|
|
14452
14473
|
thinking: config2.thinking,
|
|
14453
|
-
proxy
|
|
14474
|
+
proxy,
|
|
14475
|
+
wafSingleQuoteWorkaround: config2.wafSingleQuoteWorkaround
|
|
14476
|
+
// 0902 agentrouter WAF 引号规避
|
|
14454
14477
|
});
|
|
14455
14478
|
case "gemini":
|
|
14456
14479
|
return new GeminiProvider({
|
|
@@ -20554,6 +20577,9 @@ function buildConversationAnchor(inboundMeta, channelName, source, workspace) {
|
|
|
20554
20577
|
|
|
20555
20578
|
// src/handle-query.ts
|
|
20556
20579
|
var sessionStartDone = /* @__PURE__ */ new Set();
|
|
20580
|
+
function resolveSystemPrompt(v) {
|
|
20581
|
+
return typeof v === "function" ? v() : v || "";
|
|
20582
|
+
}
|
|
20557
20583
|
function resetSessionStartInjection(sessionId) {
|
|
20558
20584
|
sessionStartDone.delete(sessionId);
|
|
20559
20585
|
}
|
|
@@ -20871,8 +20897,8 @@ ${text}` : text });
|
|
|
20871
20897
|
model,
|
|
20872
20898
|
parentMessages: messages,
|
|
20873
20899
|
// 对齐 CC: fork subagent 继承父对话历史
|
|
20874
|
-
parentSystemPrompt: deps.systemPrompt,
|
|
20875
|
-
// 对齐 CC: fork 共享 prompt cache
|
|
20900
|
+
parentSystemPrompt: resolveSystemPrompt(deps.systemPrompt),
|
|
20901
|
+
// 对齐 CC: fork 共享 prompt cache(0902 每消息现取)
|
|
20876
20902
|
features: liveConfig.get("agents.defaults.features"),
|
|
20877
20903
|
// engine config features(AgentTool 读 agentTool.showProgress)
|
|
20878
20904
|
channelTarget: channelTarget ?? "",
|
|
@@ -25645,7 +25671,7 @@ var VoiceChatPlugin = class _VoiceChatPlugin {
|
|
|
25645
25671
|
- \u5982\u679C\u5B9E\u5728\u9700\u8981\u67E5\uFF1A\u5148\u8BF4"\u7B49\u6211\u67E5\u4E0B"\u5E76\u6781\u7B80\u8C03\u7528\uFF0C\u67E5\u5B8C\u7ACB\u523B\u603B\u7ED3\u6210\u4E00\u53E5\u8BDD`;
|
|
25646
25672
|
const engine = new QueryEngine(llmProvider, {
|
|
25647
25673
|
model: modelId,
|
|
25648
|
-
systemPrompt: (ctx.deps.systemPrompt
|
|
25674
|
+
systemPrompt: resolveSystemPrompt(ctx.deps.systemPrompt) + voiceChatRules,
|
|
25649
25675
|
maxTokens: 4096,
|
|
25650
25676
|
temperature: 0.7,
|
|
25651
25677
|
disableThinking: !this.config.thinking,
|
|
@@ -29855,8 +29881,8 @@ registerCommand({
|
|
|
29855
29881
|
sessionManager: deps.sessions,
|
|
29856
29882
|
sessionId: sid,
|
|
29857
29883
|
model: deps.config.model,
|
|
29858
|
-
contextWindow: deps.compactConfig.contextWindow || 2e5,
|
|
29859
|
-
systemPrompt: deps.systemPrompt,
|
|
29884
|
+
contextWindow: (typeof deps.compactConfig === "function" ? deps.compactConfig() : deps.compactConfig).contextWindow || 2e5,
|
|
29885
|
+
systemPrompt: resolveSystemPrompt(deps.systemPrompt),
|
|
29860
29886
|
toolDefs: registry.definitions(),
|
|
29861
29887
|
workspace: deps.config.workspace
|
|
29862
29888
|
});
|
|
@@ -29904,7 +29930,7 @@ ${question}`;
|
|
|
29904
29930
|
const stream = deps.provider.streamChat({
|
|
29905
29931
|
model: deps.config.model,
|
|
29906
29932
|
messages: [{ role: "user", content: wrappedQuestion }],
|
|
29907
|
-
systemPrompt: deps.systemPrompt,
|
|
29933
|
+
systemPrompt: resolveSystemPrompt(deps.systemPrompt),
|
|
29908
29934
|
maxTokens: 2048,
|
|
29909
29935
|
signal: void 0
|
|
29910
29936
|
});
|