| 1234567891011121314151617181920212223242526272829303132333435 |
- /* Local tool execution and credential availability only; no collection or business writes. */
- const fs = require('node:fs');
- const path = require('node:path');
- const {createRequire} = require('node:module');
- const root = path.resolve(process.argv[2]);
- const load = createRequire(path.join(root, 'package.json'));
- process.env.VOC_SKILL_NO_UPDATE_CHECK = '1';
- const timer = setTimeout(() => { console.error('{"ok":false,"error":{"code":"VOC_CHECK_TIMEOUT"}}'); process.exit(1); }, 30000);
- async function main() {
- const {Client} = load('@modelcontextprotocol/sdk/client/index.js');
- const {InMemoryTransport} = load('@modelcontextprotocol/sdk/inMemory.js');
- const {createServer} = load('./mcp/src/server.js');
- const {searchVocApis, getVocApiDoc} = load('./mcp/src/tools/voc-api-catalog-run.js');
- const manifest = JSON.parse(fs.readFileSync(path.join(root, 'skill-package-manifest.json')));
- if (manifest.version !== '0.3.44') throw Error('VERSION');
- const client = new Client({name: 'ksf-enterprise-voc-check', version: '1.0.0'});
- const server = createServer();
- const [a,b] = InMemoryTransport.createLinkedPair();
- try {
- await server.connect(b); await client.connect(a);
- const names = (await client.listTools()).tools.map(t => t.name).sort();
- if (!manifest.mcpTools.every(n => names.includes(n)) || !['voc_api_search','voc_api_doc','voc_api_call'].every(n => names.includes(n))) throw Error('TOOLS');
- const found = await searchVocApis({platform: 'jd', limit: 5});
- if (found.status !== 'ok' || !found.data?.endpoints?.length) throw Error('SEARCH');
- const doc = await getVocApiDoc({id: found.data.endpoints[0].id});
- if (doc.status !== 'ok' || !doc.data?.callTemplate) throw Error('DOC');
- for (const name of manifest.skills) if (!fs.statSync(path.join(root,'skills',name,'SKILL.md')).isFile()) throw Error('SUBSKILL');
- const context = load('./mcp/src/core/credentials.js').readCredentialContext({});
- console.log(JSON.stringify({ok: true, version: manifest.version, tools: names, subskills: manifest.skills.length,
- localParameterDocumentRead: true, catalogSearchPassed: true,
- credentialAvailable: Boolean(context.newApiToken || context.sessionToken),
- hostRegistrationVerified: false, liveAccessVerified: false, collectionRequests: 0, databaseWrites: 0}));
- } finally { await client.close(); await server.close(); clearTimeout(timer); }
- }
- main().catch(() => { clearTimeout(timer); console.error('{"ok":false,"error":{"code":"VOC_LOCAL_RUNTIME_CHECK_FAILED"}}'); process.exitCode=1; });
|