(resourceId: string)
| 72 | } |
| 73 | |
| 74 | export async function invokeResource(resourceId: string): Promise<ResourceSnapshotResult> { |
| 75 | const manifest = resolveResourceManifest(resourceId); |
| 76 | if (!manifest) { |
| 77 | throw new Error(`Resource '${resourceId}' not found in manifest`); |
| 78 | } |
| 79 | |
| 80 | const transport = new StdioClientTransport({ |
| 81 | command: 'node', |
| 82 | args: [CLI_PATH, 'mcp'], |
| 83 | env: createSnapshotHarnessEnv({ |
| 84 | NODE_ENV: 'test', |
| 85 | XCODEBUILDMCP_ENABLED_WORKFLOWS: '', |
| 86 | }), |
| 87 | stderr: 'pipe', |
| 88 | }); |
| 89 | |
| 90 | const client = new Client({ name: 'resource-snapshot-client', version: '1.0.0' }); |
| 91 | await client.connect(transport, { timeout: 30_000 }); |
| 92 | |
| 93 | try { |
| 94 | const result = await client.readResource({ uri: manifest.uri }, { timeout: 120_000 }); |
| 95 | const rawText = extractResourceText(result); |
| 96 | |
| 97 | return { |
| 98 | text: normalizeResourceOutput(rawText), |
| 99 | rawText, |
| 100 | }; |
| 101 | } finally { |
| 102 | await client.close(); |
| 103 | } |
| 104 | } |
no test coverage detected