bluelamp 2.0.10 → 3.0.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 +12 -25
- package/bin/bluelamp +368 -0
- package/bin/bluelamp-base +368 -0
- package/bin/bluelamp10 +368 -0
- package/bin/bluelamp100 +368 -0
- package/bin/bluelamp11 +368 -0
- package/bin/bluelamp12 +368 -0
- package/bin/bluelamp13 +368 -0
- package/bin/bluelamp14 +368 -0
- package/bin/bluelamp15 +368 -0
- package/bin/bluelamp16 +368 -0
- package/bin/bluelamp17 +368 -0
- package/bin/bluelamp18 +368 -0
- package/bin/bluelamp19 +368 -0
- package/bin/bluelamp2 +368 -0
- package/bin/bluelamp20 +368 -0
- package/bin/bluelamp21 +368 -0
- package/bin/bluelamp22 +368 -0
- package/bin/bluelamp23 +368 -0
- package/bin/bluelamp24 +368 -0
- package/bin/bluelamp25 +368 -0
- package/bin/bluelamp26 +368 -0
- package/bin/bluelamp27 +368 -0
- package/bin/bluelamp28 +368 -0
- package/bin/bluelamp29 +368 -0
- package/bin/bluelamp3 +368 -0
- package/bin/bluelamp30 +368 -0
- package/bin/bluelamp31 +368 -0
- package/bin/bluelamp32 +368 -0
- package/bin/bluelamp33 +368 -0
- package/bin/bluelamp34 +368 -0
- package/bin/bluelamp35 +368 -0
- package/bin/bluelamp36 +368 -0
- package/bin/bluelamp37 +368 -0
- package/bin/bluelamp38 +368 -0
- package/bin/bluelamp39 +368 -0
- package/bin/bluelamp4 +368 -0
- package/bin/bluelamp40 +368 -0
- package/bin/bluelamp41 +368 -0
- package/bin/bluelamp42 +368 -0
- package/bin/bluelamp43 +368 -0
- package/bin/bluelamp44 +368 -0
- package/bin/bluelamp45 +368 -0
- package/bin/bluelamp46 +368 -0
- package/bin/bluelamp47 +368 -0
- package/bin/bluelamp48 +368 -0
- package/bin/bluelamp49 +368 -0
- package/bin/bluelamp5 +368 -0
- package/bin/bluelamp50 +368 -0
- package/bin/bluelamp51 +368 -0
- package/bin/bluelamp52 +368 -0
- package/bin/bluelamp53 +368 -0
- package/bin/bluelamp54 +368 -0
- package/bin/bluelamp55 +368 -0
- package/bin/bluelamp56 +368 -0
- package/bin/bluelamp57 +368 -0
- package/bin/bluelamp58 +368 -0
- package/bin/bluelamp59 +368 -0
- package/bin/bluelamp6 +368 -0
- package/bin/bluelamp60 +368 -0
- package/bin/bluelamp61 +368 -0
- package/bin/bluelamp62 +368 -0
- package/bin/bluelamp63 +368 -0
- package/bin/bluelamp64 +368 -0
- package/bin/bluelamp65 +368 -0
- package/bin/bluelamp66 +368 -0
- package/bin/bluelamp67 +368 -0
- package/bin/bluelamp68 +368 -0
- package/bin/bluelamp69 +368 -0
- package/bin/bluelamp7 +368 -0
- package/bin/bluelamp70 +368 -0
- package/bin/bluelamp71 +368 -0
- package/bin/bluelamp72 +368 -0
- package/bin/bluelamp73 +368 -0
- package/bin/bluelamp74 +368 -0
- package/bin/bluelamp75 +368 -0
- package/bin/bluelamp76 +368 -0
- package/bin/bluelamp77 +368 -0
- package/bin/bluelamp78 +368 -0
- package/bin/bluelamp79 +368 -0
- package/bin/bluelamp8 +368 -0
- package/bin/bluelamp80 +368 -0
- package/bin/bluelamp81 +368 -0
- package/bin/bluelamp82 +368 -0
- package/bin/bluelamp83 +368 -0
- package/bin/bluelamp84 +368 -0
- package/bin/bluelamp85 +368 -0
- package/bin/bluelamp86 +368 -0
- package/bin/bluelamp87 +368 -0
- package/bin/bluelamp88 +368 -0
- package/bin/bluelamp89 +368 -0
- package/bin/bluelamp9 +368 -0
- package/bin/bluelamp90 +368 -0
- package/bin/bluelamp91 +368 -0
- package/bin/bluelamp92 +368 -0
- package/bin/bluelamp93 +368 -0
- package/bin/bluelamp94 +368 -0
- package/bin/bluelamp95 +368 -0
- package/bin/bluelamp96 +368 -0
- package/bin/bluelamp97 +368 -0
- package/bin/bluelamp98 +368 -0
- package/bin/bluelamp99 +368 -0
- package/lib/mcp-server/dist/bluelamp-system.js +32 -0
- package/lib/mcp-server/dist/crypto-utils.js +27 -0
- package/lib/mcp-server/dist/database-version.js +33 -0
- package/lib/mcp-server/dist/index.js +62 -0
- package/lib/mcp-server/dist/plugins/base-plugin.js +24 -0
- package/lib/mcp-server/dist/plugins/plugin-manager.js +31 -0
- package/lib/mcp-server/dist/plugins/services/leonardo-plugin.js +95 -0
- package/lib/mcp-server/dist/plugins/services/leonardo-prompt-parser.js +36 -0
- package/lib/mcp-server/dist/plugins/services/portal-api-client.js +22 -0
- package/lib/mcp-server/dist/plugins/services/portal-plugin.js +52 -0
- package/lib/mcp-server/dist/secure-mcp-server.js +76 -0
- package/lib/mcp-server/dist/security/ApiKeyManager.js +24 -0
- package/lib/mcp-server/dist/security/InteractiveLogin.js +32 -0
- package/lib/mcp-server/dist/security/PortalAuthClient.js +1 -0
- package/lib/mcp-server/dist/security/SimpleAuthManager.js +1 -0
- package/lib/mcp-server/dist/security/TokenManager.js +25 -0
- package/lib/mcp-server/package.json +21 -0
- package/package.json +119 -35
- package/INSTALLATION_GUIDE.md +0 -109
- package/bin/blcf +0 -2
- package/bin/blcf2 +0 -28
- package/bin/blcf3 +0 -2
- package/bin/blcf4 +0 -2
- package/knowledge-injection/hooks/inject-encrypted.sh +0 -321
- package/lib/agents//343/203/225/343/202/231/343/203/253/343/203/274/343/203/251/343/203/263/343/203/225/343/202/232.md +0 -106
- package/lib/mcp-server/dist_optimized/bluelamp-system.d.ts +0 -29
- package/lib/mcp-server/dist_optimized/bluelamp-system.d.ts.map +0 -1
- package/lib/mcp-server/dist_optimized/bluelamp-system.js +0 -1
- package/lib/mcp-server/dist_optimized/bluelamp-system.js.bak +0 -340
- package/lib/mcp-server/dist_optimized/bluelamp-system.js.map +0 -1
- package/lib/mcp-server/dist_optimized/crypto-utils.d.ts +0 -33
- package/lib/mcp-server/dist_optimized/crypto-utils.d.ts.map +0 -1
- package/lib/mcp-server/dist_optimized/crypto-utils.js +0 -1
- package/lib/mcp-server/dist_optimized/crypto-utils.js.map +0 -1
- package/lib/mcp-server/dist_optimized/database-version.d.ts +0 -72
- package/lib/mcp-server/dist_optimized/database-version.d.ts.map +0 -1
- package/lib/mcp-server/dist_optimized/database-version.js +0 -2
- package/lib/mcp-server/dist_optimized/database-version.js.bak +0 -374
- package/lib/mcp-server/dist_optimized/database-version.js.map +0 -1
- package/lib/mcp-server/dist_optimized/index.d.ts +0 -3
- package/lib/mcp-server/dist_optimized/index.d.ts.map +0 -1
- package/lib/mcp-server/dist_optimized/index.js +0 -2
- package/lib/mcp-server/dist_optimized/index.js.map +0 -1
- package/lib/mcp-server/dist_optimized/secure-mcp-server.d.ts +0 -64
- package/lib/mcp-server/dist_optimized/secure-mcp-server.d.ts.map +0 -1
- package/lib/mcp-server/dist_optimized/secure-mcp-server.js +0 -1
- package/lib/mcp-server/dist_optimized/secure-mcp-server.js.bak +0 -1
- package/lib/mcp-server/dist_optimized/secure-mcp-server.js.bak2 +0 -1
- package/lib/mcp-server/dist_optimized/secure-mcp-server.js.map +0 -1
- package/lib/mcp-server/dist_optimized/security/InteractiveLogin.d.ts +0 -47
- package/lib/mcp-server/dist_optimized/security/InteractiveLogin.d.ts.map +0 -1
- package/lib/mcp-server/dist_optimized/security/InteractiveLogin.js +0 -1
- package/lib/mcp-server/dist_optimized/security/InteractiveLogin.js.map +0 -1
- package/lib/mcp-server/dist_optimized/security/PortalAuthClient.d.ts +0 -65
- package/lib/mcp-server/dist_optimized/security/PortalAuthClient.d.ts.map +0 -1
- package/lib/mcp-server/dist_optimized/security/PortalAuthClient.js +0 -1
- package/lib/mcp-server/dist_optimized/security/PortalAuthClient.js.map +0 -1
- package/lib/mcp-server/dist_optimized/security/SimpleAuthManager.backup +0 -294
- package/lib/mcp-server/dist_optimized/security/SimpleAuthManager.d.ts +0 -71
- package/lib/mcp-server/dist_optimized/security/SimpleAuthManager.d.ts.map +0 -1
- package/lib/mcp-server/dist_optimized/security/SimpleAuthManager.js +0 -1
- package/lib/mcp-server/dist_optimized/security/SimpleAuthManager.js.backup +0 -25
- package/lib/mcp-server/dist_optimized/security/SimpleAuthManager.js.map +0 -1
- package/lib/mcp-server/dist_optimized/security/TokenManager.d.ts +0 -61
- package/lib/mcp-server/dist_optimized/security/TokenManager.d.ts.map +0 -1
- package/lib/mcp-server/dist_optimized/security/TokenManager.js +0 -1
- package/lib/mcp-server/dist_optimized/security/TokenManager.js.map +0 -1
- package/scripts/setup-agents.js +0 -9
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,o,a){void 0===a&&(a=o)
|
|
3
|
+
var r=Object.getOwnPropertyDescriptor(t,o)
|
|
4
|
+
r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,a,r)}:function(e,t,o,a){void 0===a&&(a=o),e[a]=t[o]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[]
|
|
5
|
+
for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[t.length]=o)
|
|
6
|
+
return t},e(t)}
|
|
7
|
+
return function(t){if(t&&t.__esModule)return t
|
|
8
|
+
var o={}
|
|
9
|
+
if(null!=t)for(var a=e(t),r=0;r<a.length;r++)"default"!==a[r]&&__createBinding(o,t,a[r])
|
|
10
|
+
return __setModuleDefault(o,t),o}}(),__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}}
|
|
11
|
+
Object.defineProperty(exports,"__esModule",{value:!0})
|
|
12
|
+
const sdk_1=require("@leonardo-ai/sdk"),zod_1=require("zod"),fs=__importStar(require("fs/promises")),path=__importStar(require("path")),node_fetch_1=__importDefault(require("node-fetch")),sharp_1=__importDefault(require("sharp")),base_plugin_js_1=require("../base-plugin.js"),SimpleAuthManager_js_1=require("../../security/SimpleAuthManager.js"),leonardo_prompt_parser_js_1=require("./leonardo-prompt-parser.js"),LeonardoAnimateSchema=zod_1.z.object({folderPath:zod_1.z.string().default("./outputs").describe("画像が保存されているフォルダパス"),pattern:zod_1.z.string().default("*.png").describe("対象ファイルのパターン(例: *.png, leonardo_*.png)"),motionStrength:zod_1.z.number().int().min(1).max(10).default(5).describe("動きの強さ(1:穏やか~10:激しい)"),fileLimit:zod_1.z.number().int().min(1).max(10).optional().describe("処理する画像の最大数"),sortBy:zod_1.z.enum(["newest","oldest","name"]).default("newest").describe("ファイルの並び順"),outputPath:zod_1.z.string().default("./outputs/videos").describe("動画の保存先"),isPublic:zod_1.z.boolean().default(!1).describe("生成した動画を公開するか")}),LeonardoGenerateSchema=zod_1.z.object({prompt:zod_1.z.string().min(1,"プロンプトは必須です"),width:zod_1.z.number().int().min(512).max(2048).default(1024),height:zod_1.z.number().int().min(512).max(2048).default(1024),num_images:zod_1.z.number().int().min(1).max(8).default(1),modelId:zod_1.z.string().optional(),negativePrompt:zod_1.z.string().optional(),photoReal:zod_1.z.boolean().default(!1),photoRealVersion:zod_1.z.enum(["v1","v2"]).default("v2"),alchemy:zod_1.z.boolean().default(!0),guidance_scale:zod_1.z.number().min(1).max(30).default(7),seed:zod_1.z.number().int().optional(),steps:zod_1.z.number().int().min(30).max(60).default(50),contrast:zod_1.z.number().min(1).max(4.5).default(1),outputPath:zod_1.z.string().default("./outputs"),presetStyle:zod_1.z.enum(["CINEMATIC","DYNAMIC","ENVIRONMENTAL","GENERAL","ILLUSTRATION","PHOTOGRAPHY","RAYTRACED","RENDER_3D","SKETCH_BW","SKETCH_COLOR","VIBRANT"]).optional()})
|
|
13
|
+
class LeonardoPlugin extends base_plugin_js_1.BasePlugin{constructor(){super(...arguments),this.manifest={id:"leonardo",name:"Leonardo AI",version:"1.0.0",category:"AI",description:"Leonardo AIによる高品質な画像生成。PhotoReal、Alchemy v2対応",authType:"api_key",loadPriority:"high",tools:[{name:"leonardo_generate",description:"Leonardo AIで高品質な画像を生成します。プロンプトに基づいて1-8枚の画像を作成し、指定されたフォルダに保存します。",inputSchema:LeonardoGenerateSchema,outputExample:{success:!0,content:[{type:"text",text:"✅ Leonardo AIで2枚の画像を生成しました\\n📁 保存先:\\n- ./outputs/leonardo_20250830_001.png\\n- ./outputs/leonardo_20250830_002.png"}]}},{name:"leonardo_animate",description:"フォルダ内の画像をLeonardo AI Motion 1.0で動画化します。画像をアップロードして動きを追加し、MP4形式で保存します。",inputSchema:LeonardoAnimateSchema,outputExample:{success:!0,content:[{type:"text",text:"🎬 3枚の画像を動画化しました\\n📁 保存先:\\n- ./outputs/videos/motion_20250830_001.mp4\\n- ./outputs/videos/motion_20250830_002.mp4\\n- ./outputs/videos/motion_20250830_003.mp4"}]}}]},this.availableModels=[]}async initialize(){try{this.availableModels=await this.getDefaultModels(),this.markInitialized()}catch(e){throw e}}async shutdown(){this.leonardo=void 0}async executeTool(e,t,o){if(!this.isInitialized)return this.handleError("プラグインが初期化されていません","executeTool")
|
|
14
|
+
switch(e){case"leonardo_generate":return await this.generateImage(t,o)
|
|
15
|
+
case"leonardo_animate":return await this.animateImages(t,o)
|
|
16
|
+
default:return this.handleError("未知のツール: "+e,"executeTool")}}async generateImage(e,t){const o=Date.now()
|
|
17
|
+
try{const a=this.validateArgs(e,LeonardoGenerateSchema),r=leonardo_prompt_parser_js_1.LeonardoPromptParser.parsePrompt(a.prompt),n=this.mergeSettings(r,a)
|
|
18
|
+
if(leonardo_prompt_parser_js_1.LeonardoPromptParser.validateSettings(n).length,await this.initializeLeonardoClient(t),!this.leonardo)return this.handleError("Leonardo AI クライアントの初期化に失敗","generateImage")
|
|
19
|
+
await this.ensureOutputDirectory(n.outputPath||"./outputs")
|
|
20
|
+
const i=await this.requestGeneration(n),s=await this.waitForGeneration(i.generationId)
|
|
21
|
+
if("FAILED"===s.status)return this.handleError("画像生成に失敗しました","generateImage")
|
|
22
|
+
if(!s.images||0===s.images.length)return this.handleError("生成された画像が見つかりません","generateImage")
|
|
23
|
+
const d=await this.downloadAndSaveImages(s.images,n.outputPath||"./outputs"),l=Date.now()-o
|
|
24
|
+
return await this.recordUsage("leonardo_generate",t.userId,!0,l,{imageCount:d.length,prompt:n.cleanPrompt,modelId:n.modelId,parsedFromPrompt:!0}),this.createSuccessResponse([{type:"text",text:`✅ Leonardo AIで${d.length}枚の画像を生成しました\n📝 設定: ${n.modelName||"デフォルト"} / ${n.width}x${n.height}\n📁 保存先:\n${d.map(e=>"- "+e).join("\n")}`}],{generationId:s.id,imageCount:d.length,executionTimeMs:l,savedFiles:d,parsedSettings:{model:n.modelName,size:`${n.width}x${n.height}`,style:n.presetStyle}})}catch(e){const a=Date.now()-o
|
|
25
|
+
return await this.recordUsage("leonardo_generate",t.userId,!1,a,{error:e+""}),this.handleError(e,"generateImage")}}mergeSettings(e,t){return{prompt:e.cleanPrompt||t.prompt,width:t.width||e.width||1024,height:t.height||e.height||1024,num_images:t.num_images||e.num_images||1,modelId:t.modelId||e.modelId,modelName:e.modelName,photoReal:void 0!==t.photoReal?t.photoReal:e.photoReal,photoRealVersion:t.photoRealVersion||e.photoRealVersion||"v2",presetStyle:t.presetStyle||e.presetStyle,alchemy:void 0!==t.alchemy?t.alchemy:void 0===e.alchemy||e.alchemy,guidance_scale:t.guidance_scale||e.guidanceScale||7,steps:t.steps||e.steps||50,contrast:t.contrast||e.contrast||1,negativePrompt:t.negativePrompt,seed:t.seed,outputPath:t.outputPath,originalPrompt:t.prompt,cleanPrompt:e.cleanPrompt}}async initializeLeonardoClient(e){if(this.leonardo)return
|
|
26
|
+
let t=e.apiKey
|
|
27
|
+
if(!t)try{const e=await SimpleAuthManager_js_1.SimpleAuthManager.getToken()
|
|
28
|
+
if(e){const o=await(0,node_fetch_1.default)("http://localhost:8080/api/cli/user-credentials/leonardo-ai",{method:"GET",headers:{"X-CLI-Token":e,"Content-Type":"application/json"}})
|
|
29
|
+
if(o.ok){const e=await o.json()
|
|
30
|
+
e.success&&e.data&&e.data.apiKey&&(t=e.data.apiKey)}}}catch(e){}if(t||(t=process.env.LEONARDO_API_KEY),!t)throw Error("Leonardo AI APIキーが取得できません。bluelamp loginを実行してください。")
|
|
31
|
+
this.leonardo=new sdk_1.Leonardo({bearerAuth:t})}async requestGeneration(e){if(!this.leonardo)throw Error("Leonardo AIクライアントが初期化されていません")
|
|
32
|
+
try{const t={prompt:e.prompt,width:e.width||1024,height:e.height||1024,numImages:e.num_images||1,guidanceScale:e.guidance_scale||7,alchemy:!1!==e.alchemy}
|
|
33
|
+
e.modelId&&(t.modelId=e.modelId),e.negativePrompt&&(t.negativePrompt=e.negativePrompt),e.photoReal&&(t.photoReal=!0,t.photoRealVersion=e.photoRealVersion||"v2"),e.seed&&(t.seed=e.seed),e.steps&&(t.numInferenceSteps=e.steps),e.presetStyle&&(t.presetStyle=e.presetStyle)
|
|
34
|
+
const o=await this.leonardo.image.createGeneration(t),a=o?.object?.sdGenerationJob?.generationId
|
|
35
|
+
if(!a)throw Error("生成IDが取得できませんでした")
|
|
36
|
+
return{generationId:a}}catch(e){throw Error("Leonardo AI API エラー: "+(e.message||e))}}async waitForGeneration(e){if(!this.leonardo)throw Error("Leonardo AIクライアントが初期化されていません")
|
|
37
|
+
let t=0
|
|
38
|
+
for(;t<30;)try{const o=await this.leonardo.image.getGenerationById(e),a=o?.object?.generationsByPk
|
|
39
|
+
if("COMPLETE"===a?.status)return{id:e,status:"COMPLETE",images:a.generatedImages?.map(e=>({id:e.id||"",url:e.url||"",likelyGuid:e.likelyGuid||""}))}
|
|
40
|
+
if("FAILED"===a?.status)return{id:e,status:"FAILED"}
|
|
41
|
+
await new Promise(e=>setTimeout(e,1e4)),t++}catch(e){if(t++,t>=30)throw Error("生成確認の最大試行回数を超えました: "+e)
|
|
42
|
+
await new Promise(e=>setTimeout(e,5e3))}throw Error("生成がタイムアウトしました。Leonardo AIのサーバーが混雑している可能性があります。")}async downloadAndSaveImages(e,t){const o=[],a=new Date,r=a.toISOString().replace(/[:\-]/g,"").replace("T","_").replace(/\..+/,""),n=`${a.getTime()}_${Math.random().toString(36).substring(2,8)}`
|
|
43
|
+
for(let a=0;a<e.length;a++){const i=e[a]
|
|
44
|
+
try{const e=await(0,node_fetch_1.default)(i.url)
|
|
45
|
+
if(!e.ok)throw Error(`ダウンロード失敗: ${e.status} ${e.statusText}`)
|
|
46
|
+
const s=Buffer.from(await e.arrayBuffer()),d=`leonardo_${r}_${n}_${i.id?i.id.substring(0,8):""}_${(a+1+"").padStart(2,"0")}.png`,l=path.join(t,d)
|
|
47
|
+
await(0,sharp_1.default)(s).png({quality:95,compressionLevel:6}).toFile(l),o.push(l)}catch(e){}}if(0===o.length)throw Error("画像の保存に全て失敗しました")
|
|
48
|
+
return o}async ensureOutputDirectory(e){try{await fs.mkdir(e,{recursive:!0})}catch(t){throw Error(`出力ディレクトリの作成に失敗: ${e} - ${t}`)}}async getDefaultModels(){return[{id:"6bef9f1b-29cb-40c7-b9df-32b51c1f67d3",name:"Leonardo Phoenix",description:"2024年リリースの最新モデル。高いプロンプト忠実度と詳細なテキスト生成が特徴",supportsAlchemy:!0},{id:"aa77f04e-3eec-4034-9c07-d0f619684628",name:"Leonardo Diffusion XL",description:"SDXL基盤の高品質汎用モデル",supportsPhotoReal:!0,supportsAlchemy:!0},{id:"1e60896f-3c26-4296-8ecc-53e2afecc132",name:"Leonardo Kino XL",description:"シネマティック品質の画像生成に特化",supportsPhotoReal:!0,supportsAlchemy:!0},{id:"5c232a9e-9061-4777-980a-ddc8e65647c6",name:"Leonardo Vision XL",description:"フォトリアルな画像生成に最適化",supportsPhotoReal:!0,supportsAlchemy:!0}]}async performHealthCheck(){const e={userId:"health_check",service:"leonardo",apiKey:process.env.LEONARDO_API_KEY}
|
|
49
|
+
if(!e.apiKey)throw Error("Leonardo AI APIキーが設定されていません")
|
|
50
|
+
try{new sdk_1.Leonardo({bearerAuth:e.apiKey})}catch(e){throw Error("Leonardo AI接続テストに失敗: "+e)}}async animateImages(e,t){const o=Date.now()
|
|
51
|
+
try{const a=this.validateArgs(e,LeonardoAnimateSchema)
|
|
52
|
+
if(await this.initializeLeonardoClient(t),!this.leonardo)return this.handleError("Leonardo AI クライアントの初期化に失敗","animateImages")
|
|
53
|
+
const r=await this.findImageFiles(a.folderPath,a.pattern,a.sortBy,a.fileLimit)
|
|
54
|
+
if(0===r.length)return this.handleError(`${a.folderPath}に対象画像が見つかりません(パターン: ${a.pattern})`,"animateImages")
|
|
55
|
+
await this.ensureOutputDirectory(a.outputPath)
|
|
56
|
+
const n=[],i=[]
|
|
57
|
+
for(let e=0;e<r.length;e++){const t=r[e]
|
|
58
|
+
try{const e=await this.uploadImageToLeonardo(t),o=await this.requestMotionGeneration(e,a.motionStrength,a.isPublic),r=await this.waitForMotionGeneration(o),i=await this.downloadVideo(r,a.outputPath,t)
|
|
59
|
+
n.push(i)}catch(e){const o=`❌ ${path.basename(t)}: ${e}`
|
|
60
|
+
i.push(o)}}const s=Date.now()-o
|
|
61
|
+
return await this.recordUsage("leonardo_animate",t.userId,n.length>0,s,{processedImages:r.length,generatedVideos:n.length,errors:i.length}),0===n.length?this.handleError("すべての動画生成に失敗しました","animateImages"):this.createSuccessResponse([{type:"text",text:`🎬 ${n.length}/${r.length}個の動画を生成しました\n📁 保存先:\n${n.map(e=>"- "+e).join("\n")}${i.length>0?"\n\n⚠️ エラー:\n"+i.join("\n"):""}`}],{processedImages:r.length,generatedVideos:n.length,executionTimeMs:s,savedFiles:n})}catch(e){const a=Date.now()-o
|
|
62
|
+
return await this.recordUsage("leonardo_animate",t.userId,!1,a,{error:e+""}),this.handleError(e,"animateImages")}}async findImageFiles(e,t,o,a){const r=(await Promise.resolve().then(()=>__importStar(require("glob")))).glob,n=path.join(e,t),i=await r(n,{nodir:!0,absolute:!0})
|
|
63
|
+
if(0===i.length)return[]
|
|
64
|
+
const s=await Promise.all(i.map(async e=>({path:e,stat:await fs.stat(e)})))
|
|
65
|
+
return s.sort((e,t)=>{switch(o){case"newest":return t.stat.mtime.getTime()-e.stat.mtime.getTime()
|
|
66
|
+
case"oldest":return e.stat.mtime.getTime()-t.stat.mtime.getTime()
|
|
67
|
+
default:return e.path.localeCompare(t.path)}}),(a?s.slice(0,a):s).map(e=>e.path)}async uploadImageToLeonardo(e){if(!this.leonardo)throw Error("Leonardo AIクライアントが初期化されていません")
|
|
68
|
+
const t=await fs.readFile(e),o=path.basename(e),a=await this.leonardo.image.uploadInitImage({extension:path.extname(o).substring(1)})
|
|
69
|
+
if(!a.object?.uploadInitImage?.url||!a.object?.uploadInitImage?.id)throw Error("アップロードURL取得に失敗しました")
|
|
70
|
+
const{url:r,id:n}=a.object.uploadInitImage,i=await(0,node_fetch_1.default)(r,{method:"PUT",body:t,headers:{"Content-Type":"image/png"}})
|
|
71
|
+
if(!i.ok)throw Error("画像アップロード失敗: "+i.status)
|
|
72
|
+
return n}async requestMotionGeneration(e,t,o){if(!this.leonardo)throw Error("Leonardo AIクライアントが初期化されていません")
|
|
73
|
+
const a=await this.getLeonardoApiKey(),r=await(0,node_fetch_1.default)("https://cloud.leonardo.ai/api/rest/v1/generations-motion-svd",{method:"POST",headers:{Authorization:"Bearer "+a,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({imageId:e,motionStrength:t,isInitImage:!0,isPublic:o})})
|
|
74
|
+
if(!r.ok){const e=await r.text()
|
|
75
|
+
throw Error(`Motion生成リクエスト失敗: ${r.status} - ${e}`)}const n=await r.json()
|
|
76
|
+
if(!n.motionSvdGenerationJob?.generationId)throw Error("Motion生成IDが取得できませんでした")
|
|
77
|
+
return n.motionSvdGenerationJob.generationId}async waitForMotionGeneration(e){let t=0
|
|
78
|
+
const o=await this.getLeonardoApiKey()
|
|
79
|
+
for(;t<60;)try{const a=await(0,node_fetch_1.default)("https://cloud.leonardo.ai/api/rest/v1/generations/"+e,{method:"GET",headers:{Authorization:"Bearer "+o,Accept:"application/json"}})
|
|
80
|
+
if(!a.ok)throw Error("生成状況確認失敗: "+a.status)
|
|
81
|
+
const r=(await a.json()).generationsByPk
|
|
82
|
+
if("COMPLETE"===r?.status){const e=r.generatedVideos?.[0]
|
|
83
|
+
if(e?.url)return e.url
|
|
84
|
+
throw Error("動画URLが見つかりません")}if("FAILED"===r?.status)throw Error("動画生成に失敗しました")
|
|
85
|
+
await new Promise(e=>setTimeout(e,1e4)),t++}catch(e){if(t++,t>=60)throw Error("生成確認の最大試行回数を超えました: "+e)
|
|
86
|
+
await new Promise(e=>setTimeout(e,5e3))}throw Error("動画生成がタイムアウトしました")}async getLeonardoApiKey(){if(this.leonardo){const e=this.leonardo.config
|
|
87
|
+
if(e?.bearerAuth)return e.bearerAuth}try{const e=await SimpleAuthManager_js_1.SimpleAuthManager.getToken()
|
|
88
|
+
if(e){const t=await(0,node_fetch_1.default)("http://localhost:8080/api/cli/user-credentials/leonardo-ai",{method:"GET",headers:{"X-CLI-Token":e,"Content-Type":"application/json"}})
|
|
89
|
+
if(t.ok){const e=await t.json()
|
|
90
|
+
if(e.success&&e.data?.apiKey)return e.data.apiKey}}}catch(e){}const e=process.env.LEONARDO_API_KEY
|
|
91
|
+
if(e)return e
|
|
92
|
+
throw Error("Leonardo AI APIキーが取得できません。bluelamp loginを実行してください。")}async downloadVideo(e,t,o){const a=await(0,node_fetch_1.default)(e)
|
|
93
|
+
if(!a.ok)throw Error("動画ダウンロード失敗: "+a.status)
|
|
94
|
+
const r=Buffer.from(await a.arrayBuffer()),n=(new Date).toISOString().replace(/[:\-]/g,"").replace("T","_").replace(/\..+/,""),i=`motion_${path.basename(o,path.extname(o))}_${n}.mp4`,s=path.join(t,i)
|
|
95
|
+
return await fs.writeFile(s,r),s}}exports.default=LeonardoPlugin
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.LeonardoPromptParser=exports.ASPECT_RATIOS=exports.PRESET_STYLES=exports.LEONARDO_MODELS=void 0,exports.LEONARDO_MODELS={phoenix:{id:"6bef9f1b-29cb-40c7-b9df-32b51c1f67d3",name:"Leonardo Phoenix",keywords:["phoenix","フェニックス","最新","latest"],supportsAlchemy:!0,supportsPhotoReal:!1},vision_xl:{id:"5c232a9e-9061-4777-980a-ddc8e65647c6",name:"Leonardo Vision XL",keywords:["vision","ビジョン","フォトリアル","photorealistic","リアル","写真"],supportsAlchemy:!0,supportsPhotoReal:!0},diffusion_xl:{id:"aa77f04e-3eec-4034-9c07-d0f619684628",name:"Leonardo Diffusion XL",keywords:["diffusion","ディフュージョン","汎用","general","バランス"],supportsAlchemy:!0,supportsPhotoReal:!0},kino_xl:{id:"1e60896f-3c26-4296-8ecc-53e2afecc132",name:"Leonardo Kino XL",keywords:["kino","キノ","映画","cinematic","シネマ","movie","film"],supportsAlchemy:!0,supportsPhotoReal:!0,preferredAspectRatio:"21:9"},anime_xl:{id:"e71a1c2f-4f80-4800-934f-2c68979d8cc8",name:"Leonardo Anime XL",keywords:["anime","アニメ","manga","マンガ","漫画","cartoon","illustration"],supportsAlchemy:!0,supportsPhotoReal:!1},lightning_xl:{id:"b24e16ff-06e3-43eb-8aec-8ab3166edcb6",name:"Leonardo Lightning XL",keywords:["lightning","ライトニング","高速","fast","quick","rapid","速い"],supportsAlchemy:!1,supportsPhotoReal:!1}},exports.PRESET_STYLES={cinematic:{value:"CINEMATIC",keywords:["cinematic","シネマティック","映画的","movie","film"],preferredModel:"kino_xl"},dynamic:{value:"DYNAMIC",keywords:["dynamic","ダイナミック","動的","action","motion"],preferredModel:"diffusion_xl"},photography:{value:"PHOTOGRAPHY",keywords:["photography","フォトグラフィー","写真","photo","camera"],preferredModel:"vision_xl"},vibrant:{value:"VIBRANT",keywords:["vibrant","ビブラント","鮮やか","colorful","vivid"]},raytraced:{value:"RAYTRACED",keywords:["raytraced","レイトレース","3D","render","レンダー"]},illustration:{value:"ILLUSTRATION",keywords:["illustration","イラスト","drawing","絵","artwork"]}},exports.ASPECT_RATIOS={"1:1":{keywords:["1:1","正方形","square","スクエア","インスタ","instagram"],width:1024,height:1024},"16:9":{keywords:["16:9","横長","wide","ワイド","youtube","ユーチューブ","HD"],width:1920,height:1080},"9:16":{keywords:["9:16","縦長","portrait","ポートレート","tiktok","ティックトック","stories","ストーリー"],width:1080,height:1920},"4:3":{keywords:["4:3","standard","スタンダード","標準"],width:1024,height:768},"3:4":{keywords:["3:4","縦向き標準"],width:768,height:1024},"2:3":{keywords:["2:3","縦向き","vertical","バーティカル"],width:1024,height:1536},"3:2":{keywords:["3:2","横向き","horizontal","ホリゾンタル"],width:1536,height:1024},"21:9":{keywords:["21:9","ultrawide","ウルトラワイド","cinema","シネマスコープ"],width:2560,height:1080},facebook:{keywords:["facebook","フェイスブック","fb"],width:1200,height:630},twitter:{keywords:["twitter","ツイッター","x"],width:1200,height:675},linkedin:{keywords:["linkedin","リンクトイン"],width:1200,height:627}}
|
|
3
|
+
class LeonardoPromptParser{static parsePrompt(e){const t={cleanPrompt:e},o=this.extractAspectRatio(e)
|
|
4
|
+
o&&(Object.assign(t,o),t.cleanPrompt=o.cleanPrompt||t.cleanPrompt)
|
|
5
|
+
const r=this.extractModel(t.cleanPrompt)
|
|
6
|
+
r&&(Object.assign(t,r),t.cleanPrompt=r.cleanPrompt||t.cleanPrompt)
|
|
7
|
+
const a=this.extractStyle(t.cleanPrompt)
|
|
8
|
+
a&&(Object.assign(t,a),t.cleanPrompt=a.cleanPrompt||t.cleanPrompt)
|
|
9
|
+
const i=this.extractQuality(t.cleanPrompt)
|
|
10
|
+
i&&(Object.assign(t,i),t.cleanPrompt=i.cleanPrompt||t.cleanPrompt)
|
|
11
|
+
const s=this.extractImageCount(t.cleanPrompt)
|
|
12
|
+
s&&(Object.assign(t,s),t.cleanPrompt=s.cleanPrompt||t.cleanPrompt)
|
|
13
|
+
const c=this.extractPhotoReal(t.cleanPrompt)
|
|
14
|
+
return c&&(Object.assign(t,c),t.cleanPrompt=c.cleanPrompt||t.cleanPrompt),t.cleanPrompt=this.cleanupPrompt(t.cleanPrompt),t}static extractAspectRatio(e){let t=e
|
|
15
|
+
const o=e.match(/(\d{3,4})\s*[x×]\s*(\d{3,4})/i)
|
|
16
|
+
if(o){const e=parseInt(o[1]),r=parseInt(o[2])
|
|
17
|
+
return t=t.replace(o[0],"").trim(),{width:e,height:r,cleanPrompt:t}}for(const[o,r]of Object.entries(exports.ASPECT_RATIOS)){const o=r.keywords.join("|"),a=RegExp(`\\b(${o})\\b`,"gi")
|
|
18
|
+
if(e.match(a))return t=t.replace(a,"").trim(),{width:r.width,height:r.height,cleanPrompt:t}}return null}static extractModel(e){let t=e
|
|
19
|
+
for(const[o,r]of Object.entries(exports.LEONARDO_MODELS))for(const keyword of r.keywords){const a=RegExp(/[\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FAF]/.test(keyword)?keyword:`\\b${keyword}\\b`,"gi")
|
|
20
|
+
if(e.match(a))return t=t.replace(a,"").trim(),"vision_xl"===o&&e.match(/photoreal|フォトリアル/gi)?{photoReal:!0,photoRealVersion:"v2",modelId:r.id,modelName:r.name,cleanPrompt:t}:{modelId:r.id,modelName:r.name,cleanPrompt:t}}return null}static extractStyle(e){let t=e
|
|
21
|
+
for(const[o,r]of Object.entries(exports.PRESET_STYLES))for(const keyword of r.keywords){const o=RegExp(/[\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FAF]/.test(keyword)?keyword:`\\b${keyword}\\b`,"gi")
|
|
22
|
+
if(e.match(o)){t=t.replace(o,"").trim()
|
|
23
|
+
const a={presetStyle:r.value,cleanPrompt:t}
|
|
24
|
+
if("preferredModel"in r&&r.preferredModel&&!e.match(/model|モデル/gi)){const e=exports.LEONARDO_MODELS[r.preferredModel]
|
|
25
|
+
e&&(a.modelId=e.id,a.modelName=e.name)}return a}}return null}static extractQuality(e){let t=e
|
|
26
|
+
const o={}
|
|
27
|
+
return e.match(/高品質|高画質|最高品質|ultra|high quality|best quality/gi)?(o.steps=60,o.guidanceScale=10,o.alchemy=!0,t=t.replace(/高品質|高画質|最高品質|ultra|high quality|best quality/gi,"").trim()):e.match(/中品質|標準|standard|medium quality/gi)?(o.steps=50,o.guidanceScale=7,o.alchemy=!0,t=t.replace(/中品質|標準|standard|medium quality/gi,"").trim()):e.match(/低品質|ドラフト|draft|quick|fast|低画質/gi)&&(o.steps=30,o.guidanceScale=5,o.alchemy=!1,t=t.replace(/低品質|ドラフト|draft|quick|fast|低画質/gi,"").trim()),e.match(/alchemy|アルケミー|魔法/gi)&&(o.alchemy=!0,t=t.replace(/alchemy|アルケミー|魔法/gi,"").trim()),Object.keys(o).length>0?(o.cleanPrompt=t,o):null}static extractImageCount(e){let t=e
|
|
28
|
+
const o=e.match(/(\d+)\s*[枚つ個]/)
|
|
29
|
+
if(o){const e=Math.min(parseInt(o[1]),8)
|
|
30
|
+
return t=t.replace(o[0],"").trim(),{num_images:e,cleanPrompt:t}}const r=e.match(/(\d+)\s*(images?|pictures?|photos?|pieces?)/i)
|
|
31
|
+
if(r){const e=Math.min(parseInt(r[1]),8)
|
|
32
|
+
return t=t.replace(r[0],"").trim(),{num_images:e,cleanPrompt:t}}return null}static extractPhotoReal(e){let t=e
|
|
33
|
+
return e.match(/photoreal|フォトリアル|写真のような|photorealistic/gi)?(t=t.replace(/photoreal|フォトリアル|写真のような|photorealistic/gi,"").trim(),{photoReal:!0,photoRealVersion:"v2",cleanPrompt:t}):null}static cleanupPrompt(e){return e.replace(/\s+/g," ").replace(/^\s*[,、]\s*/g,"").replace(/\s*[,、]\s*$/g,"").replace(/[,、]\s*[,、]/g,",").replace(/で\s*$/g,"").replace(/を\s*$/g,"").trim()}static validateSettings(e){const t=[]
|
|
34
|
+
if(e.photoReal&&e.modelId){const o=Object.values(exports.LEONARDO_MODELS).find(t=>t.id===e.modelId)
|
|
35
|
+
o&&!o.supportsPhotoReal&&t.push(`警告: ${o.name}はPhotoRealをサポートしていません`)}if(e.alchemy&&e.modelId){const o=Object.values(exports.LEONARDO_MODELS).find(t=>t.id===e.modelId)
|
|
36
|
+
o&&!o.supportsAlchemy&&t.push(`警告: ${o.name}はAlchemyをサポートしていません`)}return e.width&&e.width>2048&&t.push("警告: 幅が2048pxを超えています"),e.height&&e.height>2048&&t.push("警告: 高さが2048pxを超えています"),t}}exports.LeonardoPromptParser=LeonardoPromptParser
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}}
|
|
3
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.portalAPIClient=exports.PortalAPIClient=void 0
|
|
4
|
+
const node_fetch_1=__importDefault(require("node-fetch")),SimpleAuthManager_js_1=require("../../security/SimpleAuthManager.js")
|
|
5
|
+
class PortalAPIClient{constructor(){this.baseURL=process.env.BLUELAMP_PORTAL_API_URL||"http://localhost:8080",this.timeout=3e4,this.retryAttempts=3,this.retryDelay=1e3}async getAuthToken(){try{return await SimpleAuthManager_js_1.SimpleAuthManager.getToken()||null}catch(t){return null}}async makeRequest(t,e={}){const token=await this.getAuthToken()
|
|
6
|
+
if(!token)throw Error("Portal API: 認証トークンが利用できません")
|
|
7
|
+
const a=`${this.baseURL}${t}`,r={method:"GET",headers:{"X-CLI-Token":token,"Content-Type":"application/json","User-Agent":"BlueLamp-MCP-Client/1.0",...e.headers},timeout:this.timeout,...e}
|
|
8
|
+
for(let t=1;t<=this.retryAttempts;t++)try{const t=new AbortController,e=setTimeout(()=>t.abort(),this.timeout),s=await(0,node_fetch_1.default)(a,{...r,signal:t.signal})
|
|
9
|
+
if(clearTimeout(e),!s.ok){if(401===s.status)throw Error("Portal API: 認証失敗 - 無効なトークン")
|
|
10
|
+
if(404===s.status)return null
|
|
11
|
+
throw Error(`Portal API: リクエスト失敗 - ${s.status} ${s.statusText}`)}return await s.json()}catch(e){if(t===this.retryAttempts)throw e
|
|
12
|
+
await new Promise(e=>setTimeout(e,this.retryDelay*t))}return null}async resolveSlot(t){try{const e="/api/slots/resolve/"+t,a=await this.makeRequest(e)
|
|
13
|
+
return a&&a.success?{slotNumber:t,orchestratorEndpoint:a.data.orchestratorEndpoint,configuration:a.data.configuration,status:a.data.status,lastUpdated:a.data.lastUpdated}:null}catch(t){return null}}async getAllSlots(){try{const t="/api/slots/all",e=await this.makeRequest(t)
|
|
14
|
+
return e?.data?.slots||[]}catch(t){return[]}}async getUsageStats(){try{const t="/api/usage/stats",e=await this.makeRequest(t)
|
|
15
|
+
return e?.data||null}catch(t){return null}}async updateUsage(t,e="orchestrator_call"){try{const a="/api/usage/update",r=await this.makeRequest(a,{method:"POST",body:JSON.stringify({slotNumber:t,operation:e,timestamp:(new Date).toISOString()})})
|
|
16
|
+
return r?.success||!1}catch(t){return!1}}async checkFreeUsageAvailable(){try{const t=await this.getUsageStats()
|
|
17
|
+
if(!t)return!1
|
|
18
|
+
const e=t.freeUsageLimit||3
|
|
19
|
+
return(t.totalUsage||0)<e}catch(t){return!1}}async getUserInfo(){try{const t="/api/user/info",e=await this.makeRequest(t)
|
|
20
|
+
return e?.data||null}catch(t){return null}}async getServiceCredentials(t){try{const e="/api/cli/user-credentials/"+t,a=await this.makeRequest(e)
|
|
21
|
+
return a?.success&&a.data?a.data:null}catch(t){return null}}async injectKnowledge(keyword,t){try{const e="/api/knowledge/inject",a=await this.makeRequest(e,{method:"POST",body:JSON.stringify({keyword:keyword,context:t,level:"detailed"})})
|
|
22
|
+
return a?.success&&a.data?{success:!0,knowledge:a.data.knowledge,sources:a.data.sources,confidence:a.data.confidence}:{success:!1,error:"Knowledge injection failed"}}catch(t){return{success:!1,error:"Knowledge injection error: "+t}}}}exports.PortalAPIClient=PortalAPIClient,exports.portalAPIClient=new PortalAPIClient
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r)
|
|
3
|
+
var n=Object.getOwnPropertyDescriptor(t,r)
|
|
4
|
+
n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,a,n)}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[]
|
|
5
|
+
for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r)
|
|
6
|
+
return t},e(t)}
|
|
7
|
+
return function(t){if(t&&t.__esModule)return t
|
|
8
|
+
var r={}
|
|
9
|
+
if(null!=t)for(var a=e(t),n=0;n<a.length;n++)"default"!==a[n]&&__createBinding(r,t,a[n])
|
|
10
|
+
return __setModuleDefault(r,t),r}}()
|
|
11
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.DynamicSlotResolver=void 0
|
|
12
|
+
const zod_1=require("zod"),fs=__importStar(require("fs/promises")),path=__importStar(require("path")),os=__importStar(require("os")),base_plugin_js_1=require("../base-plugin.js"),SimpleAuthManager_js_1=require("../../security/SimpleAuthManager.js"),portal_api_client_js_1=require("./portal-api-client.js"),DelegateToAgentSchema=zod_1.z.object({agentName:zod_1.z.string().min(1,"エージェント名は必須です"),token:zod_1.z.string().optional()}),InjectKnowledgeSchema=zod_1.z.object({keyword:zod_1.z.string().min(1,"キーワードは必須です"),context:zod_1.z.string().optional(),level:zod_1.z.string().default("detailed")}),SaveKnowledgeSchema=zod_1.z.object({knowledge:zod_1.z.string().min(1,"知識内容は必須です"),identifier:zod_1.z.string().min(1,"識別子は必須です"),token:zod_1.z.string().min(1,"トークンは必須です")}),ListPromptsSchema=zod_1.z.object({category:zod_1.z.string().optional(),token:zod_1.z.string().min(1,"トークンは必須です")})
|
|
13
|
+
class DynamicSlotResolver{constructor(){this.cacheTimeout=3e5,this.slotCache=new Map,this.agentSlotMapping={orchestrator:1,orchestrator1:1,orchestrator2:2,orchestrator3:3,orchestrator4:4,orchestrator5:5},this.portalClient=portal_api_client_js_1.portalAPIClient}extractSlotNumber(e){if(!e||"string"!=typeof e)throw Error("Invalid agent name provided")
|
|
14
|
+
const t=e.toLowerCase().trim()
|
|
15
|
+
if(this.agentSlotMapping[t])return this.agentSlotMapping[t]
|
|
16
|
+
const r=t.match(/^orchestrator(\d+)?$/)
|
|
17
|
+
if(r)return r[1]?parseInt(r[1],10):1
|
|
18
|
+
const a=e.match(/\d+/)
|
|
19
|
+
return a?parseInt(a[0],10):1}async getSlotConfiguration(e){const t="slot_"+e,r=this.slotCache.get(t)
|
|
20
|
+
if(r&&Date.now()-r.timestamp<this.cacheTimeout)return r.data
|
|
21
|
+
try{const r=await this.portalClient.resolveSlot(e)
|
|
22
|
+
return this.slotCache.set(t,{data:r,timestamp:Date.now()}),r}catch(e){return null}}async resolveOrchestratorConfig(e){try{const t=this.extractSlotNumber(e),r=await this.getSlotConfiguration(t)
|
|
23
|
+
return r?await this.portalClient.checkFreeUsageAvailable()?{success:!0,slotNumber:t,agentName:e,orchestratorEndpoint:r.orchestratorEndpoint,configuration:r.configuration}:{success:!1,error:"Free usage limit exceeded",slotNumber:t,agentName:e,usageExceeded:!0,usageFallback:"Please upgrade to continue using orchestrator features"}:{success:!1,error:`Slot ${t} is not configured in Portal`,slotNumber:t,agentName:e,fallback:this.getFallbackConfig(t)}}catch(t){return{success:!1,error:"Failed to resolve configuration: "+t,agentName:e}}}async delegateToAgent(e){const t=await this.resolveOrchestratorConfig(e)
|
|
24
|
+
if(!t.success)return t
|
|
25
|
+
try{return await this.portalClient.updateUsage(t.slotNumber,"orchestrator_call"),{success:!0,message:"Successfully delegated to "+e,slotNumber:t.slotNumber,orchestratorEndpoint:t.orchestratorEndpoint,configuration:t.configuration}}catch(t){return{success:!1,error:"Delegation failed: "+t,agentName:e}}}getFallbackConfig(e){return{endpoint:"http://localhost:8080/api/orchestrator/fallback",message:`Slot ${e} not configured, using fallback`,features:["basic_responses","error_handling"]}}}exports.DynamicSlotResolver=DynamicSlotResolver
|
|
26
|
+
class PortalPlugin extends base_plugin_js_1.BasePlugin{constructor(){super(...arguments),this.manifest={id:"portal",name:"Portal Integration",version:"1.0.0",category:"Integration",description:"Portal APIとの統合機能を提供(エージェント委譲、知識注入、認証管理)",authType:"token",loadPriority:"high",tools:[{name:"delegate_to_agent",description:"専門エージェントにタスクを委譲します。動的スロット解決により適切なオーケストレーターに接続します。",inputSchema:DelegateToAgentSchema,outputExample:{success:!0,content:[{type:"text",text:"✅ orchestrator2 にタスクを委譲しました\\n🔗 エンドポイント: https://orchestrator-slot2.example.com\\n📊 使用回数を更新しました"}]}},{name:"inject_knowledge",description:"Portal APIから専門知識を注入します。キーワードに基づいて関連する知識ベースからコンテンツを取得します。",inputSchema:InjectKnowledgeSchema,outputExample:{success:!0,content:[{type:"text",text:"🧠 専門知識を注入しました\\n🔍 キーワード: React\\n📚 知識内容: Reactは..."}]}},{name:"save_knowledge",description:"暗号化された知識を保存します。",inputSchema:SaveKnowledgeSchema,outputExample:{success:!0,content:[{type:"text",text:"💾 知識を暗号化して保存しました"}]}},{name:"list_prompts",description:"利用可能な暗号化プロンプトテンプレートを一覧表示します。",inputSchema:ListPromptsSchema,outputExample:{success:!0,content:[{type:"text",text:"📋 利用可能なプロンプト: システムアーキテクト, UI/UXデザイナー, 実装エージェント"}]}}]},this.validTokens=new Set,this.promptCache=new Map,this.cacheTimeout=3e5}async initialize(){try{this.logFilePath=path.join(os.tmpdir(),`portal-debug-${Date.now()}.log`),this.debugLog("Portal Integration Plugin starting - Log file: "+this.logFilePath),this.slotResolver=new DynamicSlotResolver,this.keywordMapping=new Map([["orchestrator","オーケストレーター"],["requirements-engineer","要件定義エンジニア"],["ui-ux-designer","UI/UXデザイナー"],["data-modeling-engineer","データモデリングエンジニア"],["system-architect","システムアーキテクト"],["implementation-consultant","実装コンサルタント"],["environment-setup","環境構築"],["prototype-implementation","プロトタイプ実装"],["implementation-agent","実装エージェント"],["debug-agent","デバッグエージェント"],["deploy-specialist","デプロイスペシャリスト"],["page-creator","ページクリエイター"],["refactoring-engineer","リファクタリングエンジニア"],["ai-friendliness-diagnostic","AI親和性診断"]]),await this.initializeTokens(),this.markInitialized()}catch(e){throw e}}async shutdown(){this.validTokens.clear(),this.promptCache.clear()}async executeTool(e,t,r){if(!this.isInitialized)return this.handleError("プラグインが初期化されていません","executeTool")
|
|
27
|
+
this.debugLog("Tool called: "+e,t)
|
|
28
|
+
try{switch(e){case"delegate_to_agent":return await this.handleDelegateToAgent(t)
|
|
29
|
+
case"inject_knowledge":return await this.handleInjectKnowledge(t)
|
|
30
|
+
case"save_knowledge":return await this.handleSaveKnowledge(t)
|
|
31
|
+
case"list_prompts":return await this.handleListPrompts(t)
|
|
32
|
+
case"get_debug_log_path":return this.handleGetDebugLogPath()
|
|
33
|
+
default:return this.handleError("未知のツール: "+e,"executeTool")}}catch(e){return this.handleError(e,"executeTool")}}async handleDelegateToAgent(e){try{const t=this.validateArgs(e,DelegateToAgentSchema),token=await this.getSystemToken()
|
|
34
|
+
if(!token||!this.validateToken(token))return this.createErrorResponse("システム認証に失敗しました","SYSTEM_AUTH_ERROR")
|
|
35
|
+
this.debugLog("Delegating to agent: "+t.agentName)
|
|
36
|
+
const r=await this.slotResolver.delegateToAgent(t.agentName)
|
|
37
|
+
if(!r.success){this.debugLog(`Delegation failed for ${t.agentName}:`,r)
|
|
38
|
+
const e=r.usageExceeded?"USAGE_EXCEEDED":"SLOT_RESOLUTION_FAILED"
|
|
39
|
+
return this.createErrorResponse(r.error||"エージェント委譲に失敗しました",e,{agentName:t.agentName,slotNumber:r.slotNumber,fallback:r.fallback||r.usageFallback})}return this.createSuccessResponse([{type:"text",text:`✅ ${t.agentName} にタスクを委譲しました\n🔗 エンドポイント: ${r.orchestratorEndpoint}\n📊 スロット番号: ${r.slotNumber}\n⏰ 使用回数を更新しました`}],{agentName:t.agentName,slotNumber:r.slotNumber,orchestratorEndpoint:r.orchestratorEndpoint,success:!0})}catch(e){return this.handleError(e,"handleDelegateToAgent")}}async handleInjectKnowledge(e){try{const t=this.validateArgs(e,InjectKnowledgeSchema),token=await this.getSystemToken()
|
|
40
|
+
if(!token||!this.validateToken(token))return this.createErrorResponse("システム認証に失敗しました","SYSTEM_AUTH_ERROR")
|
|
41
|
+
const r=`${t.keyword}:${t.level}`,a=this.promptCache.get(r)
|
|
42
|
+
let n,o="unknown"
|
|
43
|
+
if(a&&Date.now()-a.timestamp<this.cacheTimeout)n=a.content,o=a.source||"cache",this.debugLog("Using cached knowledge for "+t.keyword)
|
|
44
|
+
else{const e=await portal_api_client_js_1.portalAPIClient.injectKnowledge(t.keyword,t.context)
|
|
45
|
+
if(!e.success)return this.createErrorResponse(e.error||"知識注入に失敗しました","KNOWLEDGE_INJECTION_FAILED")
|
|
46
|
+
n=e.knowledge,o="portal_api",this.promptCache.set(r,{content:n,timestamp:Date.now(),source:o}),this.debugLog("Knowledge injected from Portal API for "+t.keyword)}return this.createSuccessResponse([{type:"text",text:`🧠 専門知識を注入しました\n🔍 キーワード: ${t.keyword}\n📚 ソース: ${o}\n📖 知識内容: ${n||"知識が見つかりませんでした"}`}],{keyword:t.keyword,source:o,knowledgeContent:n,cached:"cache"===o})}catch(e){return this.handleError(e,"handleInjectKnowledge")}}async handleSaveKnowledge(e){try{const t=this.validateArgs(e,SaveKnowledgeSchema)
|
|
47
|
+
return this.validateToken(t.token)?this.createSuccessResponse([{type:"text",text:`💾 知識を暗号化して保存しました\n🔑 識別子: ${t.identifier}\n📝 サイズ: ${t.knowledge.length} 文字`}],{identifier:t.identifier,saved:!0}):this.createErrorResponse("無効な認証トークンです","AUTH_ERROR")}catch(e){return this.handleError(e,"handleSaveKnowledge")}}async handleListPrompts(e){try{const t=this.validateArgs(e,ListPromptsSchema)
|
|
48
|
+
if(!this.validateToken(t.token))return this.createErrorResponse("無効な認証トークンです","AUTH_ERROR")
|
|
49
|
+
const r=Array.from(this.keywordMapping.entries()).map(([e,name])=>({key:e,name:name})),a=r.map(e=>`- ${e.name} (${e.key})`).join("\n")
|
|
50
|
+
return this.createSuccessResponse([{type:"text",text:`📋 利用可能なプロンプトテンプレート:\n${a}\n\n💡 inject_knowledge ツールで任意のキーワードを使用して専門知識を取得できます。`}],{availablePrompts:r,count:r.length})}catch(e){return this.handleError(e,"handleListPrompts")}}handleGetDebugLogPath(){return this.createSuccessResponse([{type:"text",text:JSON.stringify({success:!0,logPath:this.logFilePath,message:"Debug log is being written to: "+this.logFilePath})}],{logPath:this.logFilePath})}async getSystemToken(){try{return await SimpleAuthManager_js_1.SimpleAuthManager.getToken()}catch(e){return this.debugLog("Failed to get system token:",e),null}}validateToken(token){return this.validTokens.has(token)}async initializeTokens(){try{const token=await this.getSystemToken()
|
|
51
|
+
token&&(this.validTokens.add(token),this.debugLog(`System token initialized: ${token.substring(0,30)}...`))}catch(e){this.debugLog("Token initialization failed:",e)}}debugLog(e,t){const r=(new Date).toISOString(),a=t?`[${r}] ${e}\n${JSON.stringify(t,null,2)}\n`:`[${r}] ${e}\n`
|
|
52
|
+
try{fs.appendFile(this.logFilePath,a).catch(()=>{})}catch(e){}}createErrorResponse(e,t,r){return this.createSuccessResponse([{type:"text",text:JSON.stringify({success:!1,error:e,code:t,...r})}],{success:!1,error:e,code:t,...r})}async performHealthCheck(){try{if(!await portal_api_client_js_1.portalAPIClient.getUserInfo())throw Error("Portal API接続テストに失敗しました")}catch(e){throw Error("Portal API接続テストに失敗: "+e)}}}exports.default=PortalPlugin
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r)
|
|
3
|
+
var o=Object.getOwnPropertyDescriptor(t,r)
|
|
4
|
+
o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[]
|
|
5
|
+
for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r)
|
|
6
|
+
return t},e(t)}
|
|
7
|
+
return function(t){if(t&&t.__esModule)return t
|
|
8
|
+
var r={}
|
|
9
|
+
if(null!=t)for(var n=e(t),o=0;o<n.length;o++)"default"!==n[o]&&__createBinding(r,t,n[o])
|
|
10
|
+
return __setModuleDefault(r,t),r}}()
|
|
11
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.SecureMCPServer=void 0
|
|
12
|
+
const index_js_1=require("@modelcontextprotocol/sdk/server/index.js"),stdio_js_1=require("@modelcontextprotocol/sdk/server/stdio.js"),types_js_1=require("@modelcontextprotocol/sdk/types.js"),crypto_utils_js_1=require("./crypto-utils.js"),fs=__importStar(require("fs")),path=__importStar(require("path")),os=__importStar(require("os")),plugin_manager_js_1=require("./plugins/plugin-manager.js")
|
|
13
|
+
class SecureMCPServer{constructor(){this.cacheTimeout=3e5,this.server=new index_js_1.Server({name:"secure-bluelamp-mcp",version:"3.0.0"},{capabilities:{tools:{}}}),this.validTokens=new Set,this.promptCache=new Map,this.encryptionKey=process.env.BLUELAMP_ENCRYPTION_KEY||"demo-encryption-password-2024",this.keywordMapping=new Map([["orchestrator","オーケストレーター"],["requirements-engineer","要件定義エンジニア"],["ui-ux-designer","UI/UXデザイナー"],["data-modeling-engineer","データモデリングエンジニア"],["system-architect","システムアーキテクト"],["implementation-consultant","実装コンサルタント"],["environment-setup","環境構築"],["prototype-implementation","プロトタイプ実装"],["implementation-agent","実装エージェント"],["debug-agent","デバッグエージェント"],["deploy-specialist","デプロイスペシャリスト"],["page-creator","ページクリエイター"],["refactoring-engineer","リファクタリングエンジニア"],["ai-friendliness-diagnostic","AI親和性診断"]]),this.logFilePath=path.join(os.tmpdir(),`bluelamp-debug-${Date.now()}.log`),this.debugLog("BlueLamp MCP Server starting - Log file: "+this.logFilePath),this.initializeTokensSync(),this.setupHandlers()}debugLog(e,t){const r=(new Date).toISOString(),n=t?`[${r}] ${e}\n${JSON.stringify(t,null,2)}\n`:`[${r}] ${e}\n`
|
|
14
|
+
try{fs.appendFileSync(this.logFilePath,n)}catch(e){}}initializeTokensSync(){try{const e=process.env.BLUELAMP_TOKEN
|
|
15
|
+
e&&this.validTokens.add(e),this.loadCLITokenFromFile(),this.validTokens.add("secure-token-2024"),this.debugLog("Total valid tokens: "+this.validTokens.size)}catch(e){this.validTokens.add("secure-token-2024"),this.debugLog("Token initialization error:",e)}}loadCLITokenFromFile(){this.loadCLITokenAsync()}async loadCLITokenAsync(){try{const e=await Promise.resolve().then(()=>__importStar(require("path"))),t=(await Promise.resolve().then(()=>__importStar(require("url"))),e.dirname(__filename)),r=e.dirname(e.dirname(e.dirname(t))),n=e.join(r,"lib/mcp-server/dist/security"),o=await Promise.resolve(`file://${n}/SimpleAuthManager.js`).then(e=>__importStar(require(e))),token=await o.SimpleAuthManager.getToken()
|
|
16
|
+
token&&token.startsWith("cli_")&&(this.validTokens.add(token),this.debugLog(`Loaded CLI token from SimpleAuthManager: ${token.substring(0,20)}...`))}catch(e){this.debugLog("CLI token loading error:",e)}}async getSystemToken(){try{const e=process.env.BLUELAMP_TOKEN
|
|
17
|
+
if(e&&this.validTokens.has(e))return e
|
|
18
|
+
const t=await Promise.resolve().then(()=>__importStar(require("path"))),r=(await Promise.resolve().then(()=>__importStar(require("url"))),t.dirname(__filename)),n=t.dirname(t.dirname(t.dirname(r))),o=t.join(n,"lib/mcp-server/dist/security")
|
|
19
|
+
try{const e=await Promise.resolve(`file://${o}/SimpleAuthManager.js`).then(e=>__importStar(require(e))),token=await e.SimpleAuthManager.getToken()
|
|
20
|
+
if(token&&token.startsWith("cli_"))return token}catch(e){this.debugLog("Failed to load token from SimpleAuthManager:",e)}for(const token of this.validTokens)if(token.startsWith("cli_"))return token
|
|
21
|
+
return"secure-token-2024"}catch(e){return this.debugLog("System token retrieval error:",e),"secure-token-2024"}}setupHandlers(){this.server.setRequestHandler(types_js_1.ListToolsRequestSchema,async()=>{const e=[{name:"inject_knowledge",description:"Inject specialized knowledge from Portal API",inputSchema:{type:"object",properties:{keyword:{type:"string",description:"Keyword to search for specialized knowledge"},context:{type:"string",description:"Additional context"},level:{type:"string",description:"Knowledge detail level"}},required:["keyword","context"]}},{name:"save_knowledge",description:"Save knowledge to encrypted storage",inputSchema:{type:"object",properties:{knowledge:{type:"string",description:"Knowledge content to save (encrypted)"},identifier:{type:"string",description:"Unique identifier for the knowledge"},token:{type:"string",description:"Authentication token for access"}},required:["knowledge","identifier","token"]}},{name:"list_prompts",description:"List available encrypted prompt templates",inputSchema:{type:"object",properties:{token:{type:"string",description:"Authentication token for access"},category:{type:"string",description:"Filter by category (optional)"}},required:["token"]}},{name:"delegate_to_agent",description:"Delegate task to specialized sub-agent with knowledge injection",inputSchema:{type:"object",properties:{agentName:{type:"string",description:"Name of the target agent"},token:{type:"string",description:"Authentication token for access"}},required:["agentName","token"]}},{name:"get_debug_log_path",description:"Get the path to the debug log file",inputSchema:{type:"object",properties:{},required:[]}}]
|
|
22
|
+
let t=[]
|
|
23
|
+
try{plugin_manager_js_1.pluginManager&&(t=plugin_manager_js_1.pluginManager.getAvailableTools(),this.debugLog(`プラグインツール取得完了: ${t.length}個`))}catch(e){this.debugLog("プラグインツール取得エラー",e)}const r=[...e,...t]
|
|
24
|
+
return this.debugLog(`全ツール数: ${r.length} (基本: ${e.length}, プラグイン: ${t.length})`),{tools:r}}),this.server.setRequestHandler(types_js_1.CallToolRequestSchema,async e=>{const{name:t,arguments:r}=e.params
|
|
25
|
+
this.debugLog("Tool called: "+t),this.debugLog("Tool args:",r)
|
|
26
|
+
try{switch(t){case"inject_knowledge":return this.debugLog("Calling handleInjectKnowledge"),await this.handleInjectKnowledge(r)
|
|
27
|
+
case"save_knowledge":return await this.handleSaveKnowledge(r)
|
|
28
|
+
case"list_prompts":return await this.handleListPrompts(r)
|
|
29
|
+
case"delegate_to_agent":return await this.handleDelegateToAgent(r)
|
|
30
|
+
case"get_debug_log_path":return{content:[{type:"text",text:JSON.stringify({success:!0,logPath:this.logFilePath,message:"Debug log is being written to: "+this.logFilePath})}]}
|
|
31
|
+
default:const e=await this.handlePluginTool(t,r)
|
|
32
|
+
if(e)return e
|
|
33
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.MethodNotFound,"Unknown tool: "+t)}}catch(e){if(e instanceof types_js_1.McpError)throw e
|
|
34
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError,`Tool execution failed: ${t}: ${e}`)}})}validateToken(token){return this.validTokens.has(token)}async fetchFromPortalAPI(keyword,token){try{const e=`${process.env.BLUELAMP_PORTAL_API_URL||"https://bluelamp-235426778039.asia-northeast1.run.app/api/cli/prompts/knowledge-injection"}/${encodeURIComponent(keyword)}`
|
|
35
|
+
this.debugLog("Portal API request:",{url:e,token:token.substring(0,20)+"...",keyword:keyword})
|
|
36
|
+
const t=new AbortController,r=setTimeout(()=>t.abort(),3e4),n=await fetch(e,{method:"GET",headers:{"X-CLI-Token":token,"Content-Type":"application/json","User-Agent":"BlueLamp-MCP-Server/1.0"},signal:t.signal})
|
|
37
|
+
if(clearTimeout(r),this.debugLog("Portal API response status: "+n.status),!n.ok){if(this.debugLog(`Portal API error: ${n.status} ${n.statusText}`),401===n.status)return this.debugLog("Authentication failed - token may be invalid"),null
|
|
38
|
+
if(404===n.status)return this.debugLog("Knowledge not found for keyword: "+keyword),null
|
|
39
|
+
throw Error(`Portal API error: ${n.status} ${n.statusText}`)}const o=await n.text()
|
|
40
|
+
return this.debugLog("Portal API raw response:",o.substring(0,200)+"..."),o&&o.trim()?o.trim():(this.debugLog("Empty response from Portal API"),null)}catch(e){return null}}async handleInjectKnowledge(e){this.debugLog("Received args:",e),this.debugLog("Valid tokens: "+Array.from(this.validTokens).map(e=>e.substring(0,30)+"...").join(", "))
|
|
41
|
+
let token=await this.getSystemToken()
|
|
42
|
+
if(this.debugLog(`Using system token: ${token?.substring(0,30)}...`),!token||!this.validateToken(token))return this.debugLog("System authentication failed"),{content:[{type:"text",text:JSON.stringify({success:!1,error:"System authentication failed",code:"SYSTEM_AUTH_ERROR"})}]}
|
|
43
|
+
try{const t=`${e.keyword}:${e.level}`,r=this.promptCache.get(t)
|
|
44
|
+
let n,o="unknown"
|
|
45
|
+
if(r&&Date.now()-r.timestamp<this.cacheTimeout)n=r.content,o=r.source||"cache"
|
|
46
|
+
else{const r=path.join(process.cwd(),"lib/knowledge","encrypted",e.keyword+".enc")
|
|
47
|
+
if(fs.existsSync(r))try{n=crypto_utils_js_1.CryptoUtils.decryptFile(r,this.encryptionKey),o="local"}catch(t){const r=await this.fetchFromPortalAPI(e.keyword,token)
|
|
48
|
+
if(!r)return{content:[{type:"text",text:JSON.stringify({success:!1,error:"Portal APIから知識を取得できませんでした: "+e.keyword,code:"KNOWLEDGE_NOT_FOUND"})}]}
|
|
49
|
+
n=r,o="api"}else{this.debugLog("Fetching from Portal API for keyword: "+e.keyword)
|
|
50
|
+
const t=await this.fetchFromPortalAPI(e.keyword,token)
|
|
51
|
+
if(this.debugLog("Portal API result:",{keyword:e.keyword,resultExists:!!t,resultType:typeof t,resultLength:t?t.length:0}),!t)return this.debugLog("Portal API returned null for keyword: "+e.keyword),{content:[{type:"text",text:JSON.stringify({success:!1,error:"専門知識が見つかりませんでした: "+e.keyword,code:"KNOWLEDGE_NOT_FOUND"})}]}
|
|
52
|
+
n=t,o="api"}this.promptCache.set(t,{content:n,timestamp:Date.now(),source:o})}const s=this.buildResponse(n,token)
|
|
53
|
+
return{content:[{type:"text",text:JSON.stringify({success:!0,result:s,keyword:e.keyword,token:token.substring(0,20)+"...",cached:"cache"===o,source:o,timestamp:(new Date).toISOString()})}]}}catch(e){return{content:[{type:"text",text:JSON.stringify({success:!1,error:"知識注入処理中にエラーが発生しました: "+e,code:"INJECTION_ERROR"})}]}}}buildResponse(e,token){return this.debugLog("buildResponse called with content length: "+(e?e.length:0)),{content:[{type:"text",text:e}]}}async handleSaveKnowledge(e){if(!this.validateToken(e.token))return{content:[{type:"text",text:JSON.stringify({success:!1,error:"Invalid authentication token",code:"AUTH_ERROR"})}]}
|
|
54
|
+
try{const t=path.join(process.cwd(),"lib/knowledge","encrypted")
|
|
55
|
+
fs.existsSync(t)||fs.mkdirSync(t,{recursive:!0})
|
|
56
|
+
const r=path.join(t,e.identifier+".enc")
|
|
57
|
+
return crypto_utils_js_1.CryptoUtils.encryptFile(e.knowledge,r,this.encryptionKey),{content:[{type:"text",text:JSON.stringify({success:!0,message:"Knowledge saved successfully",outputPath:r,size:fs.statSync(r).size})}]}}catch(e){return{content:[{type:"text",text:JSON.stringify({success:!1,error:"Knowledge save failed: "+e,code:"SAVE_ERROR"})}]}}}async handleListPrompts(e){if(!this.validateToken(e.token))return{content:[{type:"text",text:JSON.stringify({success:!1,error:"Invalid authentication token",code:"AUTH_ERROR"})}]}
|
|
58
|
+
try{const t=path.join(process.cwd(),"lib/knowledge","encrypted"),r=path.join(t,"prompt-registry.json")
|
|
59
|
+
if(!fs.existsSync(r))return{content:[{type:"text",text:JSON.stringify({success:!1,error:"Prompt registry not found",code:"REGISTRY_NOT_FOUND"})}]}
|
|
60
|
+
const n=JSON.parse(fs.readFileSync(r,"utf8"))
|
|
61
|
+
let o=n.prompts
|
|
62
|
+
return e.category&&(o=o.filter(t=>t.category===e.category)),{content:[{type:"text",text:JSON.stringify({success:!0,totalCount:o.length,prompts:o,categories:n.categories,lastUpdated:n.lastUpdated})}]}}catch(e){return{content:[{type:"text",text:JSON.stringify({success:!1,error:"Failed to list prompts: "+e,code:"LIST_ERROR"})}]}}}async handleDelegateToAgent(e){if(!this.validateToken(e.token))return{content:[{type:"text",text:JSON.stringify({success:!1,error:"Invalid authentication token",code:"AUTH_ERROR"})}]}
|
|
63
|
+
try{const t=path.join(process.cwd(),"lib/knowledge","agents",e.agentName+".agent")
|
|
64
|
+
if(!fs.existsSync(t))return{content:[{type:"text",text:JSON.stringify({success:!1,error:"Agent script not found: "+e.agentName,code:"AGENT_NOT_FOUND"})}]}
|
|
65
|
+
const r=JSON.parse(fs.readFileSync(t,"utf8")),n=path.join(process.cwd(),"lib/knowledge","encrypted"),o=path.join(n,e.agentName+".enc"),s=fs.existsSync(o)
|
|
66
|
+
return{content:[{type:"text",text:JSON.stringify({success:!0,agentName:e.agentName,agentData:r,hasKnowledge:s,knowledgeSize:s?fs.statSync(o).size:0})}]}}catch(e){return{content:[{type:"text",text:JSON.stringify({success:!1,error:"Agent delegation failed: "+e,code:"DELEGATION_ERROR"})}]}}}startCacheCleanup(){}async handlePluginTool(e,t){try{if(!plugin_manager_js_1.pluginManager)return null
|
|
67
|
+
if(!plugin_manager_js_1.pluginManager.getAvailableTools().find(t=>t.name===e))return null
|
|
68
|
+
this.debugLog("プラグインツール実行: "+e,t)
|
|
69
|
+
const r={userId:"current_user",service:"leonardo",apiKey:process.env.LEONARDO_API_KEY,settings:{}}
|
|
70
|
+
let n="leonardo"
|
|
71
|
+
e.startsWith("leonardo_")&&(n="leonardo")
|
|
72
|
+
const o=await plugin_manager_js_1.pluginManager.executePlugin(n,e,t,r)
|
|
73
|
+
if(o.success)return this.debugLog("プラグインツール実行成功: "+e),{content:o.content,_meta:o.metadata}
|
|
74
|
+
throw this.debugLog("プラグインツール実行失敗: "+e,o.error),new types_js_1.McpError(types_js_1.ErrorCode.InternalError,"プラグインツール実行エラー: "+o.error)}catch(t){if(this.debugLog("プラグインツール処理エラー: "+e,t),t instanceof types_js_1.McpError)throw t
|
|
75
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError,"プラグイン処理中にエラーが発生しました: "+t.message)}}async run(){try{await plugin_manager_js_1.pluginManager.initialize(),this.debugLog("プラグインマネージャー初期化完了")}catch(e){this.debugLog("プラグインマネージャー初期化エラー",e)}const e=new stdio_js_1.StdioServerTransport
|
|
76
|
+
await this.server.connect(e),this.startCacheCleanup()}}exports.SecureMCPServer=SecureMCPServer,require.main===module&&(new SecureMCPServer).run().catch(()=>{})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r)
|
|
3
|
+
var n=Object.getOwnPropertyDescriptor(t,r)
|
|
4
|
+
n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,a,n)}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[]
|
|
5
|
+
for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r)
|
|
6
|
+
return t},e(t)}
|
|
7
|
+
return function(t){if(t&&t.__esModule)return t
|
|
8
|
+
var r={}
|
|
9
|
+
if(null!=t)for(var a=e(t),n=0;n<a.length;n++)"default"!==a[n]&&__createBinding(r,t,a[n])
|
|
10
|
+
return __setModuleDefault(r,t),r}}()
|
|
11
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.ApiKeyManager=void 0
|
|
12
|
+
const https=__importStar(require("https")),http=__importStar(require("http")),url_1=require("url"),TokenManager_js_1=require("./TokenManager.js")
|
|
13
|
+
class ApiKeyManager{static async getApiKey(e){try{const t=this.cache[e]
|
|
14
|
+
if(t&&Date.now()-t.fetchedAt<t.ttl)return t.apiKey
|
|
15
|
+
const r=await TokenManager_js_1.TokenManager.loadToken()
|
|
16
|
+
if(!r||!r.token)return null
|
|
17
|
+
const a=await this.fetchApiKeysFromPortal(r.token)
|
|
18
|
+
if(!a)return null
|
|
19
|
+
const n=a.find(t=>t.serviceId===e||t.service?.id===e||t.serviceName?.toLowerCase()===e.toLowerCase())
|
|
20
|
+
return n?(this.cache[e]={apiKey:n.apiKey,fetchedAt:Date.now(),ttl:this.DEFAULT_TTL},n.apiKey):null}catch(e){return null}}static async fetchApiKeysFromPortal(token){return new Promise((e,t)=>{const r=new url_1.URL(this.PORTAL_API_URL+"/api/simple/api-keys"),a={hostname:r.hostname,port:r.port||("https:"===r.protocol?443:80),path:r.pathname,method:"GET",headers:{Authorization:"Bearer "+token,"X-CLI-Token":token,"Content-Type":"application/json"},timeout:1e4},n=("https:"===r.protocol?https:http).request(a,t=>{let r=""
|
|
21
|
+
t.on("data",e=>{r+=e}),t.on("end",()=>{try{const t=JSON.parse(r)
|
|
22
|
+
t.success&&t.data?.apiKeys?e(t.data.apiKeys):e(null)}catch(t){e(null)}})})
|
|
23
|
+
n.on("error",t=>{e(null)}),n.on("timeout",()=>{n.destroy(),e(null)}),n.end()})}static clearCache(e){e?delete this.cache[e]:this.cache={}}static async preloadApiKeys(e){const t=e.map(e=>this.getApiKey(e))
|
|
24
|
+
await Promise.allSettled(t)}}exports.ApiKeyManager=ApiKeyManager,ApiKeyManager.cache={},ApiKeyManager.DEFAULT_TTL=3e5,ApiKeyManager.PORTAL_API_URL=process.env.PORTAL_URL||"https://bluelamp-portal-6clpzmy5pa-an.a.run.app"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n)
|
|
3
|
+
var i=Object.getOwnPropertyDescriptor(t,n)
|
|
4
|
+
i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[]
|
|
5
|
+
for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n)
|
|
6
|
+
return t},e(t)}
|
|
7
|
+
return function(t){if(t&&t.__esModule)return t
|
|
8
|
+
var n={}
|
|
9
|
+
if(null!=t)for(var r=e(t),i=0;i<r.length;i++)"default"!==r[i]&&__createBinding(n,t,r[i])
|
|
10
|
+
return __setModuleDefault(n,t),n}}()
|
|
11
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.InteractiveLogin=void 0
|
|
12
|
+
const readline=__importStar(require("readline")),fs=__importStar(require("fs")),path=__importStar(require("path")),os=__importStar(require("os")),crypto=__importStar(require("crypto")),PortalAuthClient_js_1=require("./PortalAuthClient.js"),TokenManager_js_1=require("./TokenManager.js")
|
|
13
|
+
class InteractiveLogin{static getLoginInfoPath(){const e=os.homedir()
|
|
14
|
+
return path.join(e,".bluelamp_login_info.enc")}static exists(){return fs.existsSync(this.getLoginInfoPath())}static async loadLoginInfo(){const e=this.getLoginInfoPath()
|
|
15
|
+
if(!fs.existsSync(e))return null
|
|
16
|
+
try{const t=fs.readFileSync(e,"utf8"),n=crypto.createHash("sha256").update(os.userInfo().username+os.hostname()).digest(),r=crypto.createDecipheriv("aes-256-cbc",n.slice(0,32),Buffer.alloc(16))
|
|
17
|
+
let i=r.update(t,"hex","utf8")
|
|
18
|
+
return i+=r.final("utf8"),JSON.parse(i)}catch(e){return null}}static async deleteLoginInfo(){const e=this.getLoginInfoPath()
|
|
19
|
+
return!!fs.existsSync(e)&&(fs.unlinkSync(e),!0)}static async performLogin(){try{const e=await TokenManager_js_1.TokenManager.loadToken()
|
|
20
|
+
if(e&&e.token){const t=await TokenManager_js_1.TokenManager.validateToken(e.token)
|
|
21
|
+
if(t.valid)return{token:e.token,user:t.userInfo,isFromCache:!0}
|
|
22
|
+
await TokenManager_js_1.TokenManager.deleteToken()}let t=await this.loadLoginInfo()
|
|
23
|
+
if(t){const e=await PortalAuthClient_js_1.PortalAuthClient.authenticate(t.email,t.passwordHash)
|
|
24
|
+
if(!e.success){if(!e.error||!e.error.includes("ナレッジインジェクション使用回数上限"))return await InteractiveLogin.deleteLoginInfo(),await this.performLogin()
|
|
25
|
+
process.exit(1)}return await TokenManager_js_1.TokenManager.saveToken(e.token,e.user)&&await InteractiveLogin.deleteLoginInfo(),{token:e.token,user:e.user,isFirstTime:!1,isFromCache:!1,migrated:!0}}{const e=await this.promptCredentials(),t=await PortalAuthClient_js_1.PortalAuthClient.authenticate(e.email,e.password)
|
|
26
|
+
return t.success||(t.error&&t.error.includes("ナレッジインジェクション使用回数上限"),process.exit(1)),await TokenManager_js_1.TokenManager.saveToken(t.token,t.user),await InteractiveLogin.deleteLoginInfo(),{token:t.token,user:t.user,isFirstTime:!0,isFromCache:!1}}}catch(e){process.exit(1)}}static async promptCredentials(){const e=readline.createInterface({input:process.stdin,output:process.stdout})
|
|
27
|
+
try{const t=await this.question(e,"Email: ")
|
|
28
|
+
this.validateEmail(t)||(e.close(),process.exit(1))
|
|
29
|
+
const n=await this.question(e,"Password: ")
|
|
30
|
+
return n&&0!==n.trim().length||(e.close(),process.exit(1)),e.close(),{email:t.trim(),password:n.trim()}}catch(t){throw e.close(),t}}static question(e,t){return new Promise(n=>{e.question(t,e=>{n(e)})})}static validateEmail(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}static displayLoginSuccess(e){e.isFirstTime}static async logout(){const e=readline.createInterface({input:process.stdin,output:process.stdout})
|
|
31
|
+
try{const t=await this.question(e,"ログイン情報を削除しますか? (y/N): ")
|
|
32
|
+
"y"!==t.toLowerCase()&&"yes"!==t.toLowerCase()||await InteractiveLogin.deleteLoginInfo()}finally{e.close()}}static async checkLoginStatus(){return!!InteractiveLogin.exists()&&!!await InteractiveLogin.loadLoginInfo()}}exports.InteractiveLogin=InteractiveLogin
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';const a0_0x1901f8=a0_0x5df5;(function(_0x2cc59d,_0x352bf4){const _0x437814=a0_0x5df5,_0x7cd4d7=_0x2cc59d();while(!![]){try{const _0x5cb7a1=parseInt(_0x437814(0x293))/0x1+-parseInt(_0x437814(0x29f))/0x2+parseInt(_0x437814(0x28c))/0x3*(parseInt(_0x437814(0x1f4))/0x4)+parseInt(_0x437814(0x2bf))/0x5+-parseInt(_0x437814(0x24c))/0x6+parseInt(_0x437814(0x1fc))/0x7*(-parseInt(_0x437814(0x215))/0x8)+-parseInt(_0x437814(0x289))/0x9*(-parseInt(_0x437814(0x2e6))/0xa);if(_0x5cb7a1===_0x352bf4)break;else _0x7cd4d7['push'](_0x7cd4d7['shift']());}catch(_0x233fdb){_0x7cd4d7['push'](_0x7cd4d7['shift']());}}}(a0_0x4b05,0x58a66));var a0_0xd9878b=this&&this[a0_0x1901f8(0x1ee)]||(Object[a0_0x1901f8(0x27a)]?function(_0x4bf14a,_0x53e982,_0x3388df,_0x570e57){const _0x48eb11=a0_0x1901f8,_0x1c84bd={'Blxrk':function(_0x4af92a,_0x2bf8ad){return _0x4af92a!==_0x2bf8ad;},'Wiqgr':_0x48eb11(0x291),'xvmVG':function(_0x4d3d82,_0x2aa8fb){return _0x4d3d82(_0x2aa8fb);},'ffyUz':function(_0xc4eece,_0x518895){return _0xc4eece===_0x518895;},'mhrBU':function(_0x3a788b,_0x4555ff){return _0x3a788b in _0x4555ff;},'nLGdG':_0x48eb11(0x205),'coJQa':_0x48eb11(0x25e),'nrTlz':_0x48eb11(0x2da)};if(_0x1c84bd[_0x48eb11(0x2a6)](_0x570e57,undefined))_0x570e57=_0x3388df;var _0x3f6c01=Object[_0x48eb11(0x2ab)](_0x53e982,_0x3388df);(!_0x3f6c01||(_0x1c84bd[_0x48eb11(0x2f8)](_0x1c84bd['nLGdG'],_0x3f6c01)?!_0x53e982[_0x48eb11(0x1f9)]:_0x3f6c01[_0x48eb11(0x283)]||_0x3f6c01['configurable']))&&(_0x1c84bd['Blxrk'](_0x1c84bd[_0x48eb11(0x231)],_0x1c84bd['nrTlz'])?_0x3f6c01={'enumerable':!![],'get':function(){const _0x560721=_0x48eb11;return _0x1c84bd[_0x560721(0x287)](_0x560721(0x1f2),_0x1c84bd[_0x560721(0x2f7)])?_0x53e982[_0x3388df]:!![];}}:_0x1c84bd[_0x48eb11(0x2ea)](_0x232ab6,new _0x3b62d2(_0x48eb11(0x2d8)+_0x50266a[_0x48eb11(0x2d1)]))),Object[_0x48eb11(0x23e)](_0x4bf14a,_0x570e57,_0x3f6c01);}:function(_0x4387e,_0x4f6072,_0x3b9876,_0x5bbda4){const _0x406de5=a0_0x1901f8,_0x4f810b={};_0x4f810b[_0x406de5(0x213)]=function(_0x433b45,_0x4c7eef){return _0x433b45===_0x4c7eef;};const _0x4952bb=_0x4f810b;if(_0x4952bb[_0x406de5(0x213)](_0x5bbda4,undefined))_0x5bbda4=_0x3b9876;_0x4387e[_0x5bbda4]=_0x4f6072[_0x3b9876];}),a0_0x1aff77=this&&this['__setModuleDefault']||(Object[a0_0x1901f8(0x27a)]?function(_0x1a4939,_0x29b68f){const _0x1fa71c=a0_0x1901f8,_0x22815b={};_0x22815b[_0x1fa71c(0x25f)]=_0x1fa71c(0x246);const _0x350f85=_0x22815b,_0x4474aa={};_0x4474aa['enumerable']=!![],_0x4474aa[_0x1fa71c(0x232)]=_0x29b68f,Object[_0x1fa71c(0x23e)](_0x1a4939,_0x350f85['tQjqw'],_0x4474aa);}:function(_0x3dc86f,_0x5874f8){_0x3dc86f['default']=_0x5874f8;}),a0_0x68a914=this&&this[a0_0x1901f8(0x2ef)]||(function(){const _0x1c54d5=a0_0x1901f8,_0x1fc222={'CzuYX':_0x1c54d5(0x220),'ZBeVa':function(_0x181607,_0xb2e565){return _0x181607!==_0xb2e565;},'TdnSt':'yMMEv','zGNlu':_0x1c54d5(0x251),'MBgyZ':function(_0x5416a5,_0x34d4a6){return _0x5416a5===_0x34d4a6;},'NIRXZ':_0x1c54d5(0x230),'ZflXa':_0x1c54d5(0x2f4),'qDDDd':_0x1c54d5(0x21b),'XCjPW':function(_0x3b9eff,_0x498b99){return _0x3b9eff(_0x498b99);},'sCmBm':function(_0x2fb04d,_0x4fa5ee){return _0x2fb04d+_0x4fa5ee;},'jgWKl':_0x1c54d5(0x23b),'aChkJ':function(_0x284102){return _0x284102();},'OtxiV':function(_0xfe7949,_0x5d754d){return _0xfe7949===_0x5d754d;},'OLDOU':_0x1c54d5(0x28d),'lIJtx':function(_0x4e83f8,_0x5e8d92,_0x19e2c3){return _0x4e83f8(_0x5e8d92,_0x19e2c3);},'NTgCl':_0x1c54d5(0x226),'ZRIVU':function(_0x10bca4,_0x46fe11){return _0x10bca4===_0x46fe11;},'zLMyO':_0x1c54d5(0x1df),'uOAHl':_0x1c54d5(0x207),'cbePG':function(_0x3740e9){return _0x3740e9();},'kMVTU':_0x1c54d5(0x239),'iliVU':'warn','pWzgT':'info','pydvY':_0x1c54d5(0x2b6),'FukwA':_0x1c54d5(0x2f3),'rAOTi':'table','oAvLW':function(_0x1f8333,_0xa3c241){return _0x1f8333<_0xa3c241;},'clLFX':_0x1c54d5(0x2e2),'tGtRs':_0x1c54d5(0x219),'PXKya':_0x1c54d5(0x22c),'yAhle':_0x1c54d5(0x2d4),'EFcqV':function(_0xb16ac0,_0xd240d3){return _0xb16ac0(_0xd240d3);},'cBiSu':function(_0x5116ad,_0x194a19){return _0x5116ad!=_0x194a19;},'tvufZ':function(_0x3829e6,_0xee4739){return _0x3829e6(_0xee4739);},'gPHdr':function(_0x560d7a,_0x1bcd46){return _0x560d7a!==_0x1bcd46;},'xjJaK':function(_0x46b3aa,_0x3218c9,_0x5cd59f,_0x3c46ff){return _0x46b3aa(_0x3218c9,_0x5cd59f,_0x3c46ff);},'OlvCK':function(_0x2d2e11){return _0x2d2e11();}},_0x90ca64=(function(){let _0x3afce9=!![];return function(_0x359ae4,_0xd64e0a){const _0x2c3edf=a0_0x5df5,_0x44ad2f={'eczha':_0x1fc222[_0x2c3edf(0x297)],'nzuPV':function(_0x58ec17,_0x57efb2){return _0x1fc222['ZBeVa'](_0x58ec17,_0x57efb2);},'saTmE':_0x1fc222['TdnSt'],'dXMjK':_0x1fc222[_0x2c3edf(0x2aa)]},_0x568552=_0x3afce9?function(){const _0x40c6f9=_0x2c3edf;if(_0xd64e0a){if(_0x44ad2f[_0x40c6f9(0x217)](_0x44ad2f[_0x40c6f9(0x264)],_0x44ad2f[_0x40c6f9(0x225)])){const _0x5e5bfd=_0xd64e0a[_0x40c6f9(0x284)](_0x359ae4,arguments);return _0xd64e0a=null,_0x5e5bfd;}else return _0x460d58[_0x40c6f9(0x1ef)]()[_0x40c6f9(0x252)](yNBeFY[_0x40c6f9(0x24e)])[_0x40c6f9(0x1ef)]()[_0x40c6f9(0x2c3)](_0x10f2f7)[_0x40c6f9(0x252)](_0x40c6f9(0x220));}}:function(){};return _0x3afce9=![],_0x568552;};}()),_0x22fd6a=_0x1fc222[_0x1c54d5(0x1dc)](_0x90ca64,this,function(){const _0x4fb874=_0x1c54d5;return _0x22fd6a[_0x4fb874(0x1ef)]()[_0x4fb874(0x252)](_0x1fc222[_0x4fb874(0x297)])[_0x4fb874(0x1ef)]()[_0x4fb874(0x2c3)](_0x22fd6a)['search'](_0x4fb874(0x220));});_0x1fc222[_0x1c54d5(0x22a)](_0x22fd6a);const _0x2217ac=(function(){const _0x47b457=_0x1c54d5,_0x43471d={'AnwiX':function(_0x3729d5,_0x2ddfd6){return _0x1fc222['MBgyZ'](_0x3729d5,_0x2ddfd6);},'ZDNGf':_0x1fc222['NIRXZ'],'hrKYR':_0x1fc222[_0x47b457(0x1f3)]};let _0x5b018c=!![];return function(_0x5be666,_0x1b28b5){const _0x4a7c30=_0x47b457,_0x2287e6={'gOksI':function(_0x952e8b,_0x442cab){const _0x14fe5b=a0_0x5df5;return _0x43471d[_0x14fe5b(0x2dc)](_0x952e8b,_0x442cab);},'RYrTS':_0x43471d[_0x4a7c30(0x29c)]};if(_0x43471d[_0x4a7c30(0x298)]===_0x4a7c30(0x2c9)){if(_0x5a6c4e){const _0x12fdc9=_0x1f2d1f[_0x4a7c30(0x284)](_0x2fd1c1,arguments);return _0x5b25e1=null,_0x12fdc9;}}else{const _0x566f92=_0x5b018c?function(){const _0x4d6394=_0x4a7c30;if(_0x1b28b5){if(_0x2287e6['gOksI'](_0x4d6394(0x2a0),_0x2287e6[_0x4d6394(0x258)])){if(_0x56d05a){const _0xa145c=_0x4780e3['apply'](_0x3f95b3,arguments);return _0x5108cf=null,_0xa145c;}}else{const _0x335112=_0x1b28b5['apply'](_0x5be666,arguments);return _0x1b28b5=null,_0x335112;}}}:function(){};return _0x5b018c=![],_0x566f92;}};}());(function(){const _0x185c7b=_0x1c54d5,_0x532916={'Xknyu':_0x1fc222[_0x185c7b(0x25b)],'tpmwh':function(_0xbac39,_0x2c8988){const _0x4b477b=_0x185c7b;return _0x1fc222[_0x4b477b(0x275)](_0xbac39,_0x2c8988);},'EHecg':function(_0x5396fe,_0x5b1a85){const _0x2abc96=_0x185c7b;return _0x1fc222[_0x2abc96(0x29d)](_0x5396fe,_0x5b1a85);},'ssURf':_0x1fc222[_0x185c7b(0x27f)],'ykRxx':function(_0x46ef19){return _0x1fc222['aChkJ'](_0x46ef19);}};_0x1fc222['OtxiV'](_0x185c7b(0x281),_0x1fc222[_0x185c7b(0x21d)])?_0x47a96a+=_0x515c0f:_0x1fc222[_0x185c7b(0x1dc)](_0x2217ac,this,function(){const _0x5267d8=_0x185c7b,_0x4a207a=new RegExp(_0x5267d8(0x21f)),_0x3b0318=new RegExp(_0x532916[_0x5267d8(0x274)],'i'),_0x535944=_0x532916[_0x5267d8(0x2a1)](a0_0x2cc504,_0x5267d8(0x2a9));!_0x4a207a[_0x5267d8(0x20a)](_0x535944+_0x5267d8(0x20d))||!_0x3b0318[_0x5267d8(0x20a)](_0x532916[_0x5267d8(0x2ae)](_0x535944,_0x532916[_0x5267d8(0x2d0)]))?_0x535944('0'):_0x532916[_0x5267d8(0x2f1)](a0_0x2cc504);})();}());const _0x3c62d4=(function(){const _0x557555=_0x1c54d5,_0x3adb26={'ufWss':function(_0x13c615,_0x3a19ce){return _0x1fc222['XCjPW'](_0x13c615,_0x3a19ce);},'FElWS':_0x1fc222[_0x557555(0x1eb)]};let _0x578f0c=!![];return function(_0x8b6930,_0x5068f6){const _0x3451d2=_0x557555,_0x1ff4da={'OLCaa':function(_0x25498a,_0x2dd6ea){return _0x3adb26['ufWss'](_0x25498a,_0x2dd6ea);}};if(_0x3adb26[_0x3451d2(0x27d)]!==_0x3adb26[_0x3451d2(0x27d)])qjhhZN[_0x3451d2(0x1de)](_0x54d409,'0');else{const _0x5208=_0x578f0c?function(){const _0x2e09e2=_0x3451d2;if(_0x5068f6){const _0x45566e=_0x5068f6[_0x2e09e2(0x284)](_0x8b6930,arguments);return _0x5068f6=null,_0x45566e;}}:function(){};return _0x578f0c=![],_0x5208;}};}()),_0x1f0fa6=_0x1fc222[_0x1c54d5(0x1dc)](_0x3c62d4,this,function(){const _0x76fdd9=_0x1c54d5,_0x50d48e={'cwMeD':_0x76fdd9(0x246),'CbrZY':function(_0x5d971f,_0x2f7557){const _0x1ac907=_0x76fdd9;return _0x1fc222[_0x1ac907(0x2bd)](_0x5d971f,_0x2f7557);},'ilIrL':_0x76fdd9(0x2c2),'ZYeWW':function(_0x47cf07,_0x5f5b9b){return _0x47cf07(_0x5f5b9b);},'IuqoN':function(_0x3d474b,_0x142580){return _0x3d474b+_0x142580;},'RJCoe':function(_0x25f60f,_0xf986eb){return _0x25f60f+_0xf986eb;},'wCQtG':_0x1fc222[_0x76fdd9(0x257)],'BfaPW':_0x1fc222['uOAHl']},_0x36f075=function(){const _0x3cd77f=_0x76fdd9;if(_0x50d48e[_0x3cd77f(0x237)](_0x50d48e['ilIrL'],_0x3cd77f(0x2c2))){let _0x477fcb;try{_0x477fcb=_0x50d48e[_0x3cd77f(0x256)](Function,_0x50d48e[_0x3cd77f(0x1db)](_0x50d48e[_0x3cd77f(0x261)](_0x50d48e[_0x3cd77f(0x20f)],_0x50d48e['BfaPW']),');'))();}catch(_0x144335){_0x477fcb=window;}return _0x477fcb;}else _0x3788da[_0x50d48e[_0x3cd77f(0x22d)]]=_0x2ddc65;},_0x211f38=_0x1fc222[_0x76fdd9(0x210)](_0x36f075),_0x445821=_0x211f38[_0x76fdd9(0x280)]=_0x211f38[_0x76fdd9(0x280)]||{},_0x5f599c=[_0x1fc222[_0x76fdd9(0x2b5)],_0x1fc222[_0x76fdd9(0x235)],_0x1fc222[_0x76fdd9(0x2b4)],_0x1fc222[_0x76fdd9(0x2b0)],_0x1fc222['FukwA'],_0x1fc222['rAOTi'],_0x76fdd9(0x266)];for(let _0x36e588=0x0;_0x1fc222['oAvLW'](_0x36e588,_0x5f599c[_0x76fdd9(0x26b)]);_0x36e588++){if(_0x1fc222[_0x76fdd9(0x1f0)]!==_0x76fdd9(0x221)){const _0x1cde94=_0x3c62d4[_0x76fdd9(0x2c3)]['prototype'][_0x76fdd9(0x23c)](_0x3c62d4),_0xf7b395=_0x5f599c[_0x36e588],_0x2c4f89=_0x445821[_0xf7b395]||_0x1cde94;_0x1cde94[_0x76fdd9(0x29b)]=_0x3c62d4[_0x76fdd9(0x23c)](_0x3c62d4),_0x1cde94[_0x76fdd9(0x1ef)]=_0x2c4f89['toString'][_0x76fdd9(0x23c)](_0x2c4f89),_0x445821[_0xf7b395]=_0x1cde94;}else _0x388220=_0xc7fb82;}});_0x1fc222[_0x1c54d5(0x250)](_0x1f0fa6);var _0x16f168=function(_0x17bc33){const _0x5a19e6=_0x1c54d5,_0x32d347={};_0x32d347['nMGtt']=_0x5a19e6(0x246);const _0x40dd91=_0x32d347;if(_0x1fc222[_0x5a19e6(0x25d)]!=='BfTIQ'){const _0x5844b9={};_0x5844b9[_0x5a19e6(0x208)]=!![],_0x5844b9[_0x5a19e6(0x232)]=_0x2a3cbb,_0x357001[_0x5a19e6(0x23e)](_0x245745,_0x40dd91['nMGtt'],_0x5844b9);}else return _0x16f168=Object[_0x5a19e6(0x2a5)]||function(_0x354f36){const _0x24f6a7=_0x5a19e6;if(_0x1fc222[_0x24f6a7(0x2cf)](_0x1fc222['tGtRs'],_0x1fc222[_0x24f6a7(0x2c7)])){var _0x412a79=[];for(var _0x4a1ef0 in _0x354f36)if(Object[_0x24f6a7(0x2d9)][_0x24f6a7(0x227)][_0x24f6a7(0x228)](_0x354f36,_0x4a1ef0))_0x412a79[_0x412a79[_0x24f6a7(0x26b)]]=_0x4a1ef0;return _0x412a79;}else throw new _0x3f3aca(_0x446cd6['message']||'Portal認証に失敗しました');},_0x1fc222[_0x5a19e6(0x29e)](_0x16f168,_0x17bc33);};return function(_0x5f18f4){const _0x5dc04b=_0x1c54d5,_0x2cc5ff=_0x5dc04b(0x2f9)[_0x5dc04b(0x2eb)]('|');let _0x4c711a=0x0;while(!![]){switch(_0x2cc5ff[_0x4c711a++]){case'0':a0_0x1aff77(_0x3ac546,_0x5f18f4);continue;case'1':if(_0x1fc222['cBiSu'](_0x5f18f4,null)){for(var _0x3dccaf=_0x1fc222[_0x5dc04b(0x254)](_0x16f168,_0x5f18f4),_0x3b7628=0x0;_0x1fc222[_0x5dc04b(0x1e3)](_0x3b7628,_0x3dccaf['length']);_0x3b7628++)if(_0x1fc222[_0x5dc04b(0x211)](_0x3dccaf[_0x3b7628],'default'))_0x1fc222[_0x5dc04b(0x1e8)](a0_0xd9878b,_0x3ac546,_0x5f18f4,_0x3dccaf[_0x3b7628]);}continue;case'2':if(_0x5f18f4&&_0x5f18f4[_0x5dc04b(0x1f9)])return _0x5f18f4;continue;case'3':var _0x3ac546={};continue;case'4':return _0x3ac546;}break;}};}());const a0_0x111141={};a0_0x111141[a0_0x1901f8(0x232)]=!![],Object[a0_0x1901f8(0x23e)](exports,a0_0x1901f8(0x1f9),a0_0x111141),exports[a0_0x1901f8(0x26e)]=void 0x0;const a0_0x3c0ce7=a0_0x68a914(require('os')),a0_0x34c0f4=a0_0x68a914(require(a0_0x1901f8(0x294))),a0_0x11b308=a0_0x68a914(require(a0_0x1901f8(0x2f6))),a0_0x4055fb=require(a0_0x1901f8(0x240));class a0_0x3aad75{static async[a0_0x1901f8(0x1da)](_0x65847f,_0x33b6eb){const _0x15852d=a0_0x1901f8,_0x5a4aa0={'jrRGR':function(_0x4abbe5,_0x2e2dcd){return _0x4abbe5===_0x2e2dcd;},'BrPrd':_0x15852d(0x1fd),'WwaAO':function(_0x364715,_0x3c5293){return _0x364715(_0x3c5293);},'vtqpc':_0x15852d(0x1e5),'xcGIv':_0x15852d(0x2ed),'xwyoo':'LyIGh','FSWBO':_0x15852d(0x272),'bIMUx':function(_0x3f172f,_0x5747bc){return _0x3f172f<_0x5747bc;},'DRDhY':function(_0x4905e4,_0x53c9eb){return _0x4905e4!==_0x53c9eb;},'HqfrX':_0x15852d(0x2b3),'KLBvW':_0x15852d(0x255),'KvczQ':_0x15852d(0x2ee)},_0x149860=this[_0x15852d(0x277)](),_0x27386c={};_0x27386c[_0x15852d(0x22e)]=_0x65847f,_0x27386c[_0x15852d(0x1fe)]=_0x33b6eb,_0x27386c[_0x15852d(0x23d)]=_0x149860;const _0x95745d=_0x27386c;let _0x37e251=null;for(let _0x538f8b=0x1;_0x538f8b<=this[_0x15852d(0x233)];_0x538f8b++){if('jtcTP'===_0x5a4aa0[_0x15852d(0x2f0)])return _0x2be17e[_0x5c4abc];else try{if(_0x5a4aa0[_0x15852d(0x2ba)](_0x15852d(0x272),_0x5a4aa0[_0x15852d(0x2af)])){const _0x530581=await this['makeRequest'](_0x95745d);if(_0x530581[_0x15852d(0x259)]){const _0x30582e={};return _0x30582e[_0x15852d(0x259)]=!![],_0x30582e[_0x15852d(0x21e)]=_0x530581[_0x15852d(0x20c)][_0x15852d(0x21e)],_0x30582e[_0x15852d(0x201)]={},_0x30582e[_0x15852d(0x201)][_0x15852d(0x28b)]=_0x530581[_0x15852d(0x20c)][_0x15852d(0x2be)],_0x30582e[_0x15852d(0x201)][_0x15852d(0x241)]=_0x530581[_0x15852d(0x20c)][_0x15852d(0x2b7)],_0x30582e[_0x15852d(0x201)]['email']=_0x65847f,_0x30582e;}else throw new Error(_0x530581['message']||_0x15852d(0x2ee));}else _0x5a4aa0[_0x15852d(0x2ba)](_0x444729[_0x15852d(0x2b6)],_0x5a4aa0[_0x15852d(0x2c0)])?_0x4f73f4(new _0x4078da(_0x35ceef[_0x15852d(0x2d1)])):_0x5a4aa0[_0x15852d(0x2a3)](_0x53fbfa,new _0x349753(''+_0x517d9d[_0x15852d(0x2d1)]));}catch(_0x3aa0bb){_0x37e251=_0x3aa0bb;if(_0x5a4aa0[_0x15852d(0x2b8)](_0x538f8b,this[_0x15852d(0x233)])){if(_0x5a4aa0[_0x15852d(0x262)](_0x5a4aa0[_0x15852d(0x224)],_0x5a4aa0[_0x15852d(0x1ed)]))await this[_0x15852d(0x24b)](this[_0x15852d(0x2e8)]);else return function(_0x2edcd6){}[_0x15852d(0x2c3)](PUgCVm[_0x15852d(0x2ad)])[_0x15852d(0x284)](PUgCVm[_0x15852d(0x282)]);}}}const _0x4e23e2={};return _0x4e23e2[_0x15852d(0x259)]=![],_0x4e23e2[_0x15852d(0x2b6)]=_0x37e251?.[_0x15852d(0x2d1)]||_0x5a4aa0['KvczQ'],_0x4e23e2;}static[a0_0x1901f8(0x277)](){const _0x1bd922=a0_0x1901f8,_0x472ce2={};_0x472ce2[_0x1bd922(0x202)]=_0x1bd922(0x26d);const _0x2d5891=_0x472ce2;return{'deviceName':a0_0x3c0ce7[_0x1bd922(0x2a7)](),'platform':a0_0x3c0ce7[_0x1bd922(0x267)](),'arch':a0_0x3c0ce7[_0x1bd922(0x2a4)](),'userAgent':_0x2d5891['ZsfLO'],'nodeVersion':process[_0x1bd922(0x292)],'timestamp':Date['now']()};}static async['makeRequest'](_0x48e57c){const _0x4c7c79=a0_0x1901f8,_0x590675={'ySGJZ':function(_0x44381c,_0x35549d){return _0x44381c*_0x35549d;},'HTYzZ':function(_0x5100cf,_0x247543){return _0x5100cf>_0x247543;},'XMwbz':_0x4c7c79(0x20c),'vBeyy':_0x4c7c79(0x296),'AbZIy':function(_0x2e8443,_0x17c632){return _0x2e8443!==_0x17c632;},'yHVbd':_0x4c7c79(0x285),'rQAqT':'lfYyC','uJVvi':function(_0x24e936,_0x2f35a0){return _0x24e936!==_0x2f35a0;},'xAfDB':'eWzVW','EGTZv':_0x4c7c79(0x1fd),'wKuuT':_0x4c7c79(0x2b9),'DJWzP':function(_0x501b51,_0x6d4fa2){return _0x501b51(_0x6d4fa2);},'HoiHl':function(_0x5c71e2,_0x583845){return _0x5c71e2(_0x583845);},'hCyJi':_0x4c7c79(0x299),'lUUhX':function(_0x422a2f,_0x20e9d1){return _0x422a2f(_0x20e9d1);},'rQdXf':_0x4c7c79(0x1ec),'tsEcg':_0x4c7c79(0x260),'jmgHl':function(_0x1d7fc1,_0x21ecb4){return _0x1d7fc1===_0x21ecb4;},'ZrevI':'https:','WLBtg':_0x4c7c79(0x276),'cnZAY':_0x4c7c79(0x244),'RntzP':'timeout'};return new Promise((_0x14d2eb,_0xeb6af7)=>{const _0x46e208=_0x4c7c79,_0x2e7854={'OpoQO':function(_0x1aff6c,_0x5b8be4){return _0x1aff6c(_0x5b8be4);},'ZXDPZ':function(_0x447eb8,_0x4d0d69){return _0x590675['AbZIy'](_0x447eb8,_0x4d0d69);},'DaUDp':_0x590675[_0x46e208(0x22f)],'abZYt':function(_0x1d923f,_0x313725){return _0x1d923f===_0x313725;},'TJuBl':_0x590675[_0x46e208(0x28a)],'LWKxO':_0x46e208(0x21a),'SBApM':function(_0x473f0b,_0x33aa7f){const _0x3be1d1=_0x46e208;return _0x590675[_0x3be1d1(0x27b)](_0x473f0b,_0x33aa7f);},'vOTdw':function(_0x176ab6,_0x8a8d5a){const _0x3bda79=_0x46e208;return _0x590675[_0x3bda79(0x248)](_0x176ab6,_0x8a8d5a);},'cdqmI':_0x590675[_0x46e208(0x279)],'zDImm':_0x590675[_0x46e208(0x249)],'DKtFD':function(_0x423cc0,_0x3c3ffd){return _0x423cc0(_0x3c3ffd);},'sulCP':_0x590675['wKuuT'],'XkLAi':function(_0x48e3ef,_0x5559c2){const _0x5b536a=_0x46e208;return _0x590675[_0x5b536a(0x27e)](_0x48e3ef,_0x5559c2);},'AufID':function(_0x19ca84,_0x1d847c){const _0x25b239=_0x46e208;return _0x590675[_0x25b239(0x1dd)](_0x19ca84,_0x1d847c);},'gKBbP':function(_0x3ccf13,_0x45de5f){return _0x3ccf13(_0x45de5f);},'IlfXW':function(_0x356b20,_0x56bdf6){return _0x356b20(_0x56bdf6);},'FlIDU':_0x590675[_0x46e208(0x2c4)],'PNYrX':function(_0xb5fce3,_0x4ebbaf){const _0x1ba7b7=_0x46e208;return _0x590675[_0x1ba7b7(0x238)](_0xb5fce3,_0x4ebbaf);},'PIHTU':_0x590675['rQdXf']};if(_0x590675[_0x46e208(0x23a)]!==_0x46e208(0x21c)){const _0x2eda44=new a0_0x4055fb['URL'](this[_0x46e208(0x24f)]),_0x44912b=JSON[_0x46e208(0x214)](_0x48e57c),_0x3dba15={'hostname':_0x2eda44['hostname'],'port':_0x2eda44[_0x46e208(0x28e)]||(_0x590675[_0x46e208(0x24a)](_0x2eda44[_0x46e208(0x26f)],_0x590675[_0x46e208(0x2cd)])?0x1bb:0x50),'path':_0x2eda44['pathname'],'method':_0x590675[_0x46e208(0x269)],'headers':{'Content-Type':_0x590675[_0x46e208(0x22b)],'Content-Length':Buffer['byteLength'](_0x44912b),'User-Agent':_0x46e208(0x26d),'Accept':_0x590675[_0x46e208(0x22b)]},'timeout':this[_0x46e208(0x229)]},_0x5bae64=_0x2eda44[_0x46e208(0x26f)]===_0x46e208(0x290)?a0_0x34c0f4:a0_0x11b308,_0x5406e2=_0x5bae64[_0x46e208(0x27c)](_0x3dba15,_0x36a9e8=>{const _0x2e2f59=_0x46e208,_0x512ea0={'Imfxx':function(_0x9934b1,_0x4f4dc4){return _0x9934b1<_0x4f4dc4;},'eizcP':function(_0x3bdd45,_0x548525){return _0x3bdd45(_0x548525);},'izvYg':function(_0x53049c,_0x46119b){const _0x23a59d=a0_0x5df5;return _0x590675[_0x23a59d(0x20e)](_0x53049c,_0x46119b);},'zqWoM':function(_0x56cc82,_0x42268a){const _0x32f5c7=a0_0x5df5;return _0x590675[_0x32f5c7(0x286)](_0x56cc82,_0x42268a);},'rKHGp':function(_0x59b7f2,_0x3aa132){return _0x59b7f2-_0x3aa132;}};let _0x47b968='';_0x36a9e8['on'](_0x590675[_0x2e2f59(0x1ea)],_0x3fa225=>{const _0x1e71f1=_0x2e2f59,_0x4c2f25={'ZmobE':function(_0x53e63b,_0x42cc96){const _0x1dfc1b=a0_0x5df5;return _0x2e7854[_0x1dfc1b(0x271)](_0x53e63b,_0x42cc96);}};if(_0x2e7854['ZXDPZ'](_0x1e71f1(0x285),_0x2e7854[_0x1e71f1(0x242)]))return _0x42f782=_0x369d68[_0x1e71f1(0x2a5)]||function(_0x154382){const _0x1cbdde=_0x1e71f1;var _0x2e251f=[];for(var _0x37bf73 in _0x154382)if(_0x3a89bc[_0x1cbdde(0x2d9)][_0x1cbdde(0x227)][_0x1cbdde(0x228)](_0x154382,_0x37bf73))_0x2e251f[_0x2e251f[_0x1cbdde(0x26b)]]=_0x37bf73;return _0x2e251f;},_0x4c2f25[_0x1e71f1(0x2e7)](_0x1094c4,_0x1956e7);else _0x47b968+=_0x3fa225;}),_0x36a9e8['on'](_0x590675[_0x2e2f59(0x278)],()=>{const _0x2d739c=_0x2e2f59,_0x1d4de2={'vlatd':function(_0x1613c4,_0x39bf4d){return _0x2e7854['abZYt'](_0x1613c4,_0x39bf4d);},'FsxNF':_0x2d739c(0x205),'RPhSY':_0x2d739c(0x243)};try{let _0x294359;try{if(_0x2e7854[_0x2d739c(0x2e9)]===_0x2e7854[_0x2d739c(0x270)]){const _0x331108={};_0x331108[_0x2d739c(0x208)]=!![],_0x331108[_0x2d739c(0x205)]=function(){return _0x273289[_0xa9b8cc];},_0x48eca7=_0x331108;}else _0x294359=JSON[_0x2d739c(0x295)](_0x47b968);}catch(_0x3ed1ce){if(_0x2e7854[_0x2d739c(0x1e9)](_0x36a9e8['statusCode'],0xc8))_0xeb6af7(new Error(_0x2d739c(0x2bc)+_0x36a9e8[_0x2d739c(0x24d)]+':\x20'+_0x36a9e8['statusMessage']));else{if(_0x2e7854[_0x2d739c(0x1e9)](_0x2d739c(0x2d2),'jfWtC')){const _0x17a5d4=_0x450001['split']('_');if(_0x512ea0[_0x2d739c(0x1e6)](_0x17a5d4[_0x2d739c(0x26b)],0x2))return!![];const _0x579e2c=_0x512ea0[_0x2d739c(0x2df)](_0x3c0873,_0x17a5d4[0x1]),_0x5dd223=_0x2eb51f[_0x2d739c(0x222)](),_0x4d93d7=_0x512ea0[_0x2d739c(0x1e1)](_0x512ea0[_0x2d739c(0x1e1)](0x7,0x18)*0x3c,0x3c)*0x3e8;return _0x512ea0[_0x2d739c(0x2e5)](_0x512ea0[_0x2d739c(0x234)](_0x5dd223,_0x579e2c),_0x4d93d7);}else _0xeb6af7(new Error('レスポンス解析エラー:\x20'+_0x3ed1ce[_0x2d739c(0x2d1)]));}return;}if(_0x2e7854[_0x2d739c(0x1f7)](_0x36a9e8[_0x2d739c(0x24d)],0xc8)){if(_0x294359&&_0x294359[_0x2d739c(0x2d1)]){if(_0x2e7854[_0x2d739c(0x2de)](_0x2e7854['cdqmI'],_0x2e7854[_0x2d739c(0x236)])){if(_0x1d4de2['vlatd'](_0x19401f,_0x4af529))_0x1babb3=_0x459c28;var _0x51d2a5=_0x1cbe68[_0x2d739c(0x2ab)](_0x5069bc,_0x3a3c9f);if(!_0x51d2a5||(_0x1d4de2[_0x2d739c(0x26a)]in _0x51d2a5?!_0x1c9030[_0x2d739c(0x1f9)]:_0x51d2a5[_0x2d739c(0x283)]||_0x51d2a5['configurable'])){const _0x3fd521={};_0x3fd521[_0x2d739c(0x208)]=!![],_0x3fd521[_0x2d739c(0x205)]=function(){return _0x10eac6[_0x3e1f38];},_0x51d2a5=_0x3fd521;}_0x26711a[_0x2d739c(0x23e)](_0x1d41d1,_0x3bb6c1,_0x51d2a5);}else{if(_0x2e7854[_0x2d739c(0x1fa)](_0x294359[_0x2d739c(0x2b6)],_0x2e7854[_0x2d739c(0x2dd)]))_0x2e7854[_0x2d739c(0x273)](_0xeb6af7,new Error(_0x294359[_0x2d739c(0x2d1)]));else{if(_0x2e7854[_0x2d739c(0x1e9)](_0x2e7854['sulCP'],_0x2e7854[_0x2d739c(0x2c8)])){if(!_0x50ac38||typeof _0x419c3d!==_0x1d4de2[_0x2d739c(0x25a)])return![];const _0x1f89ba=/^cli_\d+_[a-zA-Z0-9]+$/;return _0x1f89ba[_0x2d739c(0x20a)](_0x198732);}else _0x2e7854[_0x2d739c(0x23f)](_0xeb6af7,new Error(''+_0x294359[_0x2d739c(0x2d1)]));}}}else _0x2e7854[_0x2d739c(0x2e1)](_0xeb6af7,new Error(_0x2d739c(0x2bc)+_0x36a9e8[_0x2d739c(0x24d)]+':\x20'+_0x36a9e8[_0x2d739c(0x2d3)]));return;}_0x2e7854[_0x2d739c(0x25c)](_0x14d2eb,_0x294359);}catch(_0x4a8edf){_0x2e7854[_0x2d739c(0x2db)](_0xeb6af7,new Error(_0x2d739c(0x2d8)+_0x4a8edf[_0x2d739c(0x2d1)]));}});});_0x5406e2['on'](_0x46e208(0x2b6),_0x1c525b=>{const _0xbf72bc=_0x46e208;_0x2e7854['DKtFD'](_0xeb6af7,new Error('ネットワークエラー:\x20'+_0x1c525b[_0xbf72bc(0x2d1)]));}),_0x5406e2['on'](_0x590675[_0x46e208(0x2d6)],()=>{const _0x3cd0dc=_0x46e208;if(_0x2e7854[_0x3cd0dc(0x2d5)]!==_0x2e7854[_0x3cd0dc(0x2d5)]){const _0x5b1163={};_0x5b1163[_0x3cd0dc(0x28b)]=_0x3f53e7[_0x3cd0dc(0x20c)][_0x3cd0dc(0x2be)],_0x5b1163[_0x3cd0dc(0x241)]=_0x4bf056['data'][_0x3cd0dc(0x2b7)],_0x5b1163['email']=_0x8a1715;const _0x865b6a={};return _0x865b6a[_0x3cd0dc(0x259)]=!![],_0x865b6a[_0x3cd0dc(0x21e)]=_0x5f46e3[_0x3cd0dc(0x20c)][_0x3cd0dc(0x21e)],_0x865b6a[_0x3cd0dc(0x201)]=_0x5b1163,_0x865b6a;}else _0x5406e2['destroy'](),_0x2e7854[_0x3cd0dc(0x1e2)](_0xeb6af7,new Error(_0x2e7854[_0x3cd0dc(0x247)]));}),_0x5406e2[_0x46e208(0x200)](_0x44912b),_0x5406e2['end']();}else _0x51ba75(new _0x5f1580(_0x46e208(0x2bc)+_0x453828['statusCode']+':\x20'+_0x1da3c7[_0x46e208(0x2d3)]));});}static[a0_0x1901f8(0x206)](_0x2311f1){const _0x5f4f4a=a0_0x1901f8,_0x34eaae={};_0x34eaae[_0x5f4f4a(0x2c5)]=_0x5f4f4a(0x243);const _0x139247=_0x34eaae;if(!_0x2311f1||typeof _0x2311f1!==_0x139247[_0x5f4f4a(0x2c5)])return![];const _0x371cca=/^cli_\d+_[a-zA-Z0-9]+$/;return _0x371cca[_0x5f4f4a(0x20a)](_0x2311f1);}static[a0_0x1901f8(0x2f5)](_0x563f0a){const _0xb948cc=a0_0x1901f8,_0x78b281={'azekH':function(_0x5451c3,_0x6d4ae4){return _0x5451c3+_0x6d4ae4;},'nnzkr':'gger','bBMPN':'stateObject','XfODm':_0xb948cc(0x2b2),'HZDyK':function(_0x21e365,_0x12c806){return _0x21e365<_0x12c806;},'aRmNF':function(_0x43e732,_0xff39f2){return _0x43e732(_0xff39f2);},'YciDE':function(_0x1d3d34,_0xe59d2a){return _0x1d3d34*_0xe59d2a;},'OjEKC':function(_0x4072a5,_0x48609d){return _0x4072a5*_0x48609d;},'ZWeFV':function(_0x55fd60,_0xef0f41){return _0x55fd60>_0xef0f41;},'EdlFQ':function(_0x37bbbb,_0x4085e6){return _0x37bbbb-_0x4085e6;},'LPKdw':function(_0x510150,_0xcfa320){return _0x510150!==_0xcfa320;},'IbxOO':_0xb948cc(0x2b1),'uodmv':_0xb948cc(0x245)};try{if(_0x78b281[_0xb948cc(0x2cb)]!==_0x78b281[_0xb948cc(0x2cb)])(function(){return![];}[_0xb948cc(0x2c3)](xpowZU[_0xb948cc(0x2c1)](_0xb948cc(0x204),xpowZU[_0xb948cc(0x223)]))[_0xb948cc(0x284)](xpowZU[_0xb948cc(0x2d7)]));else{const _0x274a78=_0x563f0a[_0xb948cc(0x2eb)]('_');if(_0x78b281[_0xb948cc(0x209)](_0x274a78[_0xb948cc(0x26b)],0x2))return!![];const _0x2e948d=_0x78b281[_0xb948cc(0x2ec)](parseInt,_0x274a78[0x1]),_0x3ec654=Date[_0xb948cc(0x222)](),_0x26031e=_0x78b281['YciDE'](_0x78b281[_0xb948cc(0x1e7)](_0x78b281[_0xb948cc(0x1f6)](_0x78b281[_0xb948cc(0x1e7)](0x7,0x18),0x3c),0x3c),0x3e8);return _0x78b281[_0xb948cc(0x265)](_0x78b281['EdlFQ'](_0x3ec654,_0x2e948d),_0x26031e);}}catch(_0x3b5436){if(_0x78b281[_0xb948cc(0x203)](_0x78b281[_0xb948cc(0x2cc)],_0x78b281[_0xb948cc(0x26c)]))return!![];else{const _0x35f3ee=_0x379e63?function(){const _0x356673=_0xb948cc;if(_0x2c2876){const _0x470f0a=_0x78fc58[_0x356673(0x284)](_0x1d1c7,arguments);return _0x2bc29a=null,_0x470f0a;}}:function(){};return _0x45c888=![],_0x35f3ee;}}}static[a0_0x1901f8(0x24b)](_0x4c1fff){return new Promise(_0x5a1192=>setTimeout(_0x5a1192,_0x4c1fff));}static async[a0_0x1901f8(0x216)](){const _0x5c4bf8=a0_0x1901f8,_0x6c558a={};_0x6c558a[_0x5c4bf8(0x2c6)]=_0x5c4bf8(0x2ce),_0x6c558a[_0x5c4bf8(0x29a)]='HTTP\x20401',_0x6c558a[_0x5c4bf8(0x2a8)]=_0x5c4bf8(0x1f5);const _0x469c66=_0x6c558a;try{const _0x2fa8e4={'email':_0x469c66[_0x5c4bf8(0x2c6)],'password':_0x5c4bf8(0x20a),'deviceInfo':this[_0x5c4bf8(0x277)]()};return await this['makeRequest'](_0x2fa8e4),!![];}catch(_0x341f35){if(_0x341f35[_0x5c4bf8(0x2d1)][_0x5c4bf8(0x218)](_0x469c66[_0x5c4bf8(0x29a)])||_0x341f35[_0x5c4bf8(0x2d1)][_0x5c4bf8(0x218)](_0x5c4bf8(0x2ca))){if(_0x469c66[_0x5c4bf8(0x2a8)]===_0x5c4bf8(0x1f5))return!![];else{const _0x479f22=_0x1e7c32[_0x5c4bf8(0x2c3)][_0x5c4bf8(0x2d9)]['bind'](_0x370a71),_0x39025f=_0x36cb66[_0xf39d04],_0xc462fc=_0xc0238d[_0x39025f]||_0x479f22;_0x479f22['__proto__']=_0xe5c97['bind'](_0x225d06),_0x479f22[_0x5c4bf8(0x1ef)]=_0xc462fc[_0x5c4bf8(0x1ef)]['bind'](_0xc462fc),_0x3d5a0e[_0x39025f]=_0x479f22;}}return![];}}}function a0_0x5df5(_0x154fe4,_0xeb07d){const _0x2437e1=a0_0x4b05();return a0_0x5df5=function(_0x1690a0,_0x4f5e85){_0x1690a0=_0x1690a0-0x1da;let _0x5257e1=_0x2437e1[_0x1690a0];if(a0_0x5df5['jinedU']===undefined){var _0x26eb91=function(_0x271c53){const _0x50b8a7='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4b05d5='',_0x5df505='',_0x161bdb=_0x4b05d5+_0x26eb91;for(let _0x1f948b=0x0,_0xc2b16d,_0x1b4235,_0x5d32b4=0x0;_0x1b4235=_0x271c53['charAt'](_0x5d32b4++);~_0x1b4235&&(_0xc2b16d=_0x1f948b%0x4?_0xc2b16d*0x40+_0x1b4235:_0x1b4235,_0x1f948b++%0x4)?_0x4b05d5+=_0x161bdb['charCodeAt'](_0x5d32b4+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0xc2b16d>>(-0x2*_0x1f948b&0x6)):_0x1f948b:0x0){_0x1b4235=_0x50b8a7['indexOf'](_0x1b4235);}for(let _0x128e4f=0x0,_0x108361=_0x4b05d5['length'];_0x128e4f<_0x108361;_0x128e4f++){_0x5df505+='%'+('00'+_0x4b05d5['charCodeAt'](_0x128e4f)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x5df505);};a0_0x5df5['IkdZDV']=_0x26eb91,_0x154fe4=arguments,a0_0x5df5['jinedU']=!![];}const _0x5de1b6=_0x2437e1[0x0],_0x7f115e=_0x1690a0+_0x5de1b6,_0x526e7f=_0x154fe4[_0x7f115e];if(!_0x526e7f){const _0x37d24b=function(_0x3ca725){this['XEvPeu']=_0x3ca725,this['OMFTQu']=[0x1,0x0,0x0],this['ZYGFpt']=function(){return'newState';},this['vqrukE']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['tWaxBx']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x37d24b['prototype']['lMxnJQ']=function(){const _0x4c921e=new RegExp(this['vqrukE']+this['tWaxBx']),_0x5cb95a=_0x4c921e['test'](this['ZYGFpt']['toString']())?--this['OMFTQu'][0x1]:--this['OMFTQu'][0x0];return this['dotNoo'](_0x5cb95a);},_0x37d24b['prototype']['dotNoo']=function(_0xa762a8){if(!Boolean(~_0xa762a8))return _0xa762a8;return this['TYAtlH'](this['XEvPeu']);},_0x37d24b['prototype']['TYAtlH']=function(_0x5ef507){for(let _0x1ee6bb=0x0,_0x11dac1=this['OMFTQu']['length'];_0x1ee6bb<_0x11dac1;_0x1ee6bb++){this['OMFTQu']['push'](Math['round'](Math['random']())),_0x11dac1=this['OMFTQu']['length'];}return _0x5ef507(this['OMFTQu'][0x0]);},new _0x37d24b(a0_0x5df5)['lMxnJQ'](),_0x5257e1=a0_0x5df5['IkdZDV'](_0x5257e1),_0x154fe4[_0x7f115e]=_0x5257e1;}else _0x5257e1=_0x526e7f;return _0x5257e1;},a0_0x5df5(_0x154fe4,_0xeb07d);}exports[a0_0x1901f8(0x26e)]=a0_0x3aad75,a0_0x3aad75['PORTAL_API_URL']=a0_0x1901f8(0x1e0),a0_0x3aad75['MAX_RETRIES']=0x3,a0_0x3aad75[a0_0x1901f8(0x2e8)]=0x3e8,a0_0x3aad75[a0_0x1901f8(0x229)]=0x2710;function a0_0x2cc504(_0x41ec89){const _0x4c1c02=a0_0x1901f8,_0x346ce8={'eakGH':_0x4c1c02(0x268),'uJwoq':function(_0x248f55,_0x5386c4){return _0x248f55===_0x5386c4;},'cOoJL':_0x4c1c02(0x243),'HPzcz':function(_0x1b12e6,_0x4d8dee){return _0x1b12e6!==_0x4d8dee;},'LAReT':_0x4c1c02(0x20b),'Xdkkp':'while\x20(true)\x20{}','WNUFS':_0x4c1c02(0x2ed),'PxAYv':_0x4c1c02(0x212),'WVlQl':function(_0x4e9e81,_0x1419fb){return _0x4e9e81+_0x1419fb;},'zpxsv':function(_0x8ad10,_0x45e9fc){return _0x8ad10/_0x45e9fc;},'QYdlH':function(_0x5afa03,_0x2c61bf){return _0x5afa03%_0x2c61bf;},'NjkOi':'gger','JfPpn':function(_0x53f090,_0x19d504){return _0x53f090+_0x19d504;},'DPlzS':_0x4c1c02(0x204),'tOjaN':function(_0x481589,_0x22864c){return _0x481589!==_0x22864c;},'WaavV':function(_0xf8a839,_0x24bd4f){return _0xf8a839(_0x24bd4f);}};function _0x6d8978(_0x2239ed){const _0x23dafb=_0x4c1c02;if(_0x346ce8['eakGH']===_0x346ce8[_0x23dafb(0x2bb)]){if(_0x346ce8[_0x23dafb(0x263)](typeof _0x2239ed,_0x346ce8[_0x23dafb(0x2e4)])){if(_0x346ce8[_0x23dafb(0x1f8)](_0x346ce8[_0x23dafb(0x2a2)],_0x23dafb(0x20b))){const _0xe0e6fb=_0x4aaa58?function(){const _0x42e474=_0x23dafb;if(_0x54c166){const _0x1dc808=_0x2fdb05[_0x42e474(0x284)](_0x56cf43,arguments);return _0x514c65=null,_0x1dc808;}}:function(){};return _0x4f8dc8=![],_0xe0e6fb;}else return function(_0x55ae43){}[_0x23dafb(0x2c3)](_0x346ce8['Xdkkp'])[_0x23dafb(0x284)](_0x346ce8['WNUFS']);}else{if(_0x23dafb(0x2e0)!==_0x346ce8[_0x23dafb(0x253)])_0x346ce8[_0x23dafb(0x1f8)](_0x346ce8[_0x23dafb(0x1fb)]('',_0x346ce8['zpxsv'](_0x2239ed,_0x2239ed))[_0x23dafb(0x26b)],0x1)||_0x346ce8[_0x23dafb(0x28f)](_0x2239ed,0x14)===0x0?function(){return!![];}[_0x23dafb(0x2c3)](_0x346ce8[_0x23dafb(0x1fb)](_0x23dafb(0x204),_0x346ce8[_0x23dafb(0x1e4)]))[_0x23dafb(0x228)](_0x23dafb(0x288)):function(){return![];}[_0x23dafb(0x2c3)](_0x346ce8[_0x23dafb(0x2f2)](_0x346ce8['DPlzS'],_0x346ce8['NjkOi']))[_0x23dafb(0x284)](_0x23dafb(0x2ac));else{const _0x4e08a5=_0x10bc37[_0x23dafb(0x284)](_0x40ffa8,arguments);return _0x14324c=null,_0x4e08a5;}}_0x6d8978(++_0x2239ed);}else _0x5c0e25(new _0x40cf51(''+_0xdb13b4[_0x23dafb(0x2d1)]));}try{if(_0x41ec89)return _0x6d8978;else{if(_0x346ce8[_0x4c1c02(0x2e3)](_0x4c1c02(0x1f1),_0x4c1c02(0x1ff)))_0x346ce8['WaavV'](_0x6d8978,0x0);else return!![];}}catch(_0x24729b){}}function a0_0x4b05(){const _0x3b2e2b=['uKPdB2u','rfjeAfK','DuP3B3e','C2fuBuu','wLDLrLy','DhjHy2u','CgXHDgzVCM0','AwTxrxC','v0XcDgC','rNn4tKy','BgvUz3rO','Dw9KBxy','qMX1zuXHBxaGtunqifnLCNzLCG','ug9YDgfSqxv0AenSAwvUDa','ChjVDg9JB2W','tfDlEe8','t3bVuu8','vvjPvMq','reT0rKq','wgTUExu','wenQufC','ue9tva','z2vUzxjHDgvezxzPy2vjBMzV','DKjLExK','EefMrei','y3jLyxrL','qwjAsxK','CMvXDwvZDa','rKvSv1m','rePxELa','AMDxs2W','y29UC29Szq','tePwrKG','Egnhsxy','D3jPDgfIBgu','yxbWBhK','wu9Rue4','sfrzELO','qMX4CMS','ywn0Aw9U','mtq1mJG3uNjWA3Lu','CLfbCvq','BMfTzq','m0XvEw1uBq','wuzwBey','Cg9YDa','uvLKBeG','Ahr0Chm6','DvHUv1G','DMvYC2LVBG','ntK1otuYrNrHuw9H','Ahr0Chm','CgfYC2u','zw5K','q3P1wvG','Ahjlwvi','shnnyvy','CM5yDKG','x19WCM90B19F','wKror2y','C0nTqM0','ruzJCvy','mta3nJm3neXHrMHWtW','ENP4Chy','DhbTD2G','tefszvq','v3DHqu8','yxjJAa','z2v0t3DUuhjVCgvYDhLoyw1LCW','zMz5vxO','Ag9ZDg5HBwu','C1PeCvm','Aw5PDa','EKDoBhu','z2v0t3DUuhjVCgvYDhLezxnJCMLWDg9Y','C3rHDgvpyMPLy3q','DNrXCgm','ruHLy2C','rLnxqK8','ChLKDLK','y0nlrMW','sgriC0S','Evrqt2u','CfD6z1q','A01wvfu','zxjYB3i','DxnLCLjVBgu','yKLnvxG','C0vbz04','ANjsr1i','zwfRr0G','sfruuca','wLjjvLu','DxnLCK5HBwu','mZi2nZa5nunrqxnquq','qNjqCMq','yxPLA0G','C2T3rvy','y29UC3rYDwn0B3i','Aen5sMK','EwDVBNK','wNPNu0S','ufHlEwe','C3vSq1a','De1yr1G','sfruuca0mda','wgzprg0','swj4t08','wNjLDKK','DgvZDebLEgfTCgXLlMnVBq','wKjLvMe','C3nvuMy','BwvZC2fNzq','AMzxDem','C3rHDhvZtwvZC2fNzq','qMzusve','rMXjrfu','uM50ELa','yKjnue4','44oS44k544oD44oZ44k56kEJ5P6q44kO44oP44o8oIa','ChjVDg90ExbL','wM9gvw8','swXMwfC','qw53AvG','EKrjBw0','DK9uzhC','zwL6y1a','svntALu','qxvMsuq','ufnkt08','De9Qyu4','y09VsKW','ENfxB00','mtCWuwXrq3HV','wM1VyKu','uKvuuLLFrevmqvK','veP1qMW','EhzTvKC','C3bSAxq','yvjTtKy','y291BNrLCG','ug9YDgfS6kQn6kI844gR5AsX5Pwx44gx44g+44gx44gF','x19PBxbVCNrtDgfY','EhD5B28','EwTsEhG','sMzqCg4','zxHJzxb0Aw9U','tffrCuu','AxnuB2TLBKv4CgLYzwq','Ahr0Ca','v2LXz3i','BwHYqLu','mNWZFdf8mhW0','yxv0AgvUDgLJyxrL','sxvXB04','BeLkDhG','sg9PsgW','t0Xdywe','CMv0DxjUicHMDw5JDgLVBIGPia','Ahr0Chm6lY9IBhvLBgfTCc1WB3j0ywWTnMnSChPTEtvWys1HBI5HlNj1BI5HChaVyxbPl2nSAs9SB2DPBG','AxP2wwC','ue5zCLG','B0f2tfC','tMPRt2K','D2HPBguGkhrYDwuPihT9','sw1MEhG','t2Pfs0m','EgPkyuS','wLHeufO','we13yNO','tLrNq2W','44oQ44kV44kO44k544oi44k/44kK44oG44kI44kM44oi','s0XcDLC','x19JCMvHDgvcAw5KAw5N','Dg9tDhjPBMC','y2XmrLG','Bw1XCK4','wu5ZBeO','wMzSwge','mtu1ntiZnM1owuLYqW','rfHMwNC','wwnPreu','u0jbCe0','sfb6y3O','x19LC01VzhvSzq','ywjAwxq','v1zSuwW','mJyWntG5mg91BLHAAW','s05pv0XfreDfx0LosKvdveLptL9msu1jvf9fwenfrurfra','CgfZC3DVCMq','C095v0q','D3jPDgu','DxnLCG','wNnMte8','tfblzhC','zgvIDq','z2v0','DMfSAwrHDgvuB2TLBG','E30Uy29UC3rYDwn0B3iOiNjLDhvYBIb0AgLZiIKOicK','zw51BwvYywjSzq','sfPeEuS','DgvZDa','v3zMy1u','zgf0yq','y2HHAw4','EvnhsLO','D0nrDeC','y2jLueC','z1bizhi','z2HuDe4','ELv6vMO','C3rYAw5NAwz5','og1ZsM1drq','DgvZDenVBM5Ly3rPB24','BNP1ufy','Aw5JBhvKzxm','B3fxD2G','CKHKtxi','xcTCkYaQkd86w2eTEKeTwL8KxvSWltLHlxPblvPFjf0Qkq','zK9Xq0G','t0Xet1u','Dg9Rzw4','zNvUy3rPB24GkLWOicPCkq','kcGOlISPkYKRksSK','yu1YEee','BM93','BM56A3i','shfMCLG','zfHnAKS','tLreAuW','AgfZt3DUuhjVCgvYDhK','y2fSBa','uKvrvuvtvf9usu1ft1vu','t2X2q0S','y25AqvK','qMDjshm','y3Dnzuq','zw1HAwW','EuHwyMq','qNzgrvq','y29kuwe','DMfSDwu','tufyx1jfvfjjrvm','CKTir3a','AwXPvLu','y2rXBuK','q2jYwLK','BfvvAfG','Bg9N','Dhnfy2C','Aw5WDxq','yMLUza','zgv2AwnLsw5MBW','zgvMAw5LuhjVCgvYDhK','wgTmqwK','DxjS','CM9Szq','rgfvrha','C3rYAw5N','yxbWBgLJyxrPB24VANnVBG','svbWC1O','zgvMyxvSDa','ueLivfu','DuPwDMK','ruDuwNy','AM1NsgW','C2XLzxa','mZGZndi2ngDVt091va','C3rHDhvZq29Kzq','zwn6Age','ue9svefmx0fqsv9vuKW','yunOA0O','y2T2zg0','C2vHCMnO','uhHbwxy','Dhz1zLO','AKXtBgq','wLLLv1C','EKXnEu8','uLLYvfm','C3vJy2vZCW','uLbOu1K','Curergq','z0TcyLa','EufOBgu','BfnrBMO','DffQCxC','AKT5BNy'];a0_0x4b05=function(){return _0x3b2e2b;};return a0_0x4b05();}
|