@sodikinnaa/smart-report-plugin 1.0.0-sultan-beta.0
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/README.md +28 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +166 -0
- package/docs/USER_GUIDE.md +97 -0
- package/openclaw.plugin.json +14 -0
- package/package.json +35 -0
- package/skills/smart-report/SKILL.md +48 -0
- package/sodikinnaa-smart-report-plugin-1.0.7.tgz +0 -0
- package/sodikinnaa-smart-report-plugin-1.0.8.tgz +0 -0
- package/sodikinnaa-smart-report-plugin-1.0.9.tgz +0 -0
- package/sodikinnaa-smart-report-plugin-2.0.0.tgz +0 -0
- package/sodikinnaa-smart-report-plugin-2.1.2.tgz +0 -0
- package/sodikinnaa-smart-report-plugin-2.1.3.tgz +0 -0
- package/src/index.ts +180 -0
- package/tsconfig.json +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Smart Report MCP Plugin for OpenClaw (v1.0.8)
|
|
2
|
+
|
|
3
|
+
Plugin integrasi resmi untuk menghubungkan OpenClaw dengan ekosistem **Smart Report**. Memungkinkan analisis data karyawan, laporan harian, dan dashboard KPI secara real-time.
|
|
4
|
+
|
|
5
|
+
## 🚀 Quick Start
|
|
6
|
+
```bash
|
|
7
|
+
# 1. Instal Plugin
|
|
8
|
+
openclaw plugins install @sodikinnaa/smart-report-plugin
|
|
9
|
+
|
|
10
|
+
# 2. Aktivasi Token
|
|
11
|
+
openclaw smart-auth YOUR_SECRET_TOKEN
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 📖 Dokumentasi Lengkap
|
|
15
|
+
Kami telah menyediakan panduan langkah-demi-langkah untuk pengguna teknis maupun non-teknis:
|
|
16
|
+
* [**Panduan Pengguna (User Guide)**](docs/USER_GUIDE.md) - Prasyarat, Instalasi, Tooling, dan Troubleshooting.
|
|
17
|
+
|
|
18
|
+
## 🛠️ Fitur Utama
|
|
19
|
+
* **MCP Integration:** Mendukung standar Model Context Protocol.
|
|
20
|
+
* **KPI Dashboard:** Data agregasi harian (Compact/Full/Ops mode).
|
|
21
|
+
* **Deep Analysis:** Tool untuk mendeteksi "Debt Performance" karyawan.
|
|
22
|
+
* **Division Aware:** Data karyawan sekarang sudah menyertakan nama divisi.
|
|
23
|
+
|
|
24
|
+
## ⚖️ Lisensi
|
|
25
|
+
Distributed under the MIT License. See `LICENSE` for more information.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
*Powered by Sultan Engine*
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart Report MCP Plugin for OpenClaw
|
|
3
|
+
*/
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
const PLUGIN_ID = 'smart-report-plugin';
|
|
6
|
+
const API_BASE = 'https://smartreport.siapdigital.my.id/api/mcp';
|
|
7
|
+
async function callMcp(api, method, params = {}) {
|
|
8
|
+
const config = api.config;
|
|
9
|
+
const token = config?.apiToken;
|
|
10
|
+
if (!token) {
|
|
11
|
+
throw new Error('API Token not found. Please run "openclaw smart-auth <token>" first.');
|
|
12
|
+
}
|
|
13
|
+
const response = await axios.post(API_BASE, {
|
|
14
|
+
jsonrpc: '2.0',
|
|
15
|
+
method: method,
|
|
16
|
+
params: params,
|
|
17
|
+
id: Date.now()
|
|
18
|
+
}, {
|
|
19
|
+
headers: {
|
|
20
|
+
'Authorization': `Bearer ${token}`,
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
'Accept': 'application/json'
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
if (response.data.error) {
|
|
26
|
+
throw new Error(response.data.error.message);
|
|
27
|
+
}
|
|
28
|
+
return response.data.result;
|
|
29
|
+
}
|
|
30
|
+
const plugin = {
|
|
31
|
+
id: PLUGIN_ID,
|
|
32
|
+
name: "Smart Report Integration",
|
|
33
|
+
version: "6.3.0-beta.0",
|
|
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 });
|
|
42
|
+
console.log('✅ Smart Report API Token saved successfully.');
|
|
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) };
|
|
54
|
+
}
|
|
55
|
+
});
|
|
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) };
|
|
64
|
+
}
|
|
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) };
|
|
74
|
+
}
|
|
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 () => {
|
|
82
|
+
const data = await callMcp(api, 'guides/list', {});
|
|
83
|
+
return { content: JSON.stringify(data, null, 2) };
|
|
84
|
+
}
|
|
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) };
|
|
94
|
+
}
|
|
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
|
+
}
|
|
108
|
+
}
|
|
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
|
+
}
|
|
121
|
+
}
|
|
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
|
+
}
|
|
134
|
+
}
|
|
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
|
+
}
|
|
147
|
+
}
|
|
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
|
+
}
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
export default plugin;
|
|
165
|
+
export const register = plugin.register;
|
|
166
|
+
export const activate = plugin.register;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# 📊 Panduan Lengkap Smart Report MCP Plugin
|
|
2
|
+
|
|
3
|
+
Selamat datang di ekosistem Smart Report! Plugin ini memungkinkan asisten AI Anda (OpenClaw) terhubung langsung dengan data operasional perusahaan secara real-time.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Prasyarat (Prerequisites)
|
|
8
|
+
|
|
9
|
+
Sebelum instalasi, pastikan Anda memiliki:
|
|
10
|
+
* **Environment:** Node.js v20+ dan OpenClaw Gateway terpasang.
|
|
11
|
+
* **Token API:** Token akses sah dari Admin Smart Report (Misal: `Wkr4v8Tj...`).
|
|
12
|
+
* **Akses Internet:** Dibutuhkan untuk instalasi package dan request data ke server.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 2. Instalasi (Installation)
|
|
17
|
+
|
|
18
|
+
### Jalur Normal (NPM)
|
|
19
|
+
Gunakan perintah ini di terminal OpenClaw:
|
|
20
|
+
```bash
|
|
21
|
+
openclaw plugins install @sodikinnaa/smart-report-plugin
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Jalur Fallback (Jika NPM/Cache Bermasalah)
|
|
25
|
+
Jika instalasi gagal karena kendala versi lama atau cache, gunakan link tarball langsung:
|
|
26
|
+
```bash
|
|
27
|
+
openclaw plugins install https://registry.npmjs.org/@sodikinnaa/smart-report-plugin/-/smart-report-plugin-1.0.8.tgz
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 3. Aktivasi & Autentikasi (Auth)
|
|
33
|
+
|
|
34
|
+
Setelah terinstal, Anda wajib mendaftarkan token Anda agar AI bisa mengakses data:
|
|
35
|
+
|
|
36
|
+
**Perintah:**
|
|
37
|
+
```bash
|
|
38
|
+
openclaw smart-auth <TOKEN_ANDA>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Contoh Sukses:**
|
|
42
|
+
`✅ Smart Report API Token saved successfully.`
|
|
43
|
+
|
|
44
|
+
**Contoh Gagal:**
|
|
45
|
+
`❌ Failed to save config: ...` (Pastikan Anda menjalankan perintah di terminal yang memiliki izin tulis ke folder `.openclaw`).
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 4. Daftar Resource & Tool
|
|
50
|
+
|
|
51
|
+
### 🔎 Resource (Data Statis/Stream)
|
|
52
|
+
AI dapat membaca resource ini untuk mendapatkan konteks:
|
|
53
|
+
* `smartreport://dashboard`: Data KPI hari ini (Total karyawan, kehadiran, completion rate).
|
|
54
|
+
* `smartreport://employees`: Daftar lengkap karyawan beserta nama divisinya.
|
|
55
|
+
* `smartreport://reports`: Aliran 10 laporan terbaru yang masuk.
|
|
56
|
+
* `smartreport://divisions`: Daftar seluruh divisi di perusahaan.
|
|
57
|
+
|
|
58
|
+
### 🛠️ Agent Tools (Aksi Dinamis)
|
|
59
|
+
AI dapat menjalankan perintah spesifik:
|
|
60
|
+
* **`get_daily_dashboard`**: Mengambil ringkasan statistik harian.
|
|
61
|
+
* **`get_list_reports`**: Mencari laporan berdasarkan filter (tanggal, divisi, nama).
|
|
62
|
+
* **`get_debt_analysis`**: Menganalisis siapa saja yang belum lapor atau memiliki tugas tertunda.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 5. Mode Dashboard
|
|
67
|
+
|
|
68
|
+
Saat meminta dashboard, Anda dapat menentukan `mode`:
|
|
69
|
+
1. **Compact (Default):** Ringkasan angka utama saja. Cocok untuk update cepat di chat.
|
|
70
|
+
2. **Full:** Menyertakan detail statistik per divisi. Cocok untuk laporan manajemen.
|
|
71
|
+
3. **Ops:** Menyertakan alert sistem dan highlight operasional. Cocok untuk monitoring tim.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 6. Workflow Harian (Best Practice)
|
|
76
|
+
|
|
77
|
+
Berikut adalah contoh alur kerja asisten AI Anda setiap hari:
|
|
78
|
+
1. **Pagi (09:00):** AI mengecek `smartreport://employees` untuk memetakan tim.
|
|
79
|
+
2. **Siang (13:00):** AI menjalankan `get_daily_dashboard(mode="compact")` untuk melihat progres awal.
|
|
80
|
+
3. **Sore (17:00):** AI menjalankan `get_debt_analysis` dan memberikan daftar orang yang belum lapor kepada Admin.
|
|
81
|
+
4. **Malam (20:00):** AI menarik `get_daily_dashboard(mode="full")` untuk laporan penutup ke WhatsApp Owner.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 7. Troubleshooting (Solusi Cepat)
|
|
86
|
+
|
|
87
|
+
* **Error: `ReferenceError exports is not defined`**
|
|
88
|
+
* *Solusi:* Update ke versi v1.0.6+ (`npm install ...@latest`).
|
|
89
|
+
* **Error: `package.json missing openclaw.extensions`**
|
|
90
|
+
* *Solusi:* Update ke versi v1.0.4+.
|
|
91
|
+
* **Error: `Method not found (-32601)`**
|
|
92
|
+
* *Solusi:* Pastikan backend sudah terupdate ke v1.3.0.
|
|
93
|
+
* **Error: `Unauthorized`**
|
|
94
|
+
* *Solusi:* Masukkan kembali token valid menggunakan `openclaw smart-auth`.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
*Dokumentasi ini dibuat oleh Sultan Engine Core untuk memastikan kelancaran operasional Anda.*
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "smart-report-plugin",
|
|
3
|
+
"name": "Smart Report Integration",
|
|
4
|
+
"version": "6.3.0-beta.0",
|
|
5
|
+
"description": "Integration plugin for Smart Report and AI Analytics with Daily Dashboard and Dynamic Guides",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"skills": ["skills/smart-report/SKILL.md"],
|
|
8
|
+
"configSchema": {
|
|
9
|
+
"type": "object",
|
|
10
|
+
"properties": {
|
|
11
|
+
"apiToken": { "type": "string" }
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sodikinnaa/smart-report-plugin",
|
|
3
|
+
"version": "1.0.0-sultan-beta.0",
|
|
4
|
+
"description": "OpenClaw plugin for Smart Report system integration with Daily Dashboard",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"test": "node test/simple.test.js",
|
|
12
|
+
"publish": "npm publish --access public"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"openclaw-plugin",
|
|
16
|
+
"smart-report",
|
|
17
|
+
"dashboard"
|
|
18
|
+
],
|
|
19
|
+
"author": "Sodikin",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"openclaw": {
|
|
22
|
+
"extensions": [
|
|
23
|
+
"./openclaw.plugin.json"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"typescript": "^5.0.0"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"axios": "^1.6.0"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Skill: Smart Report Dashboard & Analysis
|
|
2
|
+
|
|
3
|
+
Gunakan skill ini untuk berinteraksi dengan sistem Smart Report. AI diharapkan memformat respons secara profesional menggunakan elemen visual dashboard.
|
|
4
|
+
|
|
5
|
+
## Formatting Protocol (Wajib)
|
|
6
|
+
|
|
7
|
+
Setiap kali Anda menerima data dari tool `smart-report-plugin`, Anda **DILARANG** menampilkan JSON mentah. Anda harus memanipulasinya menjadi format berikut:
|
|
8
|
+
|
|
9
|
+
### 1. Dashboard Mode (`get_daily_dashboard`)
|
|
10
|
+
Tampilkan data dalam blok kode (backticks) dengan struktur ala dashboard:
|
|
11
|
+
```text
|
|
12
|
+
📊 [NAMA PERUSAHAAN] - DAILY KPI
|
|
13
|
+
Tanggal: [Date] | Mode: [Mode]
|
|
14
|
+
|
|
15
|
+
📈 STATS UTAMA:
|
|
16
|
+
- Total Karyawan : [total_karyawan]
|
|
17
|
+
- Sudah Lapor : [sudah_lapor] ✅
|
|
18
|
+
- Belum Lapor : [belum_lapor] ⚠️
|
|
19
|
+
- Completion : [completion_rate]
|
|
20
|
+
|
|
21
|
+
📂 STATS DIVISI:
|
|
22
|
+
[Looping: Nama Divisi: X Reports]
|
|
23
|
+
|
|
24
|
+
💡 HIGHLIGHTS:
|
|
25
|
+
- Update Terakhir: [latest_submission]
|
|
26
|
+
|
|
27
|
+
⚠️ ALERTS:
|
|
28
|
+
- [Alert 1]
|
|
29
|
+
- [Alert 2]
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 2. Employee List (`smartreport://employees`)
|
|
33
|
+
Gunakan list berpoin yang rapi:
|
|
34
|
+
* 👤 **[Nama Karyawan]** - [Division Name] ([Email])
|
|
35
|
+
|
|
36
|
+
### 3. Report List (`get_list_reports`)
|
|
37
|
+
Tampilkan ringkasan eksekutif:
|
|
38
|
+
* 📅 **[Tanggal]**: [Jumlah] laporan diterima.
|
|
39
|
+
* Detail: [Link/ID laporan jika ada].
|
|
40
|
+
|
|
41
|
+
### 4. Guides Management (`smartreport://guides`)
|
|
42
|
+
Tampilkan informasi edukatif:
|
|
43
|
+
* 📚 **[Judul Guide]** (Kategori: [Category]) - ID: [id]
|
|
44
|
+
|
|
45
|
+
Gunakan tool `get_guide_content` untuk membaca detail instruksi.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
*Generated by: SUL*** Eng***
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart Report MCP Plugin for OpenClaw
|
|
3
|
+
*/
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
|
|
6
|
+
const PLUGIN_ID = 'smart-report-plugin';
|
|
7
|
+
const API_BASE = 'https://smartreport.siapdigital.my.id/api/mcp';
|
|
8
|
+
|
|
9
|
+
async function callMcp(api: any, method: string, params: any = {}) {
|
|
10
|
+
const config: any = api.config;
|
|
11
|
+
const token = config?.apiToken;
|
|
12
|
+
|
|
13
|
+
if (!token) {
|
|
14
|
+
throw new Error('API Token not found. Please run "openclaw smart-auth <token>" first.');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const response = await axios.post(API_BASE, {
|
|
18
|
+
jsonrpc: '2.0',
|
|
19
|
+
method: method,
|
|
20
|
+
params: params,
|
|
21
|
+
id: Date.now()
|
|
22
|
+
}, {
|
|
23
|
+
headers: {
|
|
24
|
+
'Authorization': `Bearer ${token}`,
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
'Accept': 'application/json'
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
if (response.data.error) {
|
|
31
|
+
throw new Error(response.data.error.message);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return response.data.result;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const plugin: any = {
|
|
38
|
+
id: PLUGIN_ID,
|
|
39
|
+
name: "Smart Report Integration",
|
|
40
|
+
version: "6.3.0-beta.0",
|
|
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 });
|
|
50
|
+
console.log('✅ Smart Report API Token saved successfully.');
|
|
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) };
|
|
118
|
+
} catch (err: any) {
|
|
119
|
+
return { error: err.message };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
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
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
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
|
+
}
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
|
|
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
|
+
}
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
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
|
+
}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export default plugin;
|
|
179
|
+
export const register = plugin.register;
|
|
180
|
+
export const activate = plugin.register;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"lib": ["ESNext"],
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"moduleResolution": "NodeNext"
|
|
13
|
+
},
|
|
14
|
+
"include": ["src/**/*"]
|
|
15
|
+
}
|