diff --git a/lib/index.js b/lib/index.js index ba51575..0a06a33 100644 --- a/lib/index.js +++ b/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; }, diff --git a/package.json b/package.json index 776d8fe..f4c33de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dsh-netxops", - "version": "0.1.9", + "version": "0.1.10", "description": "DeepSeek Harness Netx Ops: host bridge + Plugins settings card + agent preset", "license": "MIT", "type": "module", diff --git a/src/index.ts b/src/index.ts index c0707d3..d241200 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,7 +13,7 @@ import type { Context, Fiber } from '@deepseek-ai/cordis' import z from '@deepseek-ai/schemastery' import { credentialRef } 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 * as McpClient from '@deepseek-ai/dsh-mcp-client' @@ -64,6 +64,38 @@ async function resolveToken(ctx: Context, refName: string): Promise { 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, + 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. */ @@ -119,10 +151,7 @@ export function apply(ctx: Context, config: Config = Config({})): void { // Composition defaults first (works even when settings provider is absent). remount() - // Shipped dsh 0.1.1-rc.2 exports the standalone helper; SettingsProvider has - // 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, { + installNetxopsSettings(ctx, config, { setSource: (current) => { source = current },