@make-u-free/migi 0.5.11 → 0.5.12

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/tools.js +9 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@make-u-free/migi",
3
- "version": "0.5.11",
3
+ "version": "0.5.12",
4
4
  "description": "Your AI right-hand agent. Works anywhere, with any LLM API.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/tools.js CHANGED
@@ -8,7 +8,8 @@ import chalk from 'chalk'
8
8
  import xlsxPkg from 'xlsx'
9
9
  import { createRequire } from 'module'
10
10
  const require = createRequire(import.meta.url)
11
- const pdfParse = require('pdf-parse')
11
+ const _pdfParseModule = require('pdf-parse')
12
+ const pdfParse = typeof _pdfParseModule === 'function' ? _pdfParseModule : _pdfParseModule.default
12
13
  import AdmZip from 'adm-zip'
13
14
  import OpenAI from 'openai'
14
15
  import { httpsAgent } from './tls.js'
@@ -233,11 +234,13 @@ export async function executeTool(name, args, opts = {}) {
233
234
  const buf = readFileSync(args.path)
234
235
 
235
236
  // Step 1: テキストPDFとして抽出を試みる
236
- try {
237
- const data = await pdfParse(buf)
238
- const text = data.text?.trim()
239
- if (text) return text
240
- } catch (_) {}
237
+ if (typeof pdfParse === 'function') {
238
+ try {
239
+ const data = await pdfParse(buf)
240
+ const text = data.text?.trim()
241
+ if (text) return text
242
+ } catch (_) {}
243
+ }
241
244
 
242
245
  // Step 2: 画像PDFとしてVision APIでOCR(ネイティブ依存なし)
243
246
  if (!opts.apiKey) return '(テキストが抽出できませんでした)'