dsh-lark-bot 0.15.7 → 0.15.8
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 +51 -10
- package/dist/cli.js.map +1 -1
- package/dist/plugin.d.ts +6 -0
- package/dist/plugin.js +51 -10
- package/dist/plugin.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4514,14 +4514,42 @@ function normalizeBaseUrl(url) {
|
|
|
4514
4514
|
throw new Error(`baseURL \u4EC5\u652F\u6301 http/https\uFF1A${url}`);
|
|
4515
4515
|
}
|
|
4516
4516
|
validateBaseUrl(url);
|
|
4517
|
-
const pathname = parsed.pathname
|
|
4518
|
-
if (pathname === ""
|
|
4517
|
+
const pathname = stripApiOperationSuffix(parsed.pathname);
|
|
4518
|
+
if (pathname === "") {
|
|
4519
4519
|
parsed.pathname = "/v1";
|
|
4520
4520
|
} else {
|
|
4521
4521
|
parsed.pathname = pathname;
|
|
4522
4522
|
}
|
|
4523
4523
|
return parsed.toString();
|
|
4524
4524
|
}
|
|
4525
|
+
function normalizeDeepseekBaseUrl(url) {
|
|
4526
|
+
let parsed;
|
|
4527
|
+
try {
|
|
4528
|
+
parsed = new URL(url);
|
|
4529
|
+
} catch {
|
|
4530
|
+
throw new Error(`baseURL \u4E0D\u662F\u5408\u6CD5 URL\uFF1A${url}`);
|
|
4531
|
+
}
|
|
4532
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
4533
|
+
throw new Error(`baseURL \u4EC5\u652F\u6301 http/https\uFF1A${url}`);
|
|
4534
|
+
}
|
|
4535
|
+
validateBaseUrl(url);
|
|
4536
|
+
const pathname = stripApiOperationSuffix(parsed.pathname);
|
|
4537
|
+
if (pathname === "" || pathname === "/") {
|
|
4538
|
+
return parsed.origin;
|
|
4539
|
+
}
|
|
4540
|
+
parsed.pathname = pathname;
|
|
4541
|
+
return parsed.toString();
|
|
4542
|
+
}
|
|
4543
|
+
var API_OPERATION_SUFFIXES = ["/chat/completions", "/responses", "/messages"];
|
|
4544
|
+
function stripApiOperationSuffix(pathname) {
|
|
4545
|
+
const trimmed = pathname.replace(/\/+$/, "");
|
|
4546
|
+
for (const suffix of API_OPERATION_SUFFIXES) {
|
|
4547
|
+
if (trimmed.endsWith(suffix)) {
|
|
4548
|
+
return trimmed.slice(0, trimmed.length - suffix.length).replace(/\/+$/, "");
|
|
4549
|
+
}
|
|
4550
|
+
}
|
|
4551
|
+
return trimmed;
|
|
4552
|
+
}
|
|
4525
4553
|
function validateBaseUrl(url) {
|
|
4526
4554
|
let parsed;
|
|
4527
4555
|
try {
|
|
@@ -4720,8 +4748,7 @@ var DshProviderManager = class {
|
|
|
4720
4748
|
const current = isMapLike(settings[DEEPSEEK_NAMESPACE]) ? settings[DEEPSEEK_NAMESPACE] : {};
|
|
4721
4749
|
const section = { ...current };
|
|
4722
4750
|
if (input.baseURL !== void 0) {
|
|
4723
|
-
|
|
4724
|
-
section.baseURL = input.baseURL;
|
|
4751
|
+
section.baseURL = normalizeDeepseekBaseUrl(input.baseURL);
|
|
4725
4752
|
}
|
|
4726
4753
|
if (input.apiKeyEnv !== void 0) section.apiKeyEnv = input.apiKeyEnv;
|
|
4727
4754
|
if (input.apiKey !== void 0) {
|
|
@@ -5057,7 +5084,11 @@ async function handleModel(args, ctx) {
|
|
|
5057
5084
|
}
|
|
5058
5085
|
if (!requireAdmin(ctx)) return;
|
|
5059
5086
|
await ctx.dshConfig.setDefaultModel(id);
|
|
5060
|
-
await
|
|
5087
|
+
await ctx.setDefaultModelPreference?.(id);
|
|
5088
|
+
await reply(
|
|
5089
|
+
ctx,
|
|
5090
|
+
`\u5DF2\u5199\u5165 dsh \u9ED8\u8BA4\u6A21\u578B\uFF08agent-default-model\uFF09\uFF1A\`${id}\`\uFF08\u540C\u65F6\u66F4\u65B0 profile \u9ED8\u8BA4\u6A21\u578B\uFF09\uFF0C\u65B0\u4F1A\u8BDD\u751F\u6548\u3002`
|
|
5091
|
+
);
|
|
5061
5092
|
return;
|
|
5062
5093
|
}
|
|
5063
5094
|
if (sub === "add" || sub === "remove") {
|
|
@@ -5506,7 +5537,7 @@ var FLOWS = {
|
|
|
5506
5537
|
kind: "text",
|
|
5507
5538
|
question: "Base URL",
|
|
5508
5539
|
placeholder: "https://www.kingapi.xyz",
|
|
5509
|
-
hint: "\u5F62\u5982 https://gateway.example/v1\uFF1B\u6839\u57DF\u540D\u4F1A\u81EA\u52A8\u8865\u5168 /v1",
|
|
5540
|
+
hint: "\u5F62\u5982 https://gateway.example/v1\uFF1B\u6839\u57DF\u540D\u4F1A\u81EA\u52A8\u8865\u5168 /v1\uFF0C\u8BEF\u586B /chat/completions \u7B49\u5B8C\u6574\u63A5\u53E3\u5730\u5740\u4F1A\u81EA\u52A8\u53BB\u6389\u672B\u5C3E\u8DEF\u5F84",
|
|
5510
5541
|
parse: (raw) => normalizeBaseUrl(asString(raw)?.trim() ?? "")
|
|
5511
5542
|
},
|
|
5512
5543
|
{
|
|
@@ -5660,8 +5691,7 @@ var FLOWS = {
|
|
|
5660
5691
|
const url = asString(raw)?.trim() ?? "";
|
|
5661
5692
|
if (!url) throw new Error("Base URL \u4E0D\u80FD\u4E3A\u7A7A");
|
|
5662
5693
|
if (asString(data.provider) === DEEPSEEK_PROVIDER) {
|
|
5663
|
-
|
|
5664
|
-
return url;
|
|
5694
|
+
return normalizeDeepseekBaseUrl(url);
|
|
5665
5695
|
}
|
|
5666
5696
|
return normalizeBaseUrl(url);
|
|
5667
5697
|
}
|
|
@@ -5874,7 +5904,8 @@ var FLOWS = {
|
|
|
5874
5904
|
summary: (_ctx, data) => Promise.resolve(`\u5C06\u5199\u5165 dsh \u9ED8\u8BA4\u6A21\u578B\uFF1A\`${asString(data.model)}\``),
|
|
5875
5905
|
execute: async (ctx, data) => {
|
|
5876
5906
|
await ctx.dshConfig.setDefaultModel(asString(data.model));
|
|
5877
|
-
|
|
5907
|
+
await ctx.setDefaultModelPreference?.(asString(data.model));
|
|
5908
|
+
return `\u5DF2\u5199\u5165 dsh \u9ED8\u8BA4\u6A21\u578B\uFF08agent-default-model\uFF09\uFF1A\`${asString(data.model)}\`\uFF08\u540C\u65F6\u66F4\u65B0 profile \u9ED8\u8BA4\u6A21\u578B\uFF09\uFF0C\u65B0\u4F1A\u8BDD\u751F\u6548\u3002`;
|
|
5878
5909
|
}
|
|
5879
5910
|
},
|
|
5880
5911
|
"key-set": {
|
|
@@ -7118,6 +7149,7 @@ async function startChannel(deps) {
|
|
|
7118
7149
|
channel: commandChannel,
|
|
7119
7150
|
defaultWorkspace: deps.defaultWorkspace,
|
|
7120
7151
|
defaultModel: deps.defaultModel,
|
|
7152
|
+
...deps.setDefaultModelPreference ? { setDefaultModelPreference: deps.setDefaultModelPreference } : {},
|
|
7121
7153
|
senderId: msg.senderId
|
|
7122
7154
|
};
|
|
7123
7155
|
const handled = await tryHandleCommand(msg.content, context).catch(async (error) => {
|
|
@@ -7235,7 +7267,8 @@ function wizardContextFor(event, deps, channel, scope) {
|
|
|
7235
7267
|
accessManager: deps.accessManager,
|
|
7236
7268
|
models: deps.models,
|
|
7237
7269
|
wizards: deps.wizardStore,
|
|
7238
|
-
defaultModel: deps.defaultModel
|
|
7270
|
+
defaultModel: deps.defaultModel,
|
|
7271
|
+
...deps.setDefaultModelPreference ? { setDefaultModelPreference: deps.setDefaultModelPreference } : {}
|
|
7239
7272
|
};
|
|
7240
7273
|
}
|
|
7241
7274
|
|
|
@@ -8649,6 +8682,14 @@ async function startBridgeEngine(options) {
|
|
|
8649
8682
|
dshConfig,
|
|
8650
8683
|
defaultRunTimeoutMs: activeProfile.preferences.runTimeoutMs ?? env.runTimeoutMs,
|
|
8651
8684
|
defaultModel: activeProfile.preferences.model ?? env.model,
|
|
8685
|
+
setDefaultModelPreference: async (model) => {
|
|
8686
|
+
await configStore.saveProfile(profileName, {
|
|
8687
|
+
tenant: activeProfile.tenant,
|
|
8688
|
+
appId: activeProfile.accounts.appId,
|
|
8689
|
+
appSecret: activeProfile.accounts.appSecret,
|
|
8690
|
+
model
|
|
8691
|
+
});
|
|
8692
|
+
},
|
|
8652
8693
|
accessManager: new AccessManager(configStore, profileName),
|
|
8653
8694
|
pending,
|
|
8654
8695
|
defaultWorkspace,
|