tavern-harness 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/vite.config.ts +7 -4
package/package.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -6,9 +6,12 @@ import net from 'node:net';
|
|
|
6
6
|
import { randomBytes } from 'node:crypto';
|
|
7
7
|
import { spawn, type ChildProcess } from 'node:child_process';
|
|
8
8
|
import { readFileSync, existsSync } from 'node:fs';
|
|
9
|
-
import { join } from 'node:path';
|
|
9
|
+
import { dirname, join } from 'node:path';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
10
11
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
11
12
|
|
|
13
|
+
const projectRoot = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
|
|
12
15
|
/**
|
|
13
16
|
* CORS 转发中间件:为本地(无 CORS 头)的 OpenAI 兼容服务提供同源代理。
|
|
14
17
|
* Base URL 填 http://localhost:5173/api/192.168.50.175:8788/ 即可;
|
|
@@ -71,8 +74,8 @@ function sandboxProxyPlugin(): Plugin {
|
|
|
71
74
|
let childPort: number | null = null;
|
|
72
75
|
const serviceToken = randomBytes(32).toString('base64url');
|
|
73
76
|
const approvalToken = randomBytes(32).toString('base64url');
|
|
74
|
-
const lockPath = join(
|
|
75
|
-
const SANDBOX_SCRIPT = join(
|
|
77
|
+
const lockPath = join(projectRoot, '.sandbox-port');
|
|
78
|
+
const SANDBOX_SCRIPT = join(projectRoot, 'sandbox-server.mjs');
|
|
76
79
|
const DEFAULT_PORT = 17891;
|
|
77
80
|
|
|
78
81
|
const loadPort = () => {
|
|
@@ -160,7 +163,7 @@ function sandboxProxyPlugin(): Plugin {
|
|
|
160
163
|
if (availablePort == null) return null;
|
|
161
164
|
childPort = availablePort;
|
|
162
165
|
const child = spawn(process.execPath, [SANDBOX_SCRIPT, String(availablePort)], {
|
|
163
|
-
cwd:
|
|
166
|
+
cwd: projectRoot,
|
|
164
167
|
stdio: 'ignore',
|
|
165
168
|
windowsHide: true,
|
|
166
169
|
env: {
|