mirror of
https://github.com/hansjone/netxops.git
synced 2026-10-09 04:00:46 +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
|
// src/index.ts
|
||||||
import z from "@deepseek-ai/schemastery";
|
import z from "@deepseek-ai/schemastery";
|
||||||
import { credentialRef } from "@deepseek-ai/dsh-credentials";
|
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";
|
import * as McpClient from "@deepseek-ai/dsh-mcp-client";
|
||||||
var name = "netxops";
|
var name = "netxops";
|
||||||
var inject = ["tools"];
|
var inject = ["tools"];
|
||||||
|
|
@ -22,6 +22,16 @@ async function resolveToken(ctx, refName) {
|
||||||
const hit = await credentials.resolve(credentialRef(refName));
|
const hit = await credentials.resolve(credentialRef(refName));
|
||||||
return hit?.value ?? "";
|
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({})) {
|
function apply(ctx, config = Config2({})) {
|
||||||
let source = () => config;
|
let source = () => config;
|
||||||
let mcpFiber;
|
let mcpFiber;
|
||||||
|
|
@ -70,7 +80,7 @@ function apply(ctx, config = Config2({})) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
remount();
|
remount();
|
||||||
installSettingsSection(ctx, NETXOPS_SETTINGS_NAMESPACE, Config2, config, {
|
installNetxopsSettings(ctx, config, {
|
||||||
setSource: (current) => {
|
setSource: (current) => {
|
||||||
source = current;
|
source = current;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "dsh-netxops",
|
"name": "dsh-netxops",
|
||||||
"version": "0.1.9",
|
"version": "0.1.10",
|
||||||
"description": "DeepSeek Harness Netx Ops: host bridge + Plugins settings card + agent preset",
|
"description": "DeepSeek Harness Netx Ops: host bridge + Plugins settings card + agent preset",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|
|
||||||
39
src/index.ts
39
src/index.ts
|
|
@ -13,7 +13,7 @@ import type { Context, Fiber } from '@deepseek-ai/cordis'
|
||||||
import z from '@deepseek-ai/schemastery'
|
import z from '@deepseek-ai/schemastery'
|
||||||
import { credentialRef } from '@deepseek-ai/dsh-credentials'
|
import { credentialRef } from '@deepseek-ai/dsh-credentials'
|
||||||
import type {} from '@deepseek-ai/dsh-credentials'
|
import type {} from '@deepseek-ai/dsh-credentials'
|
||||||
import { installSettingsSection } from '@deepseek-ai/dsh-settings'
|
import * as DshSettings from '@deepseek-ai/dsh-settings'
|
||||||
import type {} from '@deepseek-ai/dsh-settings'
|
import type {} from '@deepseek-ai/dsh-settings'
|
||||||
import * as McpClient from '@deepseek-ai/dsh-mcp-client'
|
import * as McpClient from '@deepseek-ai/dsh-mcp-client'
|
||||||
|
|
||||||
|
|
@ -64,6 +64,38 @@ async function resolveToken(ctx: Context, refName: string): Promise<string> {
|
||||||
return hit?.value ?? ''
|
return hit?.value ?? ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the settings namespace on both dsh generations:
|
||||||
|
* - 0.1.1-rc.2: standalone `installSettingsSection`
|
||||||
|
* - ≥0.1.2-rc.1: `settings.installSection` on the provider
|
||||||
|
*/
|
||||||
|
function installNetxopsSettings(
|
||||||
|
ctx: Context,
|
||||||
|
entry: Config,
|
||||||
|
hooks: {
|
||||||
|
setSource: (current: () => Config) => void
|
||||||
|
onChange: () => void
|
||||||
|
},
|
||||||
|
): void {
|
||||||
|
const legacy = (DshSettings as {
|
||||||
|
installSettingsSection?: (
|
||||||
|
context: Context,
|
||||||
|
ns: string,
|
||||||
|
schema: z<Config>,
|
||||||
|
base: Config,
|
||||||
|
sectionHooks: typeof hooks,
|
||||||
|
) => void
|
||||||
|
}).installSettingsSection
|
||||||
|
if (typeof legacy === 'function') {
|
||||||
|
legacy(ctx, NETXOPS_SETTINGS_NAMESPACE, Config, entry, hooks)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.inject(['settings'], (settingsCtx) => {
|
||||||
|
settingsCtx.settings.installSection(ctx, NETXOPS_SETTINGS_NAMESPACE, Config, entry, hooks)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply the Netx Ops host bridge.
|
* Apply the Netx Ops host bridge.
|
||||||
*/
|
*/
|
||||||
|
|
@ -119,10 +151,7 @@ export function apply(ctx: Context, config: Config = Config({})): void {
|
||||||
// Composition defaults first (works even when settings provider is absent).
|
// Composition defaults first (works even when settings provider is absent).
|
||||||
remount()
|
remount()
|
||||||
|
|
||||||
// Shipped dsh 0.1.1-rc.2 exports the standalone helper; SettingsProvider has
|
installNetxopsSettings(ctx, config, {
|
||||||
// no `.installSection` method there. Newer cookbooks moved it onto the
|
|
||||||
// provider — keep the helper call so the Plugins tab can see `netxops`.
|
|
||||||
installSettingsSection(ctx, NETXOPS_SETTINGS_NAMESPACE, Config, config, {
|
|
||||||
setSource: (current) => {
|
setSource: (current) => {
|
||||||
source = current
|
source = current
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue