vite-plugin-opencode-assistant 1.1.0 → 1.1.1
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/es/core/api.mjs +1 -2
- package/es/core/opencode-web.mjs +1 -1
- package/es/core/proxy-server.mjs +1 -1
- package/es/core/service.mjs +1 -1
- package/es/endpoints/context.mjs +1 -1
- package/es/endpoints/logs.mjs +4 -4
- package/es/endpoints/sessions.mjs +1 -1
- package/es/endpoints/sse.mjs +1 -1
- package/es/endpoints/start.mjs +1 -1
- package/es/endpoints/warmup.mjs +2 -1
- package/es/endpoints/widget.mjs +1 -1
- package/es/index.mjs +2 -3
- package/es/utils/system.mjs +1 -1
- package/lib/client.js +2781 -2642
- package/lib/core/api.cjs +4 -3
- package/lib/core/opencode-web.cjs +4 -4
- package/lib/core/proxy-server.cjs +1 -1
- package/lib/core/service.cjs +2 -1
- package/lib/endpoints/context.cjs +3 -3
- package/lib/endpoints/logs.cjs +6 -5
- package/lib/endpoints/sessions.cjs +3 -3
- package/lib/endpoints/sse.cjs +3 -3
- package/lib/endpoints/start.cjs +2 -2
- package/lib/endpoints/warmup.cjs +2 -1
- package/lib/endpoints/widget.cjs +3 -3
- package/lib/index.cjs +3 -2
- package/lib/utils/system.cjs +3 -3
- package/package.json +5 -5
package/lib/core/api.cjs
CHANGED
|
@@ -71,7 +71,8 @@ module.exports = __toCommonJS(api_exports);
|
|
|
71
71
|
var import_http = __toESM(require("http"));
|
|
72
72
|
var import_shared = require("@vite-plugin-opencode-assistant/shared");
|
|
73
73
|
var import_node = require("@vite-plugin-opencode-assistant/shared/node");
|
|
74
|
-
|
|
74
|
+
var import_node2 = require("@vite-plugin-opencode-assistant/shared/node");
|
|
75
|
+
const log = (0, import_node.createLogger)("API");
|
|
75
76
|
class OpenCodeAPI {
|
|
76
77
|
constructor(hostname, getPort, getProxyPort, warmupChromeMcpConfig = false, chromeDevtoolsPort = import_shared.CHROME_DEVTOOLS_PORT) {
|
|
77
78
|
__publicField(this, "hostname", hostname);
|
|
@@ -81,7 +82,7 @@ class OpenCodeAPI {
|
|
|
81
82
|
__publicField(this, "chromeDevtoolsPort", chromeDevtoolsPort);
|
|
82
83
|
}
|
|
83
84
|
createHttpRequest(options, body, timeout) {
|
|
84
|
-
const timer = new
|
|
85
|
+
const timer = new import_node.PerformanceTimer("HTTP Request", {
|
|
85
86
|
operation: `${options.method || "GET"} ${options.path}`
|
|
86
87
|
});
|
|
87
88
|
return new Promise((resolve, reject) => {
|
|
@@ -305,7 +306,7 @@ class OpenCodeAPI {
|
|
|
305
306
|
return __async(this, null, function* () {
|
|
306
307
|
const timer = log.timer(`${operation}WarmupChromeMcp`, { viteOrigin, operation });
|
|
307
308
|
let warmupSessionId = null;
|
|
308
|
-
const chromeAvailable = yield (0,
|
|
309
|
+
const chromeAvailable = yield (0, import_node2.checkChromeDevToolsAvailable)(this.chromeDevtoolsPort);
|
|
309
310
|
if (!chromeAvailable) {
|
|
310
311
|
const error = new import_shared.ChromeMcpWarmupError(
|
|
311
312
|
import_shared.ChromeMcpWarmupErrorType.CHROME_NOT_CONNECTED,
|
|
@@ -52,10 +52,10 @@ var import_execa = require("execa");
|
|
|
52
52
|
var import_fs = __toESM(require("fs"));
|
|
53
53
|
var import_module = require("module");
|
|
54
54
|
var import_path = __toESM(require("path"));
|
|
55
|
-
var
|
|
55
|
+
var import_node = require("@vite-plugin-opencode-assistant/shared/node");
|
|
56
56
|
const require2 = (0, import_module.createRequire)(import_path.default.join(process.cwd(), "package.json"));
|
|
57
57
|
const packageDir = resolvePackageDir();
|
|
58
|
-
const log = (0,
|
|
58
|
+
const log = (0, import_node.createLogger)("OpenCodeWeb");
|
|
59
59
|
function prepareOpenCodeRuntime(cwd) {
|
|
60
60
|
const cacheDir = import_path.default.join(cwd, "node_modules", ".cache", "opencode");
|
|
61
61
|
const pluginsDir = import_path.default.join(cacheDir, "plugins");
|
|
@@ -140,7 +140,7 @@ function startOpenCodeWeb(options) {
|
|
|
140
140
|
const output = data.toString().trim();
|
|
141
141
|
if (output) {
|
|
142
142
|
log.debug("[OpenCode stdout]", { output });
|
|
143
|
-
(0,
|
|
143
|
+
(0, import_node.getProcessLogBuffer)().addOpenCodeStdout(output);
|
|
144
144
|
}
|
|
145
145
|
});
|
|
146
146
|
(_b = proc.stderr) == null ? void 0 : _b.on("data", (data) => {
|
|
@@ -148,7 +148,7 @@ function startOpenCodeWeb(options) {
|
|
|
148
148
|
if (output) {
|
|
149
149
|
if (output.includes("MaxListenersExceededWarning")) return;
|
|
150
150
|
log.warn("[OpenCode stderr]", { output });
|
|
151
|
-
(0,
|
|
151
|
+
(0, import_node.getProcessLogBuffer)().addOpenCodeStderr(output);
|
|
152
152
|
}
|
|
153
153
|
});
|
|
154
154
|
return proc;
|
|
@@ -531,7 +531,7 @@ function generateBridgeScript(options) {
|
|
|
531
531
|
function insertFilePart(element) {
|
|
532
532
|
const promptInput = document.querySelector('[data-component="prompt-input"]');
|
|
533
533
|
if (!promptInput) {
|
|
534
|
-
|
|
534
|
+
log.warn('Prompt input not found');
|
|
535
535
|
return;
|
|
536
536
|
}
|
|
537
537
|
|
package/lib/core/service.cjs
CHANGED
|
@@ -57,9 +57,10 @@ __export(service_exports, {
|
|
|
57
57
|
module.exports = __toCommonJS(service_exports);
|
|
58
58
|
var import_opencode_web = require("./opencode-web.cjs");
|
|
59
59
|
var import_shared = require("@vite-plugin-opencode-assistant/shared");
|
|
60
|
+
var import_node = require("@vite-plugin-opencode-assistant/shared/node");
|
|
60
61
|
var import_system = require("../utils/system.cjs");
|
|
61
62
|
var import_proxy_server = require("./proxy-server.cjs");
|
|
62
|
-
const log = (0,
|
|
63
|
+
const log = (0, import_node.createLogger)("Service");
|
|
63
64
|
class OpenCodeService {
|
|
64
65
|
constructor(config, api, sseClients, onPortAllocated, onProxyPortAllocated) {
|
|
65
66
|
__publicField(this, "config", config);
|
|
@@ -41,11 +41,11 @@ __export(context_exports, {
|
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(context_exports);
|
|
43
43
|
var import_shared = require("@vite-plugin-opencode-assistant/shared");
|
|
44
|
-
var
|
|
45
|
-
const log = (0,
|
|
44
|
+
var import_node = require("@vite-plugin-opencode-assistant/shared/node");
|
|
45
|
+
const log = (0, import_node.createLogger)("Endpoints:Context");
|
|
46
46
|
function setupContextEndpoint(server, ctx) {
|
|
47
47
|
server.middlewares.use(import_shared.CONTEXT_API_PATH, (req, res) => __async(null, null, function* () {
|
|
48
|
-
const reqCtx = new
|
|
48
|
+
const reqCtx = new import_node.RequestContext(req.method || "GET", import_shared.CONTEXT_API_PATH);
|
|
49
49
|
res.setHeader("Content-Type", "application/json");
|
|
50
50
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
51
51
|
res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
|
package/lib/endpoints/logs.cjs
CHANGED
|
@@ -40,12 +40,13 @@ __export(logs_exports, {
|
|
|
40
40
|
setupLogsEndpoint: () => setupLogsEndpoint
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(logs_exports);
|
|
43
|
+
var import_node = require("@vite-plugin-opencode-assistant/shared/node");
|
|
44
|
+
var import_node2 = require("@vite-plugin-opencode-assistant/shared/node");
|
|
43
45
|
var import_shared = require("@vite-plugin-opencode-assistant/shared");
|
|
44
|
-
|
|
45
|
-
const log = (0, import_shared2.createLogger)("Endpoints:Logs");
|
|
46
|
+
const log = (0, import_node2.createLogger)("Endpoints:Logs");
|
|
46
47
|
function setupLogsEndpoint(server) {
|
|
47
|
-
server.middlewares.use(
|
|
48
|
-
const reqCtx = new
|
|
48
|
+
server.middlewares.use(import_shared.LOGS_API_PATH, (req, res) => __async(null, null, function* () {
|
|
49
|
+
const reqCtx = new import_node2.RequestContext(req.method || "GET", import_shared.LOGS_API_PATH);
|
|
49
50
|
res.setHeader("Content-Type", "application/json");
|
|
50
51
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
51
52
|
res.setHeader("Access-Control-Allow-Methods", "GET, DELETE, OPTIONS");
|
|
@@ -56,7 +57,7 @@ function setupLogsEndpoint(server) {
|
|
|
56
57
|
reqCtx.end(200);
|
|
57
58
|
return;
|
|
58
59
|
}
|
|
59
|
-
const buffer = (0,
|
|
60
|
+
const buffer = (0, import_node.getProcessLogBuffer)();
|
|
60
61
|
if (req.method === "GET") {
|
|
61
62
|
try {
|
|
62
63
|
const url = new URL(req.url || "", `http://${req.headers.host || "localhost"}`);
|
|
@@ -41,11 +41,11 @@ __export(sessions_exports, {
|
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(sessions_exports);
|
|
43
43
|
var import_shared = require("@vite-plugin-opencode-assistant/shared");
|
|
44
|
-
var
|
|
45
|
-
const log = (0,
|
|
44
|
+
var import_node = require("@vite-plugin-opencode-assistant/shared/node");
|
|
45
|
+
const log = (0, import_node.createLogger)("Endpoints:Sessions");
|
|
46
46
|
function setupSessionsEndpoint(server, ctx) {
|
|
47
47
|
server.middlewares.use(import_shared.SESSIONS_API_PATH, (req, res) => __async(null, null, function* () {
|
|
48
|
-
const reqCtx = new
|
|
48
|
+
const reqCtx = new import_node.RequestContext(req.method || "GET", import_shared.SESSIONS_API_PATH);
|
|
49
49
|
res.setHeader("Content-Type", "application/json");
|
|
50
50
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
51
51
|
res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
|
package/lib/endpoints/sse.cjs
CHANGED
|
@@ -41,11 +41,11 @@ __export(sse_exports, {
|
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(sse_exports);
|
|
43
43
|
var import_shared = require("@vite-plugin-opencode-assistant/shared");
|
|
44
|
-
var
|
|
45
|
-
const log = (0,
|
|
44
|
+
var import_node = require("@vite-plugin-opencode-assistant/shared/node");
|
|
45
|
+
const log = (0, import_node.createLogger)("Endpoints:SSE");
|
|
46
46
|
function setupSseEndpoint(server, ctx) {
|
|
47
47
|
server.middlewares.use(import_shared.SSE_EVENTS_PATH, (req, res) => __async(null, null, function* () {
|
|
48
|
-
const reqCtx = new
|
|
48
|
+
const reqCtx = new import_node.RequestContext("GET", import_shared.SSE_EVENTS_PATH);
|
|
49
49
|
res.writeHead(200, {
|
|
50
50
|
"Content-Type": "text/event-stream",
|
|
51
51
|
"Cache-Control": "no-cache",
|
package/lib/endpoints/start.cjs
CHANGED
|
@@ -41,10 +41,10 @@ __export(start_exports, {
|
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(start_exports);
|
|
43
43
|
var import_shared = require("@vite-plugin-opencode-assistant/shared");
|
|
44
|
-
var
|
|
44
|
+
var import_node = require("@vite-plugin-opencode-assistant/shared/node");
|
|
45
45
|
function setupStartEndpoint(server, ctx) {
|
|
46
46
|
server.middlewares.use(import_shared.START_API_PATH, (_req, res) => __async(null, null, function* () {
|
|
47
|
-
const reqCtx = new
|
|
47
|
+
const reqCtx = new import_node.RequestContext("GET", import_shared.START_API_PATH);
|
|
48
48
|
res.setHeader("Content-Type", "application/json");
|
|
49
49
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
50
50
|
res.writeHead(200);
|
package/lib/endpoints/warmup.cjs
CHANGED
|
@@ -42,8 +42,9 @@ __export(warmup_exports, {
|
|
|
42
42
|
setupWarmupEndpoint: () => setupWarmupEndpoint
|
|
43
43
|
});
|
|
44
44
|
module.exports = __toCommonJS(warmup_exports);
|
|
45
|
+
var import_node = require("@vite-plugin-opencode-assistant/shared/node");
|
|
45
46
|
var import_shared = require("@vite-plugin-opencode-assistant/shared");
|
|
46
|
-
const log = (0,
|
|
47
|
+
const log = (0, import_node.createLogger)("Endpoints:Warmup");
|
|
47
48
|
function setupWarmupEndpoint(server, ctx) {
|
|
48
49
|
server.middlewares.use(import_shared.WARMUP_API_PATH, (req, res) => __async(null, null, function* () {
|
|
49
50
|
if (req.method === "GET") {
|
package/lib/endpoints/widget.cjs
CHANGED
|
@@ -52,10 +52,10 @@ __export(widget_exports, {
|
|
|
52
52
|
module.exports = __toCommonJS(widget_exports);
|
|
53
53
|
var import_fs = __toESM(require("fs"));
|
|
54
54
|
var import_shared = require("@vite-plugin-opencode-assistant/shared");
|
|
55
|
-
var
|
|
55
|
+
var import_node = require("@vite-plugin-opencode-assistant/shared/node");
|
|
56
56
|
function setupWidgetEndpoints(server, ctx) {
|
|
57
57
|
server.middlewares.use(import_shared.WIDGET_SCRIPT_PATH, (_req, res) => __async(null, null, function* () {
|
|
58
|
-
const reqCtx = new
|
|
58
|
+
const reqCtx = new import_node.RequestContext("GET", import_shared.WIDGET_SCRIPT_PATH);
|
|
59
59
|
const widgetPath = ctx.resolveWidgetPath();
|
|
60
60
|
if (import_fs.default.existsSync(widgetPath)) {
|
|
61
61
|
res.setHeader("Content-Type", "application/javascript");
|
|
@@ -69,7 +69,7 @@ function setupWidgetEndpoints(server, ctx) {
|
|
|
69
69
|
}
|
|
70
70
|
}));
|
|
71
71
|
server.middlewares.use(import_shared.WIDGET_STYLE_PATH, (_req, res) => __async(null, null, function* () {
|
|
72
|
-
const reqCtx = new
|
|
72
|
+
const reqCtx = new import_node.RequestContext("GET", import_shared.WIDGET_STYLE_PATH);
|
|
73
73
|
const stylePath = ctx.resolveWidgetStylePath();
|
|
74
74
|
if (import_fs.default.existsSync(stylePath)) {
|
|
75
75
|
res.setHeader("Content-Type", "text/css");
|
package/lib/index.cjs
CHANGED
|
@@ -67,6 +67,7 @@ module.exports = __toCommonJS(lib_exports);
|
|
|
67
67
|
var import_crypto = __toESM(require("crypto"));
|
|
68
68
|
var import_vite = __toESM(require("unplugin-vue-inspector/vite"));
|
|
69
69
|
var import_shared = require("@vite-plugin-opencode-assistant/shared");
|
|
70
|
+
var import_node = require("@vite-plugin-opencode-assistant/shared/node");
|
|
70
71
|
var import_endpoints = require("./endpoints/index.cjs");
|
|
71
72
|
var import_injector = require("./core/injector.cjs");
|
|
72
73
|
var import_api = require("./core/api.cjs");
|
|
@@ -88,8 +89,8 @@ function createOpenCodePlugin(options = {}) {
|
|
|
88
89
|
var _a;
|
|
89
90
|
const config = __spreadValues(__spreadValues({}, import_shared.DEFAULT_CONFIG), options);
|
|
90
91
|
(0, import_shared.setVerbose)(config.verbose);
|
|
91
|
-
(0,
|
|
92
|
-
const log = (0,
|
|
92
|
+
(0, import_node.initProcessLogCapture)({ maxSize: 500 });
|
|
93
|
+
const log = (0, import_node.createLogger)("Plugin");
|
|
93
94
|
let actualWebPort = config.webPort;
|
|
94
95
|
let actualProxyPort = (_a = config.proxyPort) != null ? _a : import_shared.DEFAULT_PROXY_PORT;
|
|
95
96
|
let projectRoot = "";
|
package/lib/utils/system.cjs
CHANGED
|
@@ -62,10 +62,10 @@ var import_http = __toESM(require("http"));
|
|
|
62
62
|
var import_net = __toESM(require("net"));
|
|
63
63
|
var import_path = __toESM(require("path"));
|
|
64
64
|
var import_shared = require("@vite-plugin-opencode-assistant/shared");
|
|
65
|
-
var
|
|
66
|
-
const log = (0,
|
|
65
|
+
var import_node = require("@vite-plugin-opencode-assistant/shared/node");
|
|
66
|
+
const log = (0, import_node.createLogger)("Utils");
|
|
67
67
|
function waitForServer(url, timeout = 1e4, process2) {
|
|
68
|
-
const timer = new
|
|
68
|
+
const timer = new import_node.PerformanceTimer("waitForServer", { url, timeout });
|
|
69
69
|
return new Promise((resolve, reject) => {
|
|
70
70
|
const startTime = Date.now();
|
|
71
71
|
let attempts = 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-opencode-assistant",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Embed OpenCode Web UI in your Vite dev server for real-time code modification and preview",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.cjs",
|
|
@@ -37,15 +37,15 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"unplugin-vue-inspector": "^3.0.0",
|
|
39
39
|
"execa": "^9.6.1",
|
|
40
|
-
"@vite-plugin-opencode-assistant/opencode": "1.1.
|
|
41
|
-
"@vite-plugin-opencode-assistant/shared": "1.1.
|
|
42
|
-
"@vite-plugin-opencode-assistant/components": "1.1.
|
|
40
|
+
"@vite-plugin-opencode-assistant/opencode": "1.1.1",
|
|
41
|
+
"@vite-plugin-opencode-assistant/shared": "1.1.1",
|
|
42
|
+
"@vite-plugin-opencode-assistant/components": "1.1.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vite": ">=5.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@vite-plugin-opencode-assistant/client": "1.1.
|
|
48
|
+
"@vite-plugin-opencode-assistant/client": "1.1.1"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "pagoda-cli build && vite build -c vite.client.config.ts",
|