vite-plugin-opencode-assistant 1.0.74 → 1.0.75
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/injector.mjs +6 -2
- package/es/core/proxy-server.mjs +19 -13
- package/es/endpoints/index.d.ts +1 -1
- package/es/endpoints/index.mjs +3 -2
- package/es/endpoints/logs.d.ts +0 -2
- package/es/endpoints/logs.mjs +4 -4
- package/es/endpoints/start.d.ts +2 -1
- package/es/endpoints/start.mjs +6 -2
- package/es/endpoints/types.d.ts +2 -0
- package/es/endpoints/warmup.mjs +2 -2
- package/es/endpoints/widget.mjs +1 -2
- package/es/env.d.ts +1 -0
- package/es/index.mjs +7 -1
- package/lib/client.js +3481 -3287
- package/lib/core/injector.cjs +1 -1
- package/lib/core/proxy-server.cjs +16 -12
- package/lib/endpoints/index.cjs +3 -2
- package/lib/endpoints/index.d.ts +1 -1
- package/lib/endpoints/logs.cjs +2 -5
- package/lib/endpoints/logs.d.ts +0 -2
- package/lib/endpoints/start.cjs +6 -2
- package/lib/endpoints/start.d.ts +2 -1
- package/lib/endpoints/types.d.ts +2 -0
- package/lib/endpoints/warmup.cjs +1 -1
- package/lib/endpoints/widget.cjs +2 -3
- package/lib/env.d.ts +1 -0
- package/lib/index.cjs +7 -1
- package/lib/style.css +1 -1
- package/package.json +8 -4
- package/es/client/App.vue.d.ts +0 -6
- package/es/client/App.vue.mjs +0 -394
- package/es/client/components/ChromeWarmupError-sfc.css +0 -1
- package/es/client/components/ChromeWarmupError.vue.d.ts +0 -19
- package/es/client/components/ChromeWarmupError.vue.mjs +0 -337
- package/es/client/components/LoadingContent.vue.d.ts +0 -5
- package/es/client/components/LoadingContent.vue.mjs +0 -39
- package/es/client/composables/index.d.ts +0 -10
- package/es/client/composables/index.mjs +0 -22
- package/es/client/composables/useContext.d.ts +0 -8
- package/es/client/composables/useContext.mjs +0 -63
- package/es/client/composables/useHotkey.d.ts +0 -12
- package/es/client/composables/useHotkey.mjs +0 -41
- package/es/client/composables/useOpencodeSSE.d.ts +0 -64
- package/es/client/composables/useOpencodeSSE.mjs +0 -29
- package/es/client/composables/useOpencodeSessionSSE.d.ts +0 -66
- package/es/client/composables/useOpencodeSessionSSE.mjs +0 -168
- package/es/client/composables/useSSE.d.ts +0 -87
- package/es/client/composables/useSSE.mjs +0 -118
- package/es/client/composables/useSelectedElements.d.ts +0 -19
- package/es/client/composables/useSelectedElements.mjs +0 -43
- package/es/client/composables/useServerSSE.d.ts +0 -53
- package/es/client/composables/useServerSSE.mjs +0 -36
- package/es/client/composables/useServiceStatus.d.ts +0 -11
- package/es/client/composables/useServiceStatus.mjs +0 -47
- package/es/client/composables/useSessions.d.ts +0 -45
- package/es/client/composables/useSessions.mjs +0 -147
- package/es/client/composables/useTheme.d.ts +0 -12
- package/es/client/composables/useTheme.mjs +0 -42
- package/es/client/index.d.ts +0 -1
- package/es/client/index.mjs +0 -32
- package/es/client/styles.css +0 -1
- package/lib/client/App.vue.cjs +0 -421
- package/lib/client/App.vue.d.ts +0 -6
- package/lib/client/components/ChromeWarmupError-sfc.css +0 -1
- package/lib/client/components/ChromeWarmupError.vue.cjs +0 -356
- package/lib/client/components/ChromeWarmupError.vue.d.ts +0 -19
- package/lib/client/components/LoadingContent.vue.cjs +0 -58
- package/lib/client/components/LoadingContent.vue.d.ts +0 -5
- package/lib/client/composables/index.cjs +0 -54
- package/lib/client/composables/index.d.ts +0 -10
- package/lib/client/composables/useContext.cjs +0 -86
- package/lib/client/composables/useContext.d.ts +0 -8
- package/lib/client/composables/useHotkey.cjs +0 -66
- package/lib/client/composables/useHotkey.d.ts +0 -12
- package/lib/client/composables/useOpencodeSSE.cjs +0 -52
- package/lib/client/composables/useOpencodeSSE.d.ts +0 -64
- package/lib/client/composables/useOpencodeSessionSSE.cjs +0 -187
- package/lib/client/composables/useOpencodeSessionSSE.d.ts +0 -66
- package/lib/client/composables/useSSE.cjs +0 -141
- package/lib/client/composables/useSSE.d.ts +0 -87
- package/lib/client/composables/useSelectedElements.cjs +0 -66
- package/lib/client/composables/useSelectedElements.d.ts +0 -19
- package/lib/client/composables/useServerSSE.cjs +0 -59
- package/lib/client/composables/useServerSSE.d.ts +0 -53
- package/lib/client/composables/useServiceStatus.cjs +0 -70
- package/lib/client/composables/useServiceStatus.d.ts +0 -11
- package/lib/client/composables/useSessions.cjs +0 -168
- package/lib/client/composables/useSessions.d.ts +0 -45
- package/lib/client/composables/useTheme.cjs +0 -65
- package/lib/client/composables/useTheme.d.ts +0 -12
- package/lib/client/index.cjs +0 -54
- package/lib/client/index.d.ts +0 -1
- package/lib/client/styles.css +0 -1
package/es/core/injector.mjs
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CONFIG_DATA_ATTR,
|
|
3
|
+
WIDGET_SCRIPT_PATH,
|
|
4
|
+
WIDGET_STYLE_PATH
|
|
5
|
+
} from "@vite-plugin-opencode-assistant/shared";
|
|
2
6
|
function injectWidget(options) {
|
|
3
7
|
const configBase64 = Buffer.from(JSON.stringify(options)).toString("base64");
|
|
4
8
|
const scriptTag = `<script type="module" src="${WIDGET_SCRIPT_PATH}" ${CONFIG_DATA_ATTR}="${configBase64}"></script>`;
|
|
5
|
-
const styleTag = `<link rel="stylesheet" href="
|
|
9
|
+
const styleTag = `<link rel="stylesheet" href="${WIDGET_STYLE_PATH}" />`;
|
|
6
10
|
return `${styleTag}
|
|
7
11
|
${scriptTag}`;
|
|
8
12
|
}
|
package/es/core/proxy-server.mjs
CHANGED
|
@@ -21,7 +21,9 @@ import http from "http";
|
|
|
21
21
|
import {
|
|
22
22
|
createLogger,
|
|
23
23
|
DEFAULT_OPENCODE_SETTINGS,
|
|
24
|
-
OPENCODE_STORAGE_KEYS
|
|
24
|
+
OPENCODE_STORAGE_KEYS,
|
|
25
|
+
WIDGET_MSG,
|
|
26
|
+
BRIDGE_SCRIPT_PATH
|
|
25
27
|
} from "@vite-plugin-opencode-assistant/shared";
|
|
26
28
|
const log = createLogger("ProxyServer");
|
|
27
29
|
function mergeSettings(defaultSettings, userSettings) {
|
|
@@ -106,23 +108,23 @@ function generateBridgeScript(options) {
|
|
|
106
108
|
|
|
107
109
|
// === \u6D88\u606F\u76D1\u542C ===
|
|
108
110
|
window.addEventListener("message", function(event) {
|
|
109
|
-
if (event.data && event.data.type ===
|
|
111
|
+
if (event.data && event.data.type === ${JSON.stringify(WIDGET_MSG.SET_THEME)}) {
|
|
110
112
|
setTheme(event.data.theme);
|
|
111
113
|
}
|
|
112
114
|
|
|
113
|
-
if (event.data && event.data.type ===
|
|
115
|
+
if (event.data && event.data.type === ${JSON.stringify(WIDGET_MSG.INSERT_FILE_PART)}) {
|
|
114
116
|
insertFilePart(event.data.element);
|
|
115
117
|
}
|
|
116
118
|
|
|
117
|
-
if (event.data && event.data.type ===
|
|
119
|
+
if (event.data && event.data.type === ${JSON.stringify(WIDGET_MSG.MINIMIZE_STATE)}) {
|
|
118
120
|
handleMinimizeStateChange(event.data.minimized);
|
|
119
121
|
}
|
|
120
122
|
|
|
121
|
-
if (event.data && event.data.type ===
|
|
123
|
+
if (event.data && event.data.type === ${JSON.stringify(WIDGET_MSG.PROMPT_DOCK_VISIBILITY)}) {
|
|
122
124
|
handlePromptDockVisibilityChange(event.data.visible);
|
|
123
125
|
}
|
|
124
126
|
|
|
125
|
-
if (event.data && event.data.type ===
|
|
127
|
+
if (event.data && event.data.type === ${JSON.stringify(WIDGET_MSG.SELECT_MODE_CHANGE)}) {
|
|
126
128
|
handleSelectModeChange(event.data.selectMode);
|
|
127
129
|
}
|
|
128
130
|
});
|
|
@@ -136,7 +138,7 @@ function generateBridgeScript(options) {
|
|
|
136
138
|
event.stopPropagation();
|
|
137
139
|
if (window.parent !== window) {
|
|
138
140
|
window.parent.postMessage({
|
|
139
|
-
type:
|
|
141
|
+
type: ${JSON.stringify(WIDGET_MSG.KEYDOWN)},
|
|
140
142
|
key: event.key,
|
|
141
143
|
ctrlKey: event.ctrlKey,
|
|
142
144
|
metaKey: event.metaKey,
|
|
@@ -147,9 +149,10 @@ function generateBridgeScript(options) {
|
|
|
147
149
|
return;
|
|
148
150
|
}
|
|
149
151
|
|
|
152
|
+
|
|
150
153
|
if (window.parent !== window) {
|
|
151
154
|
window.parent.postMessage({
|
|
152
|
-
type:
|
|
155
|
+
type: ${JSON.stringify(WIDGET_MSG.KEYDOWN)},
|
|
153
156
|
key: event.key,
|
|
154
157
|
ctrlKey: event.ctrlKey,
|
|
155
158
|
metaKey: event.metaKey,
|
|
@@ -162,6 +165,9 @@ function generateBridgeScript(options) {
|
|
|
162
165
|
|
|
163
166
|
// === \u6700\u5C0F\u5316\u72B6\u6001\u6837\u5F0F ===
|
|
164
167
|
const minimizeStyles = \`
|
|
168
|
+
#root header {
|
|
169
|
+
display: none !important;
|
|
170
|
+
}
|
|
165
171
|
.opencode-minimized [data-dock-surface="tray"]:not([data-slot="permission-footer"]) {
|
|
166
172
|
display: none !important;
|
|
167
173
|
}
|
|
@@ -361,7 +367,7 @@ function generateBridgeScript(options) {
|
|
|
361
367
|
function init() {
|
|
362
368
|
injectMinimizeStyles();
|
|
363
369
|
if (window.parent !== window) {
|
|
364
|
-
window.parent.postMessage({ type:
|
|
370
|
+
window.parent.postMessage({ type: ${JSON.stringify(WIDGET_MSG.READY)} }, "*");
|
|
365
371
|
}
|
|
366
372
|
setupPromptInputListener();
|
|
367
373
|
applySavedStates();
|
|
@@ -396,7 +402,7 @@ function startProxyServer(targetUrl, port, options = {}) {
|
|
|
396
402
|
const target = new URL(targetUrl);
|
|
397
403
|
const bridgeScript = generateBridgeScript(options);
|
|
398
404
|
const server = http.createServer((req, res) => {
|
|
399
|
-
if (req.url ===
|
|
405
|
+
if (req.url === BRIDGE_SCRIPT_PATH) {
|
|
400
406
|
const body = bridgeScript;
|
|
401
407
|
res.writeHead(200, {
|
|
402
408
|
"content-type": "application/javascript; charset=utf-8",
|
|
@@ -431,15 +437,15 @@ function startProxyServer(targetUrl, port, options = {}) {
|
|
|
431
437
|
if (body.match(/<\/head>/i)) {
|
|
432
438
|
body = body.replace(
|
|
433
439
|
/<\/head>/i,
|
|
434
|
-
|
|
440
|
+
`<script src="${BRIDGE_SCRIPT_PATH}"></script></head>`
|
|
435
441
|
);
|
|
436
442
|
} else if (body.match(/<\/body>/i)) {
|
|
437
443
|
body = body.replace(
|
|
438
444
|
/<\/body>/i,
|
|
439
|
-
|
|
445
|
+
`<script src="${BRIDGE_SCRIPT_PATH}"></script></body>`
|
|
440
446
|
);
|
|
441
447
|
} else {
|
|
442
|
-
body +=
|
|
448
|
+
body += `<script src="${BRIDGE_SCRIPT_PATH}"></script>`;
|
|
443
449
|
}
|
|
444
450
|
const headers = {};
|
|
445
451
|
for (const [key, value] of Object.entries(proxyRes.headers)) {
|
package/es/endpoints/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ViteDevServer } from "vite";
|
|
2
2
|
import type { EndpointContext } from "./types";
|
|
3
|
-
import { LOGS_API_PATH } from "
|
|
3
|
+
import { LOGS_API_PATH } from "@vite-plugin-opencode-assistant/shared";
|
|
4
4
|
export * from "./types";
|
|
5
5
|
export { LOGS_API_PATH };
|
|
6
6
|
export declare function setupMiddlewares(server: ViteDevServer, ctx: EndpointContext): void;
|
package/es/endpoints/index.mjs
CHANGED
|
@@ -4,12 +4,13 @@ import { setupStartEndpoint } from "./start.mjs";
|
|
|
4
4
|
import { setupSseEndpoint } from "./sse.mjs";
|
|
5
5
|
import { setupSessionsEndpoint } from "./sessions.mjs";
|
|
6
6
|
import { setupWarmupEndpoint } from "./warmup.mjs";
|
|
7
|
-
import { setupLogsEndpoint
|
|
7
|
+
import { setupLogsEndpoint } from "./logs.mjs";
|
|
8
|
+
import { LOGS_API_PATH } from "@vite-plugin-opencode-assistant/shared";
|
|
8
9
|
export * from "./types.mjs";
|
|
9
10
|
function setupMiddlewares(server, ctx) {
|
|
10
11
|
setupWidgetEndpoints(server, ctx);
|
|
11
12
|
setupContextEndpoint(server, ctx);
|
|
12
|
-
setupStartEndpoint(server);
|
|
13
|
+
setupStartEndpoint(server, ctx);
|
|
13
14
|
setupSseEndpoint(server, ctx);
|
|
14
15
|
setupSessionsEndpoint(server, ctx);
|
|
15
16
|
setupWarmupEndpoint(server, ctx);
|
package/es/endpoints/logs.d.ts
CHANGED
package/es/endpoints/logs.mjs
CHANGED
|
@@ -18,12 +18,13 @@ var __async = (__this, __arguments, generator) => {
|
|
|
18
18
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
|
+
import { getProcessLogBuffer } from "@vite-plugin-opencode-assistant/shared";
|
|
21
22
|
import {
|
|
22
|
-
|
|
23
|
+
RequestContext,
|
|
24
|
+
createLogger,
|
|
25
|
+
LOGS_API_PATH
|
|
23
26
|
} from "@vite-plugin-opencode-assistant/shared";
|
|
24
|
-
import { RequestContext, createLogger } from "@vite-plugin-opencode-assistant/shared";
|
|
25
27
|
const log = createLogger("Endpoints:Logs");
|
|
26
|
-
const LOGS_API_PATH = "/__opencode_process_logs__";
|
|
27
28
|
function setupLogsEndpoint(server) {
|
|
28
29
|
server.middlewares.use(LOGS_API_PATH, (req, res) => __async(null, null, function* () {
|
|
29
30
|
const reqCtx = new RequestContext(req.method || "GET", LOGS_API_PATH);
|
|
@@ -102,6 +103,5 @@ function setupLogsEndpoint(server) {
|
|
|
102
103
|
}));
|
|
103
104
|
}
|
|
104
105
|
export {
|
|
105
|
-
LOGS_API_PATH,
|
|
106
106
|
setupLogsEndpoint
|
|
107
107
|
};
|
package/es/endpoints/start.d.ts
CHANGED
package/es/endpoints/start.mjs
CHANGED
|
@@ -20,13 +20,17 @@ var __async = (__this, __arguments, generator) => {
|
|
|
20
20
|
};
|
|
21
21
|
import { START_API_PATH } from "@vite-plugin-opencode-assistant/shared";
|
|
22
22
|
import { RequestContext } from "@vite-plugin-opencode-assistant/shared";
|
|
23
|
-
function setupStartEndpoint(server) {
|
|
23
|
+
function setupStartEndpoint(server, ctx) {
|
|
24
24
|
server.middlewares.use(START_API_PATH, (_req, res) => __async(null, null, function* () {
|
|
25
25
|
const reqCtx = new RequestContext("GET", START_API_PATH);
|
|
26
26
|
res.setHeader("Content-Type", "application/json");
|
|
27
27
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
28
28
|
res.writeHead(200);
|
|
29
|
-
res.end(JSON.stringify({
|
|
29
|
+
res.end(JSON.stringify({
|
|
30
|
+
success: true,
|
|
31
|
+
proxyPort: ctx.actualProxyPort,
|
|
32
|
+
webPort: ctx.actualWebPort
|
|
33
|
+
}));
|
|
30
34
|
reqCtx.end(200);
|
|
31
35
|
}));
|
|
32
36
|
}
|
package/es/endpoints/types.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export interface EndpointContext {
|
|
|
10
10
|
task: ServiceStartupTask;
|
|
11
11
|
data?: Record<string, unknown>;
|
|
12
12
|
} | null;
|
|
13
|
+
get actualProxyPort(): number;
|
|
14
|
+
get actualWebPort(): number;
|
|
13
15
|
getSessions: () => Promise<SessionInfo[]>;
|
|
14
16
|
createSession: () => Promise<SessionInfo>;
|
|
15
17
|
deleteSession: (id: string) => Promise<void>;
|
package/es/endpoints/warmup.mjs
CHANGED
|
@@ -20,10 +20,10 @@ var __async = (__this, __arguments, generator) => {
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")]) ? it.call(obj) : (obj = obj[__knownSymbol("iterator")](), it = {}, method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((yes, no, done) => (arg = fn.call(obj, arg), done = arg.done, Promise.resolve(arg.value).then((value) => yes({ value, done }), no)))), method("next"), method("return"), it);
|
|
23
|
-
import { createLogger } from "@vite-plugin-opencode-assistant/shared";
|
|
23
|
+
import { createLogger, WARMUP_API_PATH } from "@vite-plugin-opencode-assistant/shared";
|
|
24
24
|
const log = createLogger("Endpoints:Warmup");
|
|
25
25
|
function setupWarmupEndpoint(server, ctx) {
|
|
26
|
-
server.middlewares.use(
|
|
26
|
+
server.middlewares.use(WARMUP_API_PATH, (req, res) => __async(null, null, function* () {
|
|
27
27
|
if (req.method === "GET") {
|
|
28
28
|
try {
|
|
29
29
|
const models = yield ctx.getAvailableModels();
|
package/es/endpoints/widget.mjs
CHANGED
|
@@ -19,7 +19,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
import fs from "fs";
|
|
22
|
-
import { WIDGET_SCRIPT_PATH } from "@vite-plugin-opencode-assistant/shared";
|
|
22
|
+
import { WIDGET_SCRIPT_PATH, WIDGET_STYLE_PATH } from "@vite-plugin-opencode-assistant/shared";
|
|
23
23
|
import { RequestContext } from "@vite-plugin-opencode-assistant/shared";
|
|
24
24
|
function setupWidgetEndpoints(server, ctx) {
|
|
25
25
|
server.middlewares.use(WIDGET_SCRIPT_PATH, (_req, res) => __async(null, null, function* () {
|
|
@@ -36,7 +36,6 @@ function setupWidgetEndpoints(server, ctx) {
|
|
|
36
36
|
reqCtx.end(404);
|
|
37
37
|
}
|
|
38
38
|
}));
|
|
39
|
-
const WIDGET_STYLE_PATH = "/__opencode_widget__.css";
|
|
40
39
|
server.middlewares.use(WIDGET_STYLE_PATH, (_req, res) => __async(null, null, function* () {
|
|
41
40
|
const reqCtx = new RequestContext("GET", WIDGET_STYLE_PATH);
|
|
42
41
|
const stylePath = ctx.resolveWidgetStylePath();
|
package/es/env.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="chrome" />
|
package/es/index.mjs
CHANGED
|
@@ -119,6 +119,12 @@ function createOpenCodePlugin(options = {}) {
|
|
|
119
119
|
get currentTask() {
|
|
120
120
|
return service.currentTask;
|
|
121
121
|
},
|
|
122
|
+
get actualProxyPort() {
|
|
123
|
+
return actualProxyPort;
|
|
124
|
+
},
|
|
125
|
+
get actualWebPort() {
|
|
126
|
+
return actualWebPort;
|
|
127
|
+
},
|
|
122
128
|
getSessions: () => api.getSessions(service.workspaceRoot),
|
|
123
129
|
createSession: () => api.createSession(service.workspaceRoot),
|
|
124
130
|
deleteSession: (id) => api.deleteSession(id),
|
|
@@ -184,7 +190,7 @@ function createOpenCodePlugin(options = {}) {
|
|
|
184
190
|
hotkey: config.hotkey,
|
|
185
191
|
proxyPort: actualProxyPort,
|
|
186
192
|
proxyHost: config.hostname,
|
|
187
|
-
displayMode: config.displayMode,
|
|
193
|
+
displayMode: config.displayMode === "extension" ? "extension-selector" : config.displayMode,
|
|
188
194
|
splitMode: config.splitMode
|
|
189
195
|
});
|
|
190
196
|
timer.end();
|