@make-u-free/migi 0.2.7 → 0.2.8
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/package.json +1 -1
- package/src/tools.js +24 -6
package/package.json
CHANGED
package/src/tools.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync, appendFileSync, existsSync, mkdirSync } from 'fs'
|
|
2
2
|
import { execSync } from 'child_process'
|
|
3
3
|
import { dirname, extname } from 'path'
|
|
4
|
+
import { request } from 'https'
|
|
4
5
|
import { glob } from 'glob'
|
|
5
6
|
import xlsxPkg from 'xlsx'
|
|
7
|
+
import { httpsAgent } from './tls.js'
|
|
6
8
|
const { readFile: xlsxReadFile, utils: xlsxUtils } = xlsxPkg
|
|
7
9
|
|
|
8
10
|
// ---- OpenAI ツールスキーマ定義 ----
|
|
@@ -179,13 +181,29 @@ export async function executeTool(name, args, opts = {}) {
|
|
|
179
181
|
const url = opts.teamsWebhookUrl
|
|
180
182
|
if (!url) return 'エラー: Teams Webhook URL が設定されていません'
|
|
181
183
|
const body = JSON.stringify({ text: args.message })
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
return new Promise((resolve) => {
|
|
185
|
+
const parsed = new URL(url)
|
|
186
|
+
const options = {
|
|
187
|
+
hostname: parsed.hostname,
|
|
188
|
+
path: parsed.pathname + parsed.search,
|
|
189
|
+
method: 'POST',
|
|
190
|
+
headers: {
|
|
191
|
+
'Content-Type': 'application/json',
|
|
192
|
+
'Content-Length': Buffer.byteLength(body)
|
|
193
|
+
},
|
|
194
|
+
...(httpsAgent ? { agent: httpsAgent } : {})
|
|
195
|
+
}
|
|
196
|
+
const req = request(options, (res) => {
|
|
197
|
+
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
198
|
+
resolve('Teams に通知しました')
|
|
199
|
+
} else {
|
|
200
|
+
resolve(`エラー: Teams への送信に失敗しました (${res.statusCode})`)
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
req.on('error', (err) => resolve(`エラー: ${err.message}`))
|
|
204
|
+
req.write(body)
|
|
205
|
+
req.end()
|
|
186
206
|
})
|
|
187
|
-
if (!res.ok) return `エラー: Teams への送信に失敗しました (${res.status})`
|
|
188
|
-
return 'Teams に通知しました'
|
|
189
207
|
}
|
|
190
208
|
|
|
191
209
|
default:
|