Fix Netx Ops preset and settings for DSH 0.2.0-rc.2.

Ship a declarative @deepseek-ai/dsh-agent-preset patch (directory discovery is dead) and register the settings card on plugins.item via configForms.whileServed while keeping settings.section for older shells.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-10-09 17:04:12 +08:00
parent 9b8e873c18
commit 5dcce3c749
8 changed files with 651 additions and 150 deletions

View file

@ -2631,6 +2631,12 @@ var inject = [
"slots",
"locale"
];
function entryIdOf(ctx) {
const fiber = ctx.fiber?.entry;
const raw = fiber?.options?.id ?? fiber?.id ?? ctx.name ?? NETXOPS_NS;
const id = String(raw).replace(/^:/, "").trim();
return id.length > 0 ? id : NETXOPS_NS;
}
function apply(ctx) {
ctx.effect(() => {
try {
@ -2645,77 +2651,136 @@ function apply(ctx) {
}
}, "netxops: locales");
const t = ctx.locale.bind(LOCALE_NS);
let mounted = false;
const mountCard = (scope) => {
if (mounted)
return;
mounted = true;
const card = new NetxopsCardController(scope, ctx);
ctx.inject(["remote.credentials"], (credCtx) => {
card.setCredentialsAvailable(true);
credCtx.effect(() => {
const off = credCtx.remote.$on("credentials/reference-updated", (ref) => {
card.refreshCredential(String(ref));
});
return () => {
off();
card.setCredentialsAvailable(false);
};
}, "netxops: credential invalidations");
});
ctx.inject(["connection"], (connCtx) => {
const call = connCtx.connection?.rpc?.call?.bind(connCtx.connection.rpc);
if (typeof call !== "function") {
connCtx.logger.warn("netxops: connection.rpc.call unavailable — alarm status UI disabled");
return;
}
card.setAlarmPushRpc(call);
connCtx.effect(() => () => {
card.setAlarmPushRpc(undefined);
}, "netxops: clear alarm-push rpc");
});
const bindDirectoryPicker = (picker) => {
if (!picker || typeof picker.pick !== "function")
return;
card.setDirectoryPicker(picker);
};
bindDirectoryPicker(ctx.remote?.directoryPicker);
ctx.inject(["remote.directoryPicker"], (dpCtx) => {
const viaGet = typeof dpCtx.get === "function" ? dpCtx.get("remote.directoryPicker") : undefined;
const viaNested = dpCtx.remote?.directoryPicker;
bindDirectoryPicker(viaGet ?? viaNested);
dpCtx.effect(() => () => {
card.setDirectoryPicker(undefined);
}, "netxops: clear directory picker");
});
ctx.slots.inject("settings.section", () => ctx.slots.register({
name: "settings.section",
id: NETXOPS_NS,
order: 24,
label: () => t("title"),
locale: LOCALE_NS,
inject: () => card.inject()
}, NetxopsCard));
let card;
let wiredExtras = false;
const ensureCard = (scope) => {
if (card)
return card;
card = new NetxopsCardController(scope, ctx);
if (!wiredExtras) {
wiredExtras = true;
wireOptionalServices(ctx, card);
}
return card;
};
const registerSection = (owner) => {
try {
return ctx.slots.inject("settings.section", () => ctx.slots.register({
name: "settings.section",
id: NETXOPS_NS,
order: 24,
label: () => t("title"),
locale: LOCALE_NS,
inject: () => owner.inject()
}, NetxopsCard));
} catch (error) {
ctx.logger?.warn?.("netxops: settings.section unavailable: %s", error);
return () => {};
}
};
const registerPluginsItem = (owner, id) => {
try {
return ctx.slots.inject("plugins.item", () => ctx.slots.register({
name: "plugins.item",
id,
order: 24,
label: () => t("title"),
locale: LOCALE_NS,
inject: () => owner.inject()
}, NetxopsCard));
} catch (error) {
ctx.logger?.warn?.("netxops: plugins.item unavailable: %s", error);
return () => {};
}
};
ctx.inject(["configForms"], (formsCtx) => {
const forms = formsCtx.configForms;
if (!forms || typeof forms.get !== "function") {
formsCtx.logger?.warn?.("netxops: configForms present but .get missing");
if (!forms) {
formsCtx.logger?.warn?.("netxops: configForms inject fired but service missing");
return;
}
formsCtx.logger?.info?.("netxops: settings card via configForms");
mountCard(forms.get(NETXOPS_NS));
const entryId = entryIdOf(formsCtx);
const ns = entryId || NETXOPS_NS;
if (typeof forms.whileServed === "function" && typeof forms.get === "function") {
formsCtx.logger?.info?.("netxops: settings card via configForms.whileServed (%s)", ns);
formsCtx.effect(() => forms.whileServed([ns], (served) => {
if (!served.has(ns))
return () => {};
const owner = ensureCard(forms.get(ns));
const offItem = registerPluginsItem(owner, ns);
const offSection = registerSection(owner);
return () => {
offItem();
offSection();
};
}), "netxops: plugins.item whileServed");
return;
}
if (typeof forms.get === "function") {
formsCtx.logger?.info?.("netxops: settings card via configForms.get (%s)", ns);
const owner = ensureCard(forms.get(ns));
formsCtx.effect(() => {
const offItem = registerPluginsItem(owner, ns);
const offSection = registerSection(owner);
return () => {
offItem();
offSection();
};
}, "netxops: configForms slots");
} else {
formsCtx.logger?.warn?.("netxops: configForms present but .get missing");
}
});
ctx.inject(["settingsScope"], (scopeCtx) => {
if (card)
return;
const binder = scopeCtx.settingsScope;
if (!binder || typeof binder.bind !== "function") {
scopeCtx.logger?.warn?.("netxops: settingsScope present but .bind missing");
return;
}
if (mounted)
return;
scopeCtx.logger?.info?.("netxops: settings card via settingsScope");
mountCard(binder.bind({ namespace: NETXOPS_NS }));
const owner = ensureCard(binder.bind({ namespace: NETXOPS_NS }));
scopeCtx.effect(() => registerSection(owner), "netxops: settings.section");
});
}
function wireOptionalServices(ctx, card) {
ctx.inject(["remote.credentials"], (credCtx) => {
card.setCredentialsAvailable(true);
credCtx.effect(() => {
const off = credCtx.remote.$on("credentials/reference-updated", (ref) => {
card.refreshCredential(String(ref));
});
return () => {
off();
card.setCredentialsAvailable(false);
};
}, "netxops: credential invalidations");
});
ctx.inject(["connection"], (connCtx) => {
const call = connCtx.connection?.rpc?.call?.bind(connCtx.connection.rpc);
if (typeof call !== "function") {
connCtx.logger.warn("netxops: connection.rpc.call unavailable — alarm status UI disabled");
return;
}
card.setAlarmPushRpc(call);
connCtx.effect(() => () => {
card.setAlarmPushRpc(undefined);
}, "netxops: clear alarm-push rpc");
});
const bindDirectoryPicker = (picker) => {
if (!picker || typeof picker.pick !== "function")
return;
card.setDirectoryPicker(picker);
};
bindDirectoryPicker(ctx.remote?.directoryPicker);
ctx.inject(["remote.directoryPicker"], (dpCtx) => {
const viaGet = typeof dpCtx.get === "function" ? dpCtx.get("remote.directoryPicker") : undefined;
const viaNested = dpCtx.remote?.directoryPicker;
bindDirectoryPicker(viaGet ?? viaNested);
dpCtx.effect(() => () => {
card.setDirectoryPicker(undefined);
}, "netxops: clear directory picker");
});
}