@sodikinnaa/smart-report-plugin 2.1.3 → 2.1.4

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.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- /**
2
- * MCP Activation Hook
3
- */
4
- export declare function register(api: any): void;
5
- export declare const activate: typeof register;
1
+ declare const plugin: any;
2
+ export default plugin;
3
+ export declare const register: any;
4
+ export declare const activate: any;
package/dist/index.js CHANGED
@@ -2,31 +2,10 @@
2
2
  * Smart Report MCP Plugin for OpenClaw
3
3
  */
4
4
  import axios from 'axios';
5
- import * as fs from 'fs';
6
- import * as path from 'path';
7
- import * as os from 'os';
8
5
  const PLUGIN_ID = 'smart-report-plugin';
9
6
  const API_BASE = 'https://smartreport.siapdigital.my.id/api/mcp';
10
- function saveConfig(token) {
11
- const configPath = path.join(os.homedir(), '.openclaw', 'openclaw.json');
12
- if (fs.existsSync(configPath)) {
13
- const raw = fs.readFileSync(configPath, 'utf-8');
14
- const config = JSON.parse(raw);
15
- if (!config.plugins)
16
- config.plugins = {};
17
- if (!config.plugins.entries)
18
- config.plugins.entries = {};
19
- if (!config.plugins.entries[PLUGIN_ID])
20
- config.plugins.entries[PLUGIN_ID] = {};
21
- if (!config.plugins.entries[PLUGIN_ID].config)
22
- config.plugins.entries[PLUGIN_ID].config = {};
23
- config.plugins.entries[PLUGIN_ID].config.apiToken = token;
24
- config.plugins.entries[PLUGIN_ID].enabled = true;
25
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
26
- }
27
- }
28
7
  async function callMcp(api, method, params = {}) {
29
- const config = api.config.plugins?.entries?.[PLUGIN_ID]?.config;
8
+ const config = api.config;
30
9
  const token = config?.apiToken;
31
10
  if (!token) {
32
11
  throw new Error('API Token not found. Please run "openclaw smart-auth <token>" first.');
@@ -48,155 +27,140 @@ async function callMcp(api, method, params = {}) {
48
27
  }
49
28
  return response.data.result;
50
29
  }
51
- /**
52
- * MCP Activation Hook
53
- */
54
- export function register(api) {
55
- // 1. CLI Commands
56
- api.registerCli(({ program }) => {
57
- program
58
- .command('smart-auth <token>')
59
- .description('Set API Token for Smart Report integration')
60
- .action((token) => {
61
- try {
62
- saveConfig(token);
30
+ const plugin = {
31
+ id: PLUGIN_ID,
32
+ name: "Smart Report Integration",
33
+ version: "2.1.4",
34
+ register(api) {
35
+ // 1. CLI Commands
36
+ api.registerCli(({ program }) => {
37
+ program
38
+ .command('smart-auth <token>')
39
+ .description('Set API Token for Smart Report integration')
40
+ .action(async (token) => {
41
+ await api.saveConfig({ apiToken: token });
63
42
  console.log('✅ Smart Report API Token saved successfully.');
64
- process.exit(0);
65
- }
66
- catch (err) {
67
- console.error('❌ Failed to save config:', err.message);
68
- process.exit(1);
43
+ });
44
+ }, { commands: ['smart-auth'] });
45
+ // 2. Resources
46
+ api.registerResource({
47
+ uri: 'smartreport://reports',
48
+ name: 'Recent Reports',
49
+ description: 'Stream of latest submitted reports',
50
+ mimeType: 'application/json',
51
+ read: async () => {
52
+ const data = await callMcp(api, 'reports/list', { per_page: 10 });
53
+ return { content: JSON.stringify(data, null, 2) };
69
54
  }
70
55
  });
71
- }, { commands: ['smart-auth'] });
72
- // 2. Resources
73
- api.registerResource({
74
- uri: 'smartreport://reports',
75
- name: 'Recent Reports',
76
- description: 'Stream of latest submitted reports',
77
- mimeType: 'application/json',
78
- read: async () => {
79
- const data = await callMcp(api, 'reports/list', { per_page: 10 });
80
- return { content: JSON.stringify(data, null, 2) };
81
- }
82
- });
83
- api.registerResource({
84
- uri: 'smartreport://employees',
85
- name: 'Employee List',
86
- description: 'Complete list of active employees with division names',
87
- mimeType: 'application/json',
88
- read: async () => {
89
- const data = await callMcp(api, 'employees/list', {});
90
- return { content: JSON.stringify(data, null, 2) };
91
- }
92
- });
93
- api.registerResource({
94
- uri: 'smartreport://divisions',
95
- name: 'Division List',
96
- description: 'List of all divisions in the company',
97
- mimeType: 'application/json',
98
- read: async () => {
99
- const data = await callMcp(api, 'divisions/list', {});
100
- return { content: JSON.stringify(data, null, 2) };
101
- }
102
- });
103
- api.registerResource({
104
- uri: 'smartreport://guides',
105
- name: 'Guides List',
106
- description: 'List of all available dynamic guides',
107
- mimeType: 'application/json',
108
- read: async () => {
109
- const data = await callMcp(api, 'guides/list', {});
110
- return { content: JSON.stringify(data, null, 2) };
111
- }
112
- });
113
- api.registerResource({
114
- uri: 'smartreport://debt-aging',
115
- name: 'Debt Aging Analysis',
116
- description: 'Analysis of pending tasks and overdue reports',
117
- mimeType: 'application/json',
118
- read: async () => {
119
- const data = await callMcp(api, 'attendance/list_absent', { include_reason: true });
120
- return { content: JSON.stringify(data, null, 2) };
121
- }
122
- });
123
- api.registerResource({
124
- uri: 'smartreport://dashboard',
125
- name: 'Daily Dashboard',
126
- description: 'Real-time KPI dashboard (stats, highlights, alerts)',
127
- mimeType: 'application/json',
128
- read: async (params) => {
129
- const data = await callMcp(api, 'smartreport/dashboard', params || {});
130
- return { content: JSON.stringify(data, null, 2) };
131
- }
132
- });
133
- // 3. Agent Tools
134
- api.registerTool({
135
- name: 'get_daily_dashboard',
136
- description: 'Retrieve real-time KPI dashboard (stats, highlights, alerts).',
137
- execute: async (args) => {
138
- try {
139
- const data = await callMcp(api, 'smartreport/dashboard', args);
140
- return { text: JSON.stringify(data, null, 2) };
56
+ api.registerResource({
57
+ uri: 'smartreport://employees',
58
+ name: 'Employee List',
59
+ description: 'Complete list of active employees with division names',
60
+ mimeType: 'application/json',
61
+ read: async () => {
62
+ const data = await callMcp(api, 'employees/list', {});
63
+ return { content: JSON.stringify(data, null, 2) };
141
64
  }
142
- catch (err) {
143
- return { error: err.message };
65
+ });
66
+ api.registerResource({
67
+ uri: 'smartreport://divisions',
68
+ name: 'Division List',
69
+ description: 'List of all divisions in the company',
70
+ mimeType: 'application/json',
71
+ read: async () => {
72
+ const data = await callMcp(api, 'divisions/list', {});
73
+ return { content: JSON.stringify(data, null, 2) };
144
74
  }
145
- }
146
- });
147
- api.registerTool({
148
- name: 'get_guides_list',
149
- description: 'Retrieve list of all available dynamic guides.',
150
- execute: async () => {
151
- try {
75
+ });
76
+ api.registerResource({
77
+ uri: 'smartreport://guides',
78
+ name: 'Guides List',
79
+ description: 'List of all available dynamic guides',
80
+ mimeType: 'application/json',
81
+ read: async () => {
152
82
  const data = await callMcp(api, 'guides/list', {});
153
- return { text: JSON.stringify(data, null, 2) };
154
- }
155
- catch (err) {
156
- return { error: err.message };
83
+ return { content: JSON.stringify(data, null, 2) };
157
84
  }
158
- }
159
- });
160
- api.registerTool({
161
- name: 'get_guide_content',
162
- description: 'Retrieve full content of a specific guide by ID.',
163
- execute: async (args) => {
164
- try {
165
- const data = await callMcp(api, 'guides/get', args);
166
- return { text: JSON.stringify(data, null, 2) };
85
+ });
86
+ api.registerResource({
87
+ uri: 'smartreport://dashboard',
88
+ name: 'Daily Dashboard',
89
+ description: 'Real-time KPI dashboard (stats, highlights, alerts)',
90
+ mimeType: 'application/json',
91
+ read: async (params) => {
92
+ const data = await callMcp(api, 'smartreport/dashboard', params || {});
93
+ return { content: JSON.stringify(data, null, 2) };
167
94
  }
168
- catch (err) {
169
- return { error: err.message };
95
+ });
96
+ // 3. Agent Tools
97
+ api.registerTool({
98
+ name: 'get_daily_dashboard',
99
+ description: 'Retrieve real-time KPI dashboard (stats, highlights, alerts).',
100
+ execute: async (args) => {
101
+ try {
102
+ const data = await callMcp(api, 'smartreport/dashboard', args);
103
+ return { text: JSON.stringify(data, null, 2) };
104
+ }
105
+ catch (err) {
106
+ return { error: err.message };
107
+ }
170
108
  }
171
- }
172
- });
173
- api.registerTool({
174
- name: 'get_list_reports',
175
- description: 'Retrieve reports with filters (date, employee, division).',
176
- execute: async (args) => {
177
- try {
178
- const data = await callMcp(api, 'reports/list', args);
179
- return { text: JSON.stringify(data, null, 2) };
109
+ });
110
+ api.registerTool({
111
+ name: 'get_guides_list',
112
+ description: 'Retrieve list of all available dynamic guides.',
113
+ execute: async () => {
114
+ try {
115
+ const data = await callMcp(api, 'guides/list', {});
116
+ return { text: JSON.stringify(data, null, 2) };
117
+ }
118
+ catch (err) {
119
+ return { error: err.message };
120
+ }
180
121
  }
181
- catch (err) {
182
- return { error: err.message };
122
+ });
123
+ api.registerTool({
124
+ name: 'get_guide_content',
125
+ description: 'Retrieve full content of a specific guide by ID.',
126
+ execute: async (args) => {
127
+ try {
128
+ const data = await callMcp(api, 'guides/get', args);
129
+ return { text: JSON.stringify(data, null, 2) };
130
+ }
131
+ catch (err) {
132
+ return { error: err.message };
133
+ }
183
134
  }
184
- }
185
- });
186
- api.registerTool({
187
- name: 'get_debt_analysis',
188
- description: 'Analyze pending tasks and employee performance debt.',
189
- execute: async (args) => {
190
- try {
191
- const data = await callMcp(api, 'analyze_performance', args);
192
- return { text: JSON.stringify(data, null, 2) };
135
+ });
136
+ api.registerTool({
137
+ name: 'get_list_reports',
138
+ description: 'Retrieve reports with filters (date, employee, division).',
139
+ execute: async (args) => {
140
+ try {
141
+ const data = await callMcp(api, 'reports/list', args);
142
+ return { text: JSON.stringify(data, null, 2) };
143
+ }
144
+ catch (err) {
145
+ return { error: err.message };
146
+ }
193
147
  }
194
- catch (err) {
195
- return { error: err.message };
148
+ });
149
+ api.registerTool({
150
+ name: 'get_debt_analysis',
151
+ description: 'Analyze pending tasks and employee performance debt.',
152
+ execute: async (args) => {
153
+ try {
154
+ const data = await callMcp(api, 'analyze_performance', args);
155
+ return { text: JSON.stringify(data, null, 2) };
156
+ }
157
+ catch (err) {
158
+ return { error: err.message };
159
+ }
196
160
  }
197
- }
198
- });
199
- }
200
- // We remove default export and stick to NAMED exports only
201
- // to see if it helps the loader distinguish the module structure.
202
- export const activate = register;
161
+ });
162
+ }
163
+ };
164
+ export default plugin;
165
+ export const register = plugin.register;
166
+ export const activate = plugin.register;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sodikinnaa/smart-report-plugin",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "OpenClaw plugin for Smart Report system integration with Daily Dashboard",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
package/src/index.ts CHANGED
@@ -2,32 +2,12 @@
2
2
  * Smart Report MCP Plugin for OpenClaw
3
3
  */
4
4
  import axios from 'axios';
5
- import * as fs from 'fs';
6
- import * as path from 'path';
7
- import * as os from 'os';
8
5
 
9
6
  const PLUGIN_ID = 'smart-report-plugin';
10
7
  const API_BASE = 'https://smartreport.siapdigital.my.id/api/mcp';
11
8
 
12
- function saveConfig(token: string) {
13
- const configPath = path.join(os.homedir(), '.openclaw', 'openclaw.json');
14
- if (fs.existsSync(configPath)) {
15
- const raw = fs.readFileSync(configPath, 'utf-8');
16
- const config = JSON.parse(raw);
17
- if (!config.plugins) config.plugins = {};
18
- if (!config.plugins.entries) config.plugins.entries = {};
19
- if (!config.plugins.entries[PLUGIN_ID]) config.plugins.entries[PLUGIN_ID] = {};
20
- if (!config.plugins.entries[PLUGIN_ID].config) config.plugins.entries[PLUGIN_ID].config = {};
21
-
22
- config.plugins.entries[PLUGIN_ID].config.apiToken = token;
23
- config.plugins.entries[PLUGIN_ID].enabled = true;
24
-
25
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
26
- }
27
- }
28
-
29
9
  async function callMcp(api: any, method: string, params: any = {}) {
30
- const config = (api.config as any).plugins?.entries?.[PLUGIN_ID]?.config;
10
+ const config: any = api.config;
31
11
  const token = config?.apiToken;
32
12
 
33
13
  if (!token) {
@@ -54,161 +34,147 @@ async function callMcp(api: any, method: string, params: any = {}) {
54
34
  return response.data.result;
55
35
  }
56
36
 
57
- /**
58
- * MCP Activation Hook
59
- */
60
- export function register(api: any) {
61
- // 1. CLI Commands
62
- api.registerCli(({ program }: any) => {
63
- program
64
- .command('smart-auth <token>')
65
- .description('Set API Token for Smart Report integration')
66
- .action((token: string) => {
67
- try {
68
- saveConfig(token);
37
+ const plugin: any = {
38
+ id: PLUGIN_ID,
39
+ name: "Smart Report Integration",
40
+ version: "2.1.4",
41
+
42
+ register(api: any) {
43
+ // 1. CLI Commands
44
+ api.registerCli(({ program }: any) => {
45
+ program
46
+ .command('smart-auth <token>')
47
+ .description('Set API Token for Smart Report integration')
48
+ .action(async (token: string) => {
49
+ await api.saveConfig({ apiToken: token });
69
50
  console.log('✅ Smart Report API Token saved successfully.');
70
- process.exit(0);
51
+ });
52
+ }, { commands: ['smart-auth'] });
53
+
54
+ // 2. Resources
55
+ api.registerResource({
56
+ uri: 'smartreport://reports',
57
+ name: 'Recent Reports',
58
+ description: 'Stream of latest submitted reports',
59
+ mimeType: 'application/json',
60
+ read: async () => {
61
+ const data = await callMcp(api, 'reports/list', { per_page: 10 });
62
+ return { content: JSON.stringify(data, null, 2) };
63
+ }
64
+ });
65
+
66
+ api.registerResource({
67
+ uri: 'smartreport://employees',
68
+ name: 'Employee List',
69
+ description: 'Complete list of active employees with division names',
70
+ mimeType: 'application/json',
71
+ read: async () => {
72
+ const data = await callMcp(api, 'employees/list', {});
73
+ return { content: JSON.stringify(data, null, 2) };
74
+ }
75
+ });
76
+
77
+ api.registerResource({
78
+ uri: 'smartreport://divisions',
79
+ name: 'Division List',
80
+ description: 'List of all divisions in the company',
81
+ mimeType: 'application/json',
82
+ read: async () => {
83
+ const data = await callMcp(api, 'divisions/list', {});
84
+ return { content: JSON.stringify(data, null, 2) };
85
+ }
86
+ });
87
+
88
+ api.registerResource({
89
+ uri: 'smartreport://guides',
90
+ name: 'Guides List',
91
+ description: 'List of all available dynamic guides',
92
+ mimeType: 'application/json',
93
+ read: async () => {
94
+ const data = await callMcp(api, 'guides/list', {});
95
+ return { content: JSON.stringify(data, null, 2) };
96
+ }
97
+ });
98
+
99
+ api.registerResource({
100
+ uri: 'smartreport://dashboard',
101
+ name: 'Daily Dashboard',
102
+ description: 'Real-time KPI dashboard (stats, highlights, alerts)',
103
+ mimeType: 'application/json',
104
+ read: async (params: any) => {
105
+ const data = await callMcp(api, 'smartreport/dashboard', params || {});
106
+ return { content: JSON.stringify(data, null, 2) };
107
+ }
108
+ });
109
+
110
+ // 3. Agent Tools
111
+ api.registerTool({
112
+ name: 'get_daily_dashboard',
113
+ description: 'Retrieve real-time KPI dashboard (stats, highlights, alerts).',
114
+ execute: async (args: any) => {
115
+ try {
116
+ const data = await callMcp(api, 'smartreport/dashboard', args);
117
+ return { text: JSON.stringify(data, null, 2) };
71
118
  } catch (err: any) {
72
- console.error('❌ Failed to save config:', err.message);
73
- process.exit(1);
119
+ return { error: err.message };
74
120
  }
75
- });
76
- }, { commands: ['smart-auth'] });
77
-
78
- // 2. Resources
79
- api.registerResource({
80
- uri: 'smartreport://reports',
81
- name: 'Recent Reports',
82
- description: 'Stream of latest submitted reports',
83
- mimeType: 'application/json',
84
- read: async () => {
85
- const data = await callMcp(api, 'reports/list', { per_page: 10 });
86
- return { content: JSON.stringify(data, null, 2) };
87
- }
88
- });
89
-
90
- api.registerResource({
91
- uri: 'smartreport://employees',
92
- name: 'Employee List',
93
- description: 'Complete list of active employees with division names',
94
- mimeType: 'application/json',
95
- read: async () => {
96
- const data = await callMcp(api, 'employees/list', {});
97
- return { content: JSON.stringify(data, null, 2) };
98
- }
99
- });
100
-
101
- api.registerResource({
102
- uri: 'smartreport://divisions',
103
- name: 'Division List',
104
- description: 'List of all divisions in the company',
105
- mimeType: 'application/json',
106
- read: async () => {
107
- const data = await callMcp(api, 'divisions/list', {});
108
- return { content: JSON.stringify(data, null, 2) };
109
- }
110
- });
111
-
112
- api.registerResource({
113
- uri: 'smartreport://guides',
114
- name: 'Guides List',
115
- description: 'List of all available dynamic guides',
116
- mimeType: 'application/json',
117
- read: async () => {
118
- const data = await callMcp(api, 'guides/list', {});
119
- return { content: JSON.stringify(data, null, 2) };
120
- }
121
- });
122
-
123
- api.registerResource({
124
- uri: 'smartreport://debt-aging',
125
- name: 'Debt Aging Analysis',
126
- description: 'Analysis of pending tasks and overdue reports',
127
- mimeType: 'application/json',
128
- read: async () => {
129
- const data = await callMcp(api, 'attendance/list_absent', { include_reason: true });
130
- return { content: JSON.stringify(data, null, 2) };
131
- }
132
- });
133
-
134
- api.registerResource({
135
- uri: 'smartreport://dashboard',
136
- name: 'Daily Dashboard',
137
- description: 'Real-time KPI dashboard (stats, highlights, alerts)',
138
- mimeType: 'application/json',
139
- read: async (params: any) => {
140
- const data = await callMcp(api, 'smartreport/dashboard', params || {});
141
- return { content: JSON.stringify(data, null, 2) };
142
- }
143
- });
144
-
145
- // 3. Agent Tools
146
- api.registerTool({
147
- name: 'get_daily_dashboard',
148
- description: 'Retrieve real-time KPI dashboard (stats, highlights, alerts).',
149
- execute: async (args: any) => {
150
- try {
151
- const data = await callMcp(api, 'smartreport/dashboard', args);
152
- return { text: JSON.stringify(data, null, 2) };
153
- } catch (err: any) {
154
- return { error: err.message };
155
121
  }
156
- }
157
- });
122
+ });
158
123
 
159
- api.registerTool({
160
- name: 'get_guides_list',
161
- description: 'Retrieve list of all available dynamic guides.',
162
- execute: async () => {
163
- try {
164
- const data = await callMcp(api, 'guides/list', {});
165
- return { text: JSON.stringify(data, null, 2) };
166
- } catch (err: any) {
167
- return { error: err.message };
124
+ api.registerTool({
125
+ name: 'get_guides_list',
126
+ description: 'Retrieve list of all available dynamic guides.',
127
+ execute: async () => {
128
+ try {
129
+ const data = await callMcp(api, 'guides/list', {});
130
+ return { text: JSON.stringify(data, null, 2) };
131
+ } catch (err: any) {
132
+ return { error: err.message };
133
+ }
168
134
  }
169
- }
170
- });
135
+ });
171
136
 
172
- api.registerTool({
173
- name: 'get_guide_content',
174
- description: 'Retrieve full content of a specific guide by ID.',
175
- execute: async (args: any) => {
176
- try {
177
- const data = await callMcp(api, 'guides/get', args);
178
- return { text: JSON.stringify(data, null, 2) };
179
- } catch (err: any) {
180
- return { error: err.message };
137
+ api.registerTool({
138
+ name: 'get_guide_content',
139
+ description: 'Retrieve full content of a specific guide by ID.',
140
+ execute: async (args: any) => {
141
+ try {
142
+ const data = await callMcp(api, 'guides/get', args);
143
+ return { text: JSON.stringify(data, null, 2) };
144
+ } catch (err: any) {
145
+ return { error: err.message };
146
+ }
181
147
  }
182
- }
183
- });
148
+ });
184
149
 
185
- api.registerTool({
186
- name: 'get_list_reports',
187
- description: 'Retrieve reports with filters (date, employee, division).',
188
- execute: async (args: any) => {
189
- try {
190
- const data = await callMcp(api, 'reports/list', args);
191
- return { text: JSON.stringify(data, null, 2) };
192
- } catch (err: any) {
193
- return { error: err.message };
150
+ api.registerTool({
151
+ name: 'get_list_reports',
152
+ description: 'Retrieve reports with filters (date, employee, division).',
153
+ execute: async (args: any) => {
154
+ try {
155
+ const data = await callMcp(api, 'reports/list', args);
156
+ return { text: JSON.stringify(data, null, 2) };
157
+ } catch (err: any) {
158
+ return { error: err.message };
159
+ }
194
160
  }
195
- }
196
- });
161
+ });
197
162
 
198
- api.registerTool({
199
- name: 'get_debt_analysis',
200
- description: 'Analyze pending tasks and employee performance debt.',
201
- execute: async (args: any) => {
202
- try {
203
- const data = await callMcp(api, 'analyze_performance', args);
204
- return { text: JSON.stringify(data, null, 2) };
205
- } catch (err: any) {
206
- return { error: err.message };
163
+ api.registerTool({
164
+ name: 'get_debt_analysis',
165
+ description: 'Analyze pending tasks and employee performance debt.',
166
+ execute: async (args: any) => {
167
+ try {
168
+ const data = await callMcp(api, 'analyze_performance', args);
169
+ return { text: JSON.stringify(data, null, 2) };
170
+ } catch (err: any) {
171
+ return { error: err.message };
172
+ }
207
173
  }
208
- }
209
- });
210
- }
174
+ });
175
+ }
176
+ };
211
177
 
212
- // We remove default export and stick to NAMED exports only
213
- // to see if it helps the loader distinguish the module structure.
214
- export const activate = register;
178
+ export default plugin;
179
+ export const register = plugin.register;
180
+ export const activate = plugin.register;