@johnny-joster/n9e-plugin 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,10 @@
2
2
  "permissions": {
3
3
  "allow": [
4
4
  "Bash(npx tsc:*)",
5
- "Bash(npm install)"
5
+ "Bash(npm install)",
6
+ "Bash(export KUBECONFIG=/Users/yaobinze/workarea/youdao/k8s/k8s-prod-maintain1)",
7
+ "Bash(kubectl get:*)",
8
+ "Bash(kubectl logs:*)"
6
9
  ]
7
10
  }
8
11
  }
package/index.ts CHANGED
@@ -17,13 +17,14 @@ import {
17
17
  } from "./src/tools/alert-mutes.ts";
18
18
 
19
19
  export default function(api: OpenClawPluginApi) {
20
- // Register tool: Query active alerts
21
- api.registerTool({
22
- name: "n9e_query_active_alerts",
23
- description: "查询夜莺平台当前活跃的告警事件。支持按严重级别(1=严重,2=警告,3=提示)、规则名称筛选。用于回答\"当前有哪些告警\"、\"最近的告警\"、\"有没有严重告警\"等问题。",
24
- inputSchema: activeAlertsToolInputSchema,
25
- handler: activeAlertsToolHandler
26
- });
20
+ try {
21
+ // Register tool: Query active alerts
22
+ api.registerTool({
23
+ name: "n9e_query_active_alerts",
24
+ description: "查询夜莺平台当前活跃的告警事件。支持按严重级别(1=严重,2=警告,3=提示)、规则名称筛选。用于回答\"当前有哪些告警\"、\"最近的告警\"、\"有没有严重告警\"等问题。",
25
+ inputSchema: activeAlertsToolInputSchema,
26
+ handler: activeAlertsToolHandler
27
+ });
27
28
 
28
29
  // Register tool: Query historical alerts
29
30
  api.registerTool({
@@ -50,4 +51,8 @@ export default function(api: OpenClawPluginApi) {
50
51
  });
51
52
 
52
53
  api.logger.info("N9e plugin loaded successfully");
54
+ } catch (error) {
55
+ api.logger.error("Failed to load N9e plugin:", error);
56
+ throw error;
57
+ }
53
58
  }
@@ -1,12 +1,10 @@
1
1
  {
2
2
  "id": "n9e-plugin",
3
- "skills": ["./skills"],
4
3
  "configSchema": {
5
4
  "type": "object",
6
5
  "properties": {
7
6
  "apiBaseUrl": {
8
7
  "type": "string",
9
- "format": "uri",
10
8
  "description": "夜莺API基础地址"
11
9
  },
12
10
  "apiKey": {
@@ -20,8 +18,7 @@
20
18
  "default": 30000,
21
19
  "description": "请求超时时间(毫秒)"
22
20
  }
23
- },
24
- "required": ["apiBaseUrl", "apiKey"]
21
+ }
25
22
  },
26
23
  "uiHints": {
27
24
  "apiBaseUrl": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnny-joster/n9e-plugin",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Nightingale alert platform query plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -32,12 +32,12 @@ export const activeAlertsToolInputSchema = {
32
32
  export const activeAlertsToolHandler: ToolHandler = async (input, context) => {
33
33
  try {
34
34
  // Parse and validate config
35
- const rawConfig = context.config.plugins?.entries?.["n9e-plugin"]?.config;
36
- if (!rawConfig) {
35
+ const rawConfig = context?.config?.plugins?.entries?.["n9e-plugin"]?.config;
36
+ if (!rawConfig || !rawConfig.apiBaseUrl || !rawConfig.apiKey) {
37
37
  return {
38
38
  content: [{
39
39
  type: "text",
40
- text: "❌ 插件配置未找到,请在配置文件中添加n9e-plugin配置"
40
+ text: "❌ 插件配置未找到或不完整,请在配置文件中添加 apiBaseUrl 和 apiKey"
41
41
  }],
42
42
  isError: true
43
43
  };
@@ -56,7 +56,12 @@ export const activeAlertsToolHandler: ToolHandler = async (input, context) => {
56
56
 
57
57
  // Format response
58
58
  const alerts = list.map(alert => {
59
- const tags = alert.tags ? JSON.parse(alert.tags) : {};
59
+ let tags = {};
60
+ try {
61
+ tags = alert.tags ? JSON.parse(alert.tags) : {};
62
+ } catch (e) {
63
+ // Ignore JSON parse errors
64
+ }
60
65
  return {
61
66
  id: alert.id,
62
67
  rule_name: alert.rule_name,