mirror of
https://github.com/hansjone/netxops.git
synced 2026-10-09 05:10:45 +08:00
Support both dsh settings APIs for the netxops namespace.
0.1.1-rc.2 uses installSettingsSection; 0.1.2+ uses settings.installSection — detect at runtime so global and source dsh both boot. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
ca91031fd0
commit
4854101afd
3 changed files with 47 additions and 8 deletions
14
lib/index.js
14
lib/index.js
|
|
@ -1,7 +1,7 @@
|
|||
// src/index.ts
|
||||
import z from "@deepseek-ai/schemastery";
|
||||
import { credentialRef } from "@deepseek-ai/dsh-credentials";
|
||||
import { installSettingsSection } from "@deepseek-ai/dsh-settings";
|
||||
import * as DshSettings from "@deepseek-ai/dsh-settings";
|
||||
import * as McpClient from "@deepseek-ai/dsh-mcp-client";
|
||||
var name = "netxops";
|
||||
var inject = ["tools"];
|
||||
|
|
@ -22,6 +22,16 @@ async function resolveToken(ctx, refName) {
|
|||
const hit = await credentials.resolve(credentialRef(refName));
|
||||
return hit?.value ?? "";
|
||||
}
|
||||
function installNetxopsSettings(ctx, entry, hooks) {
|
||||
const legacy = DshSettings.installSettingsSection;
|
||||
if (typeof legacy === "function") {
|
||||
legacy(ctx, NETXOPS_SETTINGS_NAMESPACE, Config2, entry, hooks);
|
||||
return;
|
||||
}
|
||||
ctx.inject(["settings"], (settingsCtx) => {
|
||||
settingsCtx.settings.installSection(ctx, NETXOPS_SETTINGS_NAMESPACE, Config2, entry, hooks);
|
||||
});
|
||||
}
|
||||
function apply(ctx, config = Config2({})) {
|
||||
let source = () => config;
|
||||
let mcpFiber;
|
||||
|
|
@ -70,7 +80,7 @@ function apply(ctx, config = Config2({})) {
|
|||
});
|
||||
};
|
||||
remount();
|
||||
installSettingsSection(ctx, NETXOPS_SETTINGS_NAMESPACE, Config2, config, {
|
||||
installNetxopsSettings(ctx, config, {
|
||||
setSource: (current) => {
|
||||
source = current;
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue