mirror of
https://github.com/hansjone/netxops.git
synced 2026-10-09 05:10:45 +08:00
Merge nms+common into ops so login questions load execManagedNe.
One capability group now ships netx-ops (alarms + managed CLI + paths); keep tools-nms/common as aliases. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
6e591be2b5
commit
63f88bdf6c
33 changed files with 2133 additions and 446 deletions
|
|
@ -1,6 +1,5 @@
|
|||
/**
|
||||
* Forced common-group tools + skill (native managed CLI + findTopologyPaths).
|
||||
*
|
||||
* @deprecated Use `dsh-netxops/tools-ops`. Alias that still forces the ops group.
|
||||
* @module dsh-netxops/tools-common
|
||||
*/
|
||||
|
||||
|
|
@ -11,5 +10,5 @@ export const name = 'netxops-tools-common'
|
|||
export const inject = ['tools']
|
||||
|
||||
export function apply(ctx: Context): void {
|
||||
applyGroupToolsPlugin(ctx, { name, mode: 'forced', only: ['common'] })
|
||||
applyGroupToolsPlugin(ctx, { name, mode: 'forced', only: ['ops'] })
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
/**
|
||||
* Forced nms-group tools + skill (vendor NMS adapter; current provider zte-ume).
|
||||
* Mount this export in any agent preset that needs NMS alarms/inventory.
|
||||
*
|
||||
* @deprecated Use `dsh-netxops/tools-ops`. Alias that still forces the ops group.
|
||||
* @module dsh-netxops/tools-nms
|
||||
*/
|
||||
|
||||
|
|
@ -12,5 +10,5 @@ export const name = 'netxops-tools-nms'
|
|||
export const inject = ['tools']
|
||||
|
||||
export function apply(ctx: Context): void {
|
||||
applyGroupToolsPlugin(ctx, { name, mode: 'forced', only: ['nms'] })
|
||||
applyGroupToolsPlugin(ctx, { name, mode: 'forced', only: ['ops'] })
|
||||
}
|
||||
|
|
|
|||
15
src/agent-tools-ops.ts
Normal file
15
src/agent-tools-ops.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* Forced ops-group tools + skill (NMS + managed CLI + paths).
|
||||
*
|
||||
* @module dsh-netxops/tools-ops
|
||||
*/
|
||||
|
||||
import type { Context } from '@deepseek-ai/cordis'
|
||||
import { applyGroupToolsPlugin } from './netx/group-tools-plugin.ts'
|
||||
|
||||
export const name = 'netxops-tools-ops'
|
||||
export const inject = ['tools']
|
||||
|
||||
export function apply(ctx: Context): void {
|
||||
applyGroupToolsPlugin(ctx, { name, mode: 'forced', only: ['ops'] })
|
||||
}
|
||||
|
|
@ -364,31 +364,17 @@ export function NetxopsCard(props: NetxopsCardProps) {
|
|||
</div>
|
||||
<p className="dsh-nx-hint">{t('capabilityGroupsHint')}</p>
|
||||
<CapabilityGroupBlock
|
||||
title={t('groupNms')}
|
||||
title={t('groupOps')}
|
||||
inPresetLabel={t('groupInPreset')}
|
||||
publicLabel={t('groupPublic')}
|
||||
inPreset={state.groupNmsInPreset}
|
||||
published={state.groupNmsPublic}
|
||||
inPreset={state.groupOpsInPreset}
|
||||
published={state.groupOpsPublic}
|
||||
disabled={disabled}
|
||||
onEditInPreset={(checked) => {
|
||||
props.edit('groupNmsInPreset', checked ? 'true' : 'false')
|
||||
props.edit('groupOpsInPreset', checked ? 'true' : 'false')
|
||||
}}
|
||||
onEditPublic={(checked) => {
|
||||
props.edit('groupNmsPublic', checked ? 'true' : 'false')
|
||||
}}
|
||||
/>
|
||||
<CapabilityGroupBlock
|
||||
title={t('groupCommon')}
|
||||
inPresetLabel={t('groupInPreset')}
|
||||
publicLabel={t('groupPublic')}
|
||||
inPreset={state.groupCommonInPreset}
|
||||
published={state.groupCommonPublic}
|
||||
disabled={disabled}
|
||||
onEditInPreset={(checked) => {
|
||||
props.edit('groupCommonInPreset', checked ? 'true' : 'false')
|
||||
}}
|
||||
onEditPublic={(checked) => {
|
||||
props.edit('groupCommonPublic', checked ? 'true' : 'false')
|
||||
props.edit('groupOpsPublic', checked ? 'true' : 'false')
|
||||
}}
|
||||
/>
|
||||
<CapabilityGroupBlock
|
||||
|
|
|
|||
|
|
@ -35,10 +35,8 @@ export interface NetxopsSettings {
|
|||
alarmDeliverIm?: boolean
|
||||
imBotId?: string
|
||||
imTargetId?: string
|
||||
groupNmsInPreset?: boolean
|
||||
groupNmsPublic?: boolean
|
||||
groupCommonInPreset?: boolean
|
||||
groupCommonPublic?: boolean
|
||||
groupOpsInPreset?: boolean
|
||||
groupOpsPublic?: boolean
|
||||
groupTopologyInPreset?: boolean
|
||||
groupTopologyPublic?: boolean
|
||||
nmsProvider?: string
|
||||
|
|
@ -54,10 +52,8 @@ interface CredentialState {
|
|||
export interface NetxopsCardState extends CardShell {
|
||||
apiUrl: CardFieldState
|
||||
lang: CardFieldState
|
||||
groupNmsInPreset: CardFieldState
|
||||
groupNmsPublic: CardFieldState
|
||||
groupCommonInPreset: CardFieldState
|
||||
groupCommonPublic: CardFieldState
|
||||
groupOpsInPreset: CardFieldState
|
||||
groupOpsPublic: CardFieldState
|
||||
groupTopologyInPreset: CardFieldState
|
||||
groupTopologyPublic: CardFieldState
|
||||
nmsProvider: CardFieldState
|
||||
|
|
@ -113,10 +109,8 @@ export class NetxopsCardController {
|
|||
textField('apiUrl'),
|
||||
textField('lang'),
|
||||
textField('nmsProvider'),
|
||||
booleanFieldPersistFalse('groupNmsInPreset'),
|
||||
booleanField('groupNmsPublic'),
|
||||
booleanFieldPersistFalse('groupCommonInPreset'),
|
||||
booleanField('groupCommonPublic'),
|
||||
booleanFieldPersistFalse('groupOpsInPreset'),
|
||||
booleanField('groupOpsPublic'),
|
||||
booleanField('groupTopologyInPreset'),
|
||||
booleanField('groupTopologyPublic'),
|
||||
booleanField('alarmPushEnabled'),
|
||||
|
|
@ -244,10 +238,8 @@ export class NetxopsCardController {
|
|||
apiUrl: this.form.field('apiUrl'),
|
||||
lang: this.form.field('lang'),
|
||||
nmsProvider: this.form.field('nmsProvider'),
|
||||
groupNmsInPreset: this.form.field('groupNmsInPreset'),
|
||||
groupNmsPublic: this.form.field('groupNmsPublic'),
|
||||
groupCommonInPreset: this.form.field('groupCommonInPreset'),
|
||||
groupCommonPublic: this.form.field('groupCommonPublic'),
|
||||
groupOpsInPreset: this.form.field('groupOpsInPreset'),
|
||||
groupOpsPublic: this.form.field('groupOpsPublic'),
|
||||
groupTopologyInPreset: this.form.field('groupTopologyInPreset'),
|
||||
groupTopologyPublic: this.form.field('groupTopologyPublic'),
|
||||
alarmPushEnabled: this.form.field('alarmPushEnabled'),
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ export type NetxopsLocaleKey =
|
|||
| 'capabilityGroupsHint'
|
||||
| 'nmsProvider'
|
||||
| 'nmsProviderHint'
|
||||
| 'groupNms'
|
||||
| 'groupCommon'
|
||||
| 'groupOps'
|
||||
| 'groupTopology'
|
||||
| 'groupInPreset'
|
||||
| 'groupPublic'
|
||||
|
|
@ -58,17 +57,16 @@ export type NetxopsLocaleKey =
|
|||
|
||||
export const en: Record<NetxopsLocaleKey, string> = {
|
||||
title: 'Netx Ops',
|
||||
description: 'netx API, bearer token, and capability groups (nms / common / topology).',
|
||||
description: 'netx API, bearer token, and capability groups (ops / topology).',
|
||||
apiUrl: 'API URL',
|
||||
apiUrlHint: 'netx REST root, e.g. http://127.0.0.1:8890 (also used for alarm subscribe)',
|
||||
lang: 'Language',
|
||||
langHint: 'Response language hint (zh / en).',
|
||||
capabilityGroups: 'Capability groups',
|
||||
capabilityGroupsHint: 'One group ↔ one skill (netx-nms / netx-common / netx-topology). Defaults: nms + common in preset; topology and all public off. Save, then open a new session. Other agents can mount dsh-netxops/tools-nms|common|topology.',
|
||||
capabilityGroupsHint: 'One group ↔ one skill. ops = netx-ops (alarms + CLI login + paths); topology = netx-topology. Defaults: ops on; topology and public off. New sessions after save. Other agents: dsh-netxops/tools-ops|topology.',
|
||||
nmsProvider: 'nms provider',
|
||||
nmsProviderHint: 'Vendor adapter id. Supported today: zte-ume (REST still /v1/ume/*; model tools are netx__*Nms*).',
|
||||
groupNms: 'nms — skill netx-nms (alarms / inventory / SQL)',
|
||||
groupCommon: 'common — skill netx-common (managed CLI + findTopologyPaths)',
|
||||
groupOps: 'ops — skill netx-ops (NMS alarms/inventory + managed CLI login + paths)',
|
||||
groupTopology: 'topology — skill netx-topology (canvas / fabric / dual_unit)',
|
||||
groupInPreset: 'In Netx Ops preset',
|
||||
groupPublic: 'Publish to other presets',
|
||||
|
|
@ -115,17 +113,16 @@ export const en: Record<NetxopsLocaleKey, string> = {
|
|||
|
||||
export const zh: Record<NetxopsLocaleKey, string> = {
|
||||
title: 'Netx Ops',
|
||||
description: 'netx API、Bearer Token,以及能力组(nms / common / topology)。',
|
||||
description: 'netx API、Bearer Token,以及能力组(ops / topology)。',
|
||||
apiUrl: 'API 地址',
|
||||
apiUrlHint: 'netx REST 根地址,例如 http://127.0.0.1:8890(告警订阅复用同一地址)',
|
||||
lang: '语言',
|
||||
langHint: '响应语言提示(zh / en)。',
|
||||
capabilityGroups: '能力组',
|
||||
capabilityGroupsHint: '一组一个 skill(netx-nms / netx-common / netx-topology)。默认:nms + common 进入预设;topology 与全部公开关闭。保存后请新开会话。其他 Agent 可挂 dsh-netxops/tools-nms|common|topology。',
|
||||
capabilityGroupsHint: '一组一个 skill。ops = netx-ops(告警 + 纳管登录 + 路径);topology = netx-topology。默认 ops 开;topology / 公开关。保存后新会话生效。其他 Agent:dsh-netxops/tools-ops|topology。',
|
||||
nmsProvider: 'nms provider',
|
||||
nmsProviderHint: '厂商适配器 id。当前支持:zte-ume(REST 仍为 /v1/ume/*;模型工具名为 netx__*Nms*)。',
|
||||
groupNms: 'nms — skill netx-nms(告警 / 库存 / SQL)',
|
||||
groupCommon: 'common — skill netx-common(纳管 CLI + findTopologyPaths)',
|
||||
groupOps: 'ops — skill netx-ops(NMS 告警/库存 + 纳管 CLI 登录 + 路径)',
|
||||
groupTopology: 'topology — skill netx-topology(画布 / Fabric / dual_unit)',
|
||||
groupInPreset: '在 Netx Ops 预设中启用',
|
||||
groupPublic: '对其他预设公开',
|
||||
|
|
|
|||
18
src/index.ts
18
src/index.ts
|
|
@ -91,14 +91,10 @@ export interface Config {
|
|||
* (REST `/v1/ume/*`; model tools are generic `netx__*Nms*`).
|
||||
*/
|
||||
nmsProvider: string
|
||||
/** nms tools/skills in the Netx Ops preset (default on). */
|
||||
groupNmsInPreset: boolean
|
||||
/** Publish nms tools/skills to other presets via the host layer (default off). */
|
||||
groupNmsPublic: boolean
|
||||
/** common tools/skills in the Netx Ops preset (default on). */
|
||||
groupCommonInPreset: boolean
|
||||
/** Publish common tools/skills to other presets (default off). */
|
||||
groupCommonPublic: boolean
|
||||
/** ops tools/skills in the Netx Ops preset (default on) — NMS + CLI + paths. */
|
||||
groupOpsInPreset: boolean
|
||||
/** Publish ops tools/skills to other presets (default off). */
|
||||
groupOpsPublic: boolean
|
||||
/** topology canvas / layout tools in the Netx Ops preset (default off). */
|
||||
groupTopologyInPreset: boolean
|
||||
/** Publish topology tools/skills to other presets (default off). */
|
||||
|
|
@ -117,10 +113,8 @@ export const Config: z<Config> = z.object({
|
|||
imBotId: z.string().default(''),
|
||||
imTargetId: z.string().default(''),
|
||||
nmsProvider: z.string().default('zte-ume'),
|
||||
groupNmsInPreset: z.boolean().default(true),
|
||||
groupNmsPublic: z.boolean().default(false),
|
||||
groupCommonInPreset: z.boolean().default(true),
|
||||
groupCommonPublic: z.boolean().default(false),
|
||||
groupOpsInPreset: z.boolean().default(true),
|
||||
groupOpsPublic: z.boolean().default(false),
|
||||
groupTopologyInPreset: z.boolean().default(false),
|
||||
groupTopologyPublic: z.boolean().default(false),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -3,13 +3,12 @@
|
|||
*
|
||||
* Rule: **one group ↔ one skill** (dirs under `netx/skills/<group>/`).
|
||||
*
|
||||
* - `nms` → skill `netx-nms` — vendor NMS adapter (zte-ume behind generic names)
|
||||
* - `common` → skill `netx-common` — managed CLI + findTopologyPaths
|
||||
* - `topology` → skill `netx-topology` — canvas / fabric / dual_unit / layout recipes
|
||||
* - `ops` → skill `netx-ops` — NMS alarms/inventory/SQL + managed CLI + findTopologyPaths
|
||||
* - `topology` → skill `netx-topology` — canvas / fabric / dual_unit / layout
|
||||
*/
|
||||
|
||||
/** Stable group ids used in settings, skill dirs, and registration filters. */
|
||||
export type NetxCapabilityGroupId = 'nms' | 'common' | 'topology'
|
||||
export type NetxCapabilityGroupId = 'ops' | 'topology'
|
||||
|
||||
/** Per-group exposure knobs. */
|
||||
export interface NetxGroupExposure {
|
||||
|
|
@ -24,29 +23,26 @@ export type NetxCapabilityGroups = Record<NetxCapabilityGroupId, NetxGroupExposu
|
|||
|
||||
/** Flat settings fields (Plugins card + schemastery Config). */
|
||||
export interface NetxCapabilityGroupSettingsFields {
|
||||
groupNmsInPreset: boolean
|
||||
groupNmsPublic: boolean
|
||||
groupCommonInPreset: boolean
|
||||
groupCommonPublic: boolean
|
||||
groupOpsInPreset: boolean
|
||||
groupOpsPublic: boolean
|
||||
groupTopologyInPreset: boolean
|
||||
groupTopologyPublic: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Default: nms + common in Ops preset; topology and all public off.
|
||||
* Default: ops in Ops preset; topology and all public off.
|
||||
*/
|
||||
export const DEFAULT_CAPABILITY_GROUPS: NetxCapabilityGroups = Object.freeze({
|
||||
nms: Object.freeze({ inPreset: true, public: false }),
|
||||
common: Object.freeze({ inPreset: true, public: false }),
|
||||
ops: Object.freeze({ inPreset: true, public: false }),
|
||||
topology: Object.freeze({ inPreset: false, public: false }),
|
||||
})
|
||||
|
||||
/**
|
||||
* Model-facing tool names (`netx__*`) owned by each group.
|
||||
* nms tools use generic `Nms` names; HTTP still hits the configured NMS provider adapter.
|
||||
* NMS tools use generic `Nms` names; HTTP still hits the configured NMS provider adapter.
|
||||
*/
|
||||
export const TOOLS_BY_GROUP: Readonly<Record<NetxCapabilityGroupId, readonly string[]>> = Object.freeze({
|
||||
nms: Object.freeze([
|
||||
ops: Object.freeze([
|
||||
'netx__queryNmsAlarms',
|
||||
'netx__aggregateNmsAlarms',
|
||||
'netx__runNmsDiagnostics',
|
||||
|
|
@ -56,8 +52,6 @@ export const TOOLS_BY_GROUP: Readonly<Record<NetxCapabilityGroupId, readonly str
|
|||
'netx__aggregateNmsAlarmsRaw',
|
||||
'netx__listNmsAlarmFields',
|
||||
'netx__sqlQueryNms',
|
||||
]),
|
||||
common: Object.freeze([
|
||||
'netx__listManagedNe',
|
||||
'netx__getManagedNe',
|
||||
'netx__execManagedNe',
|
||||
|
|
@ -86,24 +80,29 @@ export const TOOLS_BY_GROUP: Readonly<Record<NetxCapabilityGroupId, readonly str
|
|||
|
||||
/** Skill directory name under skills root / `presets/netxops/skills/<group>/`. */
|
||||
export const SKILL_DIR_BY_GROUP: Readonly<Record<NetxCapabilityGroupId, string>> = Object.freeze({
|
||||
nms: 'nms',
|
||||
common: 'common',
|
||||
ops: 'ops',
|
||||
topology: 'topology',
|
||||
})
|
||||
|
||||
export const CAPABILITY_GROUP_IDS: readonly NetxCapabilityGroupId[] = Object.freeze([
|
||||
'nms',
|
||||
'common',
|
||||
'ops',
|
||||
'topology',
|
||||
])
|
||||
|
||||
/**
|
||||
* Build group policy from flat settings / Config fields.
|
||||
* Accepts legacy `groupManagedNe*` as aliases of `groupCommon*`.
|
||||
* Legacy `groupTopologyLayout*` ORs into `topology` (layout tools now live in topology).
|
||||
*
|
||||
* Legacy aliases (all map into `ops`):
|
||||
* - `groupNms*` / `groupCommon*` / `groupManagedNe*`
|
||||
*
|
||||
* Legacy `groupTopologyLayout*` ORs into `topology`.
|
||||
*/
|
||||
export function capabilityGroupsFromSettings(
|
||||
fields: Partial<NetxCapabilityGroupSettingsFields & {
|
||||
groupNmsInPreset?: boolean
|
||||
groupNmsPublic?: boolean
|
||||
groupCommonInPreset?: boolean
|
||||
groupCommonPublic?: boolean
|
||||
groupManagedNeInPreset?: boolean
|
||||
groupManagedNePublic?: boolean
|
||||
groupTopologyLayoutInPreset?: boolean
|
||||
|
|
@ -111,19 +110,29 @@ export function capabilityGroupsFromSettings(
|
|||
}> | null | undefined,
|
||||
): NetxCapabilityGroups {
|
||||
const src = fields ?? {}
|
||||
const commonInPreset = src.groupCommonInPreset !== undefined
|
||||
? src.groupCommonInPreset !== false
|
||||
: src.groupManagedNeInPreset !== false
|
||||
const commonPublic = src.groupCommonPublic === true
|
||||
|| src.groupManagedNePublic === true
|
||||
|
||||
let opsInPreset = true
|
||||
if (src.groupOpsInPreset !== undefined) {
|
||||
opsInPreset = src.groupOpsInPreset !== false
|
||||
} else {
|
||||
const legacy = [
|
||||
src.groupNmsInPreset,
|
||||
src.groupCommonInPreset,
|
||||
src.groupManagedNeInPreset,
|
||||
].filter((v): v is boolean => v !== undefined)
|
||||
if (legacy.length > 0) {
|
||||
// Any explicit true → on; all explicit false → off.
|
||||
opsInPreset = legacy.some((v) => v === true)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
nms: {
|
||||
inPreset: src.groupNmsInPreset !== false,
|
||||
public: src.groupNmsPublic === true,
|
||||
},
|
||||
common: {
|
||||
inPreset: commonInPreset,
|
||||
public: commonPublic,
|
||||
ops: {
|
||||
inPreset: opsInPreset,
|
||||
public: src.groupOpsPublic === true
|
||||
|| src.groupNmsPublic === true
|
||||
|| src.groupCommonPublic === true
|
||||
|| src.groupManagedNePublic === true,
|
||||
},
|
||||
topology: {
|
||||
inPreset: src.groupTopologyInPreset === true
|
||||
|
|
@ -136,9 +145,6 @@ export function capabilityGroupsFromSettings(
|
|||
|
||||
/**
|
||||
* Groups enabled for one registration plane.
|
||||
* @param groups - published policy.
|
||||
* @param plane - preset scope vs host public layer.
|
||||
* @param only - when set, intersect with this allow-list (per-export tools packages).
|
||||
*/
|
||||
export function groupsForPlane(
|
||||
groups: NetxCapabilityGroups | undefined,
|
||||
|
|
@ -155,13 +161,16 @@ export function groupsForPlane(
|
|||
}
|
||||
|
||||
/**
|
||||
* Force-enable the listed groups (for `dsh-netxops/tools-<group>` mounts that
|
||||
* intentionally ignore Ops-preset inPreset flags).
|
||||
* Force-enable the listed groups (for `dsh-netxops/tools-<group>` mounts).
|
||||
* Legacy `nms` / `common` aliases resolve to `ops`.
|
||||
*/
|
||||
export function groupsForced(
|
||||
only: readonly NetxCapabilityGroupId[],
|
||||
only: readonly (NetxCapabilityGroupId | 'nms' | 'common')[],
|
||||
): NetxCapabilityGroupId[] {
|
||||
return CAPABILITY_GROUP_IDS.filter((id) => only.includes(id))
|
||||
const normalized = only.map((id) => (
|
||||
id === 'nms' || id === 'common' ? 'ops' as const : id
|
||||
))
|
||||
return CAPABILITY_GROUP_IDS.filter((id) => normalized.includes(id))
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue