vite-plugin-opencode-assistant 1.0.26 → 1.0.28
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/client/App.vue.js +64 -36
- package/es/client/composables/index.d.ts +10 -0
- package/es/client/composables/index.js +22 -0
- package/es/client/composables/useOpencodeSSE.d.ts +64 -0
- package/es/client/composables/useOpencodeSSE.js +29 -0
- package/es/client/composables/useOpencodeSessionSSE.d.ts +66 -0
- package/es/client/composables/useOpencodeSessionSSE.js +168 -0
- package/es/client/composables/useSSE.d.ts +85 -18
- package/es/client/composables/useSSE.js +101 -44
- package/es/client/composables/useServerSSE.d.ts +53 -0
- package/es/client/composables/useServerSSE.js +36 -0
- package/es/client/composables/useServiceStatus.d.ts +0 -2
- package/es/client/composables/useServiceStatus.js +1 -7
- package/es/client/composables/useSessions.d.ts +24 -5
- package/es/client/composables/useSessions.js +16 -2
- package/es/core/proxy-server.js +61 -148
- package/es/index.js +3 -1
- package/lib/client/App.vue.js +63 -35
- package/lib/client/composables/index.d.ts +10 -0
- package/lib/client/composables/index.js +54 -0
- package/lib/client/composables/useOpencodeSSE.d.ts +64 -0
- package/lib/client/composables/useOpencodeSSE.js +52 -0
- package/lib/client/composables/useOpencodeSessionSSE.d.ts +66 -0
- package/lib/client/composables/useOpencodeSessionSSE.js +187 -0
- package/lib/client/composables/useSSE.d.ts +85 -18
- package/lib/client/composables/useSSE.js +100 -43
- package/lib/client/composables/useServerSSE.d.ts +53 -0
- package/lib/client/composables/useServerSSE.js +59 -0
- package/lib/client/composables/useServiceStatus.d.ts +0 -2
- package/lib/client/composables/useServiceStatus.js +1 -7
- package/lib/client/composables/useSessions.d.ts +24 -5
- package/lib/client/composables/useSessions.js +16 -2
- package/lib/client.js +3722 -3390
- package/lib/core/proxy-server.js +61 -148
- package/lib/index.js +3 -1
- package/lib/style.css +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var useServerSSE_exports = {};
|
|
19
|
+
__export(useServerSSE_exports, {
|
|
20
|
+
useServerSSE: () => useServerSSE
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(useServerSSE_exports);
|
|
23
|
+
var import_useSSE = require("./useSSE");
|
|
24
|
+
function useServerSSE(options = {}) {
|
|
25
|
+
const { onStatusSync, onTaskUpdate, onClearElements, onConnected } = options;
|
|
26
|
+
const { status, isConnected, connect, disconnect } = (0, import_useSSE.useSSE)({
|
|
27
|
+
endpoint: "/__opencode_events__",
|
|
28
|
+
autoConnect: false,
|
|
29
|
+
onMessage: (data) => {
|
|
30
|
+
const message = data;
|
|
31
|
+
switch (message.type) {
|
|
32
|
+
case "CONNECTED":
|
|
33
|
+
onConnected == null ? void 0 : onConnected();
|
|
34
|
+
break;
|
|
35
|
+
case "STATUS_SYNC":
|
|
36
|
+
onStatusSync == null ? void 0 : onStatusSync(message);
|
|
37
|
+
break;
|
|
38
|
+
case "TASK_UPDATE":
|
|
39
|
+
onTaskUpdate == null ? void 0 : onTaskUpdate(message);
|
|
40
|
+
break;
|
|
41
|
+
case "CLEAR_ELEMENTS":
|
|
42
|
+
onClearElements == null ? void 0 : onClearElements();
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
// 状态
|
|
49
|
+
status,
|
|
50
|
+
isConnected,
|
|
51
|
+
// 方法
|
|
52
|
+
connect,
|
|
53
|
+
disconnect
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
useServerSSE
|
|
59
|
+
});
|
|
@@ -5,9 +5,7 @@ export declare function useServiceStatus(): {
|
|
|
5
5
|
chromeMcpFailed: import("vue").Ref<boolean, boolean>;
|
|
6
6
|
chromeMcpErrorType: import("vue").Ref<string | undefined, string | undefined>;
|
|
7
7
|
chromeMcpErrorMessage: import("vue").Ref<string | undefined, string | undefined>;
|
|
8
|
-
thinking: import("vue").Ref<boolean, boolean>;
|
|
9
8
|
loadingText: import("vue").ComputedRef<string>;
|
|
10
9
|
updateStatusFromTask: (task: ServiceStartupTask | "", errorType?: string, errorMessage?: string) => void;
|
|
11
10
|
setStarting: () => void;
|
|
12
|
-
setThinking: (value: boolean) => void;
|
|
13
11
|
};
|
|
@@ -28,7 +28,6 @@ function useServiceStatus() {
|
|
|
28
28
|
const chromeMcpFailed = (0, import_vue.ref)(false);
|
|
29
29
|
const chromeMcpErrorType = (0, import_vue.ref)(void 0);
|
|
30
30
|
const chromeMcpErrorMessage = (0, import_vue.ref)(void 0);
|
|
31
|
-
const thinking = (0, import_vue.ref)(false);
|
|
32
31
|
const loadingText = (0, import_vue.computed)(() => {
|
|
33
32
|
if (!currentTask.value) return "\u52A0\u8F7D\u4E2D...";
|
|
34
33
|
return import_shared.SERVICE_STARTUP_TASKS[currentTask.value] || "\u52A0\u8F7D\u4E2D...";
|
|
@@ -54,20 +53,15 @@ function useServiceStatus() {
|
|
|
54
53
|
const setStarting = () => {
|
|
55
54
|
serviceStatus.value = "starting";
|
|
56
55
|
};
|
|
57
|
-
const setThinking = (value) => {
|
|
58
|
-
thinking.value = value;
|
|
59
|
-
};
|
|
60
56
|
return {
|
|
61
57
|
currentTask,
|
|
62
58
|
serviceStatus,
|
|
63
59
|
chromeMcpFailed,
|
|
64
60
|
chromeMcpErrorType,
|
|
65
61
|
chromeMcpErrorMessage,
|
|
66
|
-
thinking,
|
|
67
62
|
loadingText,
|
|
68
63
|
updateStatusFromTask,
|
|
69
|
-
setStarting
|
|
70
|
-
setThinking
|
|
64
|
+
setStarting
|
|
71
65
|
};
|
|
72
66
|
}
|
|
73
67
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
+
import { type Ref } from "vue";
|
|
1
2
|
import type { OpenCodeWidgetSession } from "@vite-plugin-opencode-assistant/shared";
|
|
2
|
-
export
|
|
3
|
-
|
|
3
|
+
export interface UseSessionsOptions {
|
|
4
|
+
showNotification: (msg: string) => void;
|
|
5
|
+
/** Session 更新回调 (从 SSE 事件接收) */
|
|
6
|
+
onSessionUpdate?: Ref<((session: {
|
|
7
|
+
id: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
time?: {
|
|
10
|
+
updated?: number;
|
|
11
|
+
};
|
|
12
|
+
}) => void) | undefined>;
|
|
13
|
+
}
|
|
14
|
+
export declare function useSessions(options: UseSessionsOptions): {
|
|
15
|
+
sessions: Ref<{
|
|
4
16
|
id: string;
|
|
5
17
|
title?: string | undefined;
|
|
6
18
|
updatedAt?: (string | number | Date) | undefined;
|
|
@@ -15,12 +27,19 @@ export declare function useSessions(showNotification: (msg: string) => void): {
|
|
|
15
27
|
directory?: string | undefined;
|
|
16
28
|
url?: string | undefined;
|
|
17
29
|
}[]>;
|
|
18
|
-
loadingSessionList:
|
|
19
|
-
currentSessionId:
|
|
30
|
+
loadingSessionList: Ref<boolean | undefined, boolean | undefined>;
|
|
31
|
+
currentSessionId: Ref<string | null, string | null>;
|
|
20
32
|
iframeSrc: import("vue").ComputedRef<string>;
|
|
21
|
-
iframeLoading:
|
|
33
|
+
iframeLoading: Ref<boolean, boolean>;
|
|
22
34
|
loadSessions: () => Promise<void>;
|
|
23
35
|
createSession: () => Promise<void>;
|
|
24
36
|
deleteSession: (session: OpenCodeWidgetSession) => Promise<void>;
|
|
25
37
|
selectSession: (session: OpenCodeWidgetSession) => void;
|
|
38
|
+
updateSessionInfo: (sessionUpdate: {
|
|
39
|
+
id: string;
|
|
40
|
+
title?: string;
|
|
41
|
+
time?: {
|
|
42
|
+
updated?: number;
|
|
43
|
+
};
|
|
44
|
+
}) => void;
|
|
26
45
|
};
|
|
@@ -59,7 +59,8 @@ __export(useSessions_exports, {
|
|
|
59
59
|
module.exports = __toCommonJS(useSessions_exports);
|
|
60
60
|
var import_vue = require("vue");
|
|
61
61
|
var import_shared = require("@vite-plugin-opencode-assistant/shared");
|
|
62
|
-
function useSessions(
|
|
62
|
+
function useSessions(options) {
|
|
63
|
+
const { showNotification } = options;
|
|
63
64
|
const sessions = (0, import_vue.ref)([]);
|
|
64
65
|
const loadingSessionList = (0, import_vue.ref)(void 0);
|
|
65
66
|
const currentSessionId = (0, import_vue.ref)(null);
|
|
@@ -90,6 +91,18 @@ function useSessions(showNotification) {
|
|
|
90
91
|
loadingSessionList.value = false;
|
|
91
92
|
}
|
|
92
93
|
});
|
|
94
|
+
const updateSessionInfo = (sessionUpdate) => {
|
|
95
|
+
var _a;
|
|
96
|
+
const index = sessions.value.findIndex((s) => s.id === sessionUpdate.id);
|
|
97
|
+
if (index === -1) return;
|
|
98
|
+
const session = sessions.value[index];
|
|
99
|
+
if (sessionUpdate.title && sessionUpdate.title !== session.title) {
|
|
100
|
+
sessions.value[index] = __spreadProps(__spreadValues({}, session), {
|
|
101
|
+
title: sessionUpdate.title,
|
|
102
|
+
updatedAt: ((_a = sessionUpdate.time) == null ? void 0 : _a.updated) || Date.now()
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
};
|
|
93
106
|
const createSession = () => __async(null, null, function* () {
|
|
94
107
|
try {
|
|
95
108
|
const response = yield fetch(import_shared.SESSIONS_API_PATH, { method: "POST" });
|
|
@@ -139,7 +152,8 @@ function useSessions(showNotification) {
|
|
|
139
152
|
loadSessions,
|
|
140
153
|
createSession,
|
|
141
154
|
deleteSession,
|
|
142
|
-
selectSession
|
|
155
|
+
selectSession,
|
|
156
|
+
updateSessionInfo
|
|
143
157
|
};
|
|
144
158
|
}
|
|
145
159
|
// Annotate the CommonJS export names for ESM import in node:
|