vite-plugin-opencode-assistant 1.0.14 → 1.0.16

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.
Files changed (81) hide show
  1. package/es/client/App.vue.d.ts +6 -0
  2. package/es/client/App.vue.js +300 -0
  3. package/es/client/components/ChromeWarmupError-sfc.css +1 -0
  4. package/es/client/components/ChromeWarmupError.vue.d.ts +11 -0
  5. package/es/client/components/ChromeWarmupError.vue.js +196 -0
  6. package/es/client/components/LoadingContent.vue.d.ts +5 -0
  7. package/es/client/components/LoadingContent.vue.js +39 -0
  8. package/es/client/composables/useContext.d.ts +8 -0
  9. package/es/client/composables/useContext.js +63 -0
  10. package/es/client/composables/useHotkey.d.ts +12 -0
  11. package/es/client/composables/useHotkey.js +41 -0
  12. package/es/client/composables/useSSE.d.ts +20 -0
  13. package/es/client/composables/useSSE.js +61 -0
  14. package/es/client/composables/useSelectedElements.d.ts +19 -0
  15. package/es/client/composables/useSelectedElements.js +43 -0
  16. package/es/client/composables/useServiceStatus.d.ts +13 -0
  17. package/es/client/composables/useServiceStatus.js +53 -0
  18. package/es/client/composables/useSessions.d.ts +26 -0
  19. package/es/client/composables/useSessions.js +127 -0
  20. package/es/client/composables/useTheme.d.ts +12 -0
  21. package/es/client/composables/useTheme.js +42 -0
  22. package/es/client/index.d.ts +1 -1
  23. package/es/client/index.js +5 -675
  24. package/es/client/styles.css +1 -0
  25. package/es/core/api.d.ts +18 -6
  26. package/es/core/api.js +324 -69
  27. package/es/core/proxy-server.d.ts +5 -1
  28. package/es/core/proxy-server.js +201 -70
  29. package/es/core/service.d.ts +9 -2
  30. package/es/core/service.js +80 -44
  31. package/es/endpoints/index.js +1 -1
  32. package/es/endpoints/sse.js +0 -3
  33. package/es/endpoints/start.d.ts +1 -2
  34. package/es/endpoints/start.js +2 -2
  35. package/es/endpoints/types.d.ts +5 -2
  36. package/es/endpoints/warmup.js +15 -3
  37. package/es/index.js +8 -12
  38. package/es/utils/system.d.ts +3 -1
  39. package/es/utils/system.js +39 -10
  40. package/lib/client/App.vue.d.ts +6 -0
  41. package/lib/client/App.vue.js +329 -0
  42. package/lib/client/components/ChromeWarmupError-sfc.css +1 -0
  43. package/lib/client/components/ChromeWarmupError.vue.d.ts +11 -0
  44. package/lib/client/components/ChromeWarmupError.vue.js +215 -0
  45. package/lib/client/components/LoadingContent.vue.d.ts +5 -0
  46. package/lib/client/components/LoadingContent.vue.js +58 -0
  47. package/lib/client/composables/useContext.d.ts +8 -0
  48. package/lib/client/composables/useContext.js +86 -0
  49. package/lib/client/composables/useHotkey.d.ts +12 -0
  50. package/lib/client/composables/useHotkey.js +66 -0
  51. package/lib/client/composables/useSSE.d.ts +20 -0
  52. package/lib/client/composables/useSSE.js +84 -0
  53. package/lib/client/composables/useSelectedElements.d.ts +19 -0
  54. package/lib/client/composables/useSelectedElements.js +66 -0
  55. package/lib/client/composables/useServiceStatus.d.ts +13 -0
  56. package/lib/client/composables/useServiceStatus.js +76 -0
  57. package/lib/client/composables/useSessions.d.ts +26 -0
  58. package/lib/client/composables/useSessions.js +148 -0
  59. package/lib/client/composables/useTheme.d.ts +12 -0
  60. package/lib/client/composables/useTheme.js +65 -0
  61. package/lib/client/index.d.ts +1 -1
  62. package/lib/client/index.js +22 -667
  63. package/lib/client/styles.css +1 -0
  64. package/lib/client.js +2988 -2973
  65. package/lib/core/api.d.ts +18 -6
  66. package/lib/core/api.js +321 -74
  67. package/lib/core/proxy-server.d.ts +5 -1
  68. package/lib/core/proxy-server.js +201 -70
  69. package/lib/core/service.d.ts +9 -2
  70. package/lib/core/service.js +76 -43
  71. package/lib/endpoints/index.js +1 -1
  72. package/lib/endpoints/sse.js +0 -3
  73. package/lib/endpoints/start.d.ts +1 -2
  74. package/lib/endpoints/start.js +2 -2
  75. package/lib/endpoints/types.d.ts +5 -2
  76. package/lib/endpoints/warmup.js +15 -3
  77. package/lib/index.js +8 -12
  78. package/lib/style.css +1 -1
  79. package/lib/utils/system.d.ts +3 -1
  80. package/lib/utils/system.js +39 -5
  81. package/package.json +4 -4
@@ -0,0 +1,58 @@
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 LoadingContent_vue_exports = {};
19
+ __export(LoadingContent_vue_exports, {
20
+ default: () => LoadingContent_vue_default
21
+ });
22
+ module.exports = __toCommonJS(LoadingContent_vue_exports);
23
+ var import_vue = require("vue");
24
+ var import_vue2 = require("vue");
25
+ const __vue_sfc__ = /* @__PURE__ */ (0, import_vue.defineComponent)({
26
+ __name: "LoadingContent",
27
+ props: {
28
+ loadingText: { type: String, required: true }
29
+ },
30
+ setup(__props, { expose: __expose }) {
31
+ __expose();
32
+ const __returned__ = {};
33
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
34
+ return __returned__;
35
+ }
36
+ });
37
+ const _hoisted_1 = { class: "opencode-custom-loading" };
38
+ const _hoisted_2 = { class: "opencode-loading-text" };
39
+ function __vue_render__(_ctx, _cache, $props, $setup, $data, $options) {
40
+ return (0, import_vue2.openBlock)(), (0, import_vue2.createElementBlock)("div", _hoisted_1, [
41
+ _cache[0] || (_cache[0] = (0, import_vue2.createElementVNode)(
42
+ "div",
43
+ { class: "opencode-loading-spinner" },
44
+ null,
45
+ -1
46
+ /* CACHED */
47
+ )),
48
+ (0, import_vue2.createElementVNode)(
49
+ "div",
50
+ _hoisted_2,
51
+ (0, import_vue2.toDisplayString)($props.loadingText),
52
+ 1
53
+ /* TEXT */
54
+ )
55
+ ]);
56
+ }
57
+ __vue_sfc__.render = __vue_render__;
58
+ var LoadingContent_vue_default = __vue_sfc__;
@@ -0,0 +1,8 @@
1
+ import type { OpenCodeSelectedElement, ServiceStatus } from "@vite-plugin-opencode-assistant/shared";
2
+ export declare function useContext(serviceStatus: {
3
+ value: ServiceStatus;
4
+ }, selectedElements: {
5
+ value: OpenCodeSelectedElement[];
6
+ }): {
7
+ updateContext: (force?: boolean) => void;
8
+ };
@@ -0,0 +1,86 @@
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 useContext_exports = {};
19
+ __export(useContext_exports, {
20
+ useContext: () => useContext
21
+ });
22
+ module.exports = __toCommonJS(useContext_exports);
23
+ var import_vue = require("vue");
24
+ function useContext(serviceStatus, selectedElements) {
25
+ let currentPageUrl = "";
26
+ let currentPageTitle = "";
27
+ const updateContext = (force = false) => {
28
+ if (serviceStatus.value === "idle") return;
29
+ const newUrl = window.location.href;
30
+ const newTitle = document.title;
31
+ if (force || newUrl !== currentPageUrl || newTitle !== currentPageTitle) {
32
+ currentPageUrl = newUrl;
33
+ currentPageTitle = newTitle;
34
+ fetch("/__opencode_context__", {
35
+ method: "POST",
36
+ headers: { "Content-Type": "application/json" },
37
+ body: JSON.stringify({
38
+ url: newUrl,
39
+ title: newTitle,
40
+ selectedElements: selectedElements.value
41
+ })
42
+ }).catch(() => {
43
+ });
44
+ }
45
+ };
46
+ const scheduleContextUpdate = () => {
47
+ requestAnimationFrame(() => updateContext());
48
+ };
49
+ let titleObserver = null;
50
+ const originalPushState = history.pushState;
51
+ const originalReplaceState = history.replaceState;
52
+ (0, import_vue.onMounted)(() => {
53
+ history.pushState = function(...args) {
54
+ originalPushState.apply(this, args);
55
+ scheduleContextUpdate();
56
+ };
57
+ history.replaceState = function(...args) {
58
+ originalReplaceState.apply(this, args);
59
+ scheduleContextUpdate();
60
+ };
61
+ window.addEventListener("popstate", scheduleContextUpdate);
62
+ window.addEventListener("hashchange", scheduleContextUpdate);
63
+ titleObserver = new MutationObserver(() => {
64
+ if (document.title !== currentPageTitle) updateContext();
65
+ });
66
+ if (document.head) {
67
+ titleObserver.observe(document.head, { childList: true, subtree: true });
68
+ }
69
+ });
70
+ (0, import_vue.onUnmounted)(() => {
71
+ history.pushState = originalPushState;
72
+ history.replaceState = originalReplaceState;
73
+ window.removeEventListener("popstate", scheduleContextUpdate);
74
+ window.removeEventListener("hashchange", scheduleContextUpdate);
75
+ if (titleObserver) {
76
+ titleObserver.disconnect();
77
+ }
78
+ });
79
+ return {
80
+ updateContext
81
+ };
82
+ }
83
+ // Annotate the CommonJS export names for ESM import in node:
84
+ 0 && (module.exports = {
85
+ useContext
86
+ });
@@ -0,0 +1,12 @@
1
+ interface HotkeyConfig {
2
+ ctrl: boolean;
3
+ shift: boolean;
4
+ alt: boolean;
5
+ key: string;
6
+ }
7
+ export declare function parseHotkey(hotkeyStr: string): HotkeyConfig;
8
+ export declare function matchHotkey(e: KeyboardEvent, hotkeyConfig: HotkeyConfig): boolean;
9
+ export declare function useHotkey(hotkeyStr: string, callback: (event: KeyboardEvent) => void): {
10
+ hotkeyConfig: HotkeyConfig;
11
+ };
12
+ export {};
@@ -0,0 +1,66 @@
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 useHotkey_exports = {};
19
+ __export(useHotkey_exports, {
20
+ matchHotkey: () => matchHotkey,
21
+ parseHotkey: () => parseHotkey,
22
+ useHotkey: () => useHotkey
23
+ });
24
+ module.exports = __toCommonJS(useHotkey_exports);
25
+ var import_vue = require("vue");
26
+ function parseHotkey(hotkeyStr) {
27
+ if (!hotkeyStr) return { ctrl: true, shift: false, alt: false, key: "k" };
28
+ const parts = hotkeyStr.toLowerCase().split("+");
29
+ const key = parts.pop();
30
+ return {
31
+ ctrl: parts.includes("ctrl") || parts.includes("cmd") || parts.includes("meta"),
32
+ shift: parts.includes("shift"),
33
+ alt: parts.includes("alt"),
34
+ key: key || "k"
35
+ };
36
+ }
37
+ function matchHotkey(e, hotkeyConfig) {
38
+ const ctrlMatch = hotkeyConfig.ctrl ? e.ctrlKey || e.metaKey : !(e.ctrlKey || e.metaKey);
39
+ const shiftMatch = hotkeyConfig.shift ? e.shiftKey : !e.shiftKey;
40
+ const altMatch = hotkeyConfig.alt ? e.altKey : !e.altKey;
41
+ const keyMatch = e.key.toLowerCase() === hotkeyConfig.key.toLowerCase();
42
+ return ctrlMatch && shiftMatch && altMatch && keyMatch;
43
+ }
44
+ function useHotkey(hotkeyStr, callback) {
45
+ const hotkeyConfig = parseHotkey(hotkeyStr);
46
+ const handleKeydown = (e) => {
47
+ if (matchHotkey(e, hotkeyConfig)) {
48
+ callback(e);
49
+ }
50
+ };
51
+ (0, import_vue.onMounted)(() => {
52
+ document.addEventListener("keydown", handleKeydown);
53
+ });
54
+ (0, import_vue.onUnmounted)(() => {
55
+ document.removeEventListener("keydown", handleKeydown);
56
+ });
57
+ return {
58
+ hotkeyConfig
59
+ };
60
+ }
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ matchHotkey,
64
+ parseHotkey,
65
+ useHotkey
66
+ });
@@ -0,0 +1,20 @@
1
+ import { ServiceStartupTask } from "@vite-plugin-opencode-assistant/shared";
2
+ interface SSEStatusSyncData {
3
+ type: "STATUS_SYNC";
4
+ isStarted?: boolean;
5
+ task: ServiceStartupTask;
6
+ errorType?: string;
7
+ errorMessage?: string;
8
+ }
9
+ interface SSETaskUpdateData {
10
+ type: "TASK_UPDATE";
11
+ task: ServiceStartupTask;
12
+ errorType?: string;
13
+ errorMessage?: string;
14
+ }
15
+ export declare function useSSE(onStatusSync: (data: SSEStatusSyncData) => void, onTaskUpdate: (data: SSETaskUpdateData) => void, onClearElements: () => void, onConnected: () => void): {
16
+ setupSSE: () => void;
17
+ closeSSE: () => void;
18
+ sseRetryCount: import("vue").Ref<number, number>;
19
+ };
20
+ export {};
@@ -0,0 +1,84 @@
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 useSSE_exports = {};
19
+ __export(useSSE_exports, {
20
+ useSSE: () => useSSE
21
+ });
22
+ module.exports = __toCommonJS(useSSE_exports);
23
+ var import_vue = require("vue");
24
+ const MAX_SSE_RETRIES = 10;
25
+ const SSE_RETRY_DELAY = 1e3;
26
+ function useSSE(onStatusSync, onTaskUpdate, onClearElements, onConnected) {
27
+ const sseConnection = (0, import_vue.ref)(null);
28
+ const sseRetryCount = (0, import_vue.ref)(0);
29
+ const setupSSE = () => {
30
+ if (sseConnection.value) return;
31
+ try {
32
+ sseConnection.value = new EventSource("/__opencode_events__");
33
+ sseConnection.value.onmessage = (event) => {
34
+ try {
35
+ const data = JSON.parse(event.data);
36
+ if (data.type === "CONNECTED") {
37
+ onConnected();
38
+ sseRetryCount.value = 0;
39
+ } else if (data.type === "STATUS_SYNC") {
40
+ onStatusSync(data);
41
+ } else if (data.type === "TASK_UPDATE") {
42
+ onTaskUpdate(data);
43
+ } else if (data.type === "CLEAR_ELEMENTS") {
44
+ onClearElements();
45
+ }
46
+ } catch (e) {
47
+ }
48
+ };
49
+ sseConnection.value.onerror = () => {
50
+ var _a;
51
+ (_a = sseConnection.value) == null ? void 0 : _a.close();
52
+ sseConnection.value = null;
53
+ if (sseRetryCount.value < MAX_SSE_RETRIES) {
54
+ sseRetryCount.value++;
55
+ setTimeout(setupSSE, SSE_RETRY_DELAY * sseRetryCount.value);
56
+ }
57
+ };
58
+ } catch (e) {
59
+ sseConnection.value = null;
60
+ if (sseRetryCount.value < MAX_SSE_RETRIES) {
61
+ sseRetryCount.value++;
62
+ setTimeout(setupSSE, SSE_RETRY_DELAY * sseRetryCount.value);
63
+ }
64
+ }
65
+ };
66
+ const closeSSE = () => {
67
+ if (sseConnection.value) {
68
+ sseConnection.value.close();
69
+ sseConnection.value = null;
70
+ }
71
+ };
72
+ (0, import_vue.onUnmounted)(() => {
73
+ closeSSE();
74
+ });
75
+ return {
76
+ setupSSE,
77
+ closeSSE,
78
+ sseRetryCount
79
+ };
80
+ }
81
+ // Annotate the CommonJS export names for ESM import in node:
82
+ 0 && (module.exports = {
83
+ useSSE
84
+ });
@@ -0,0 +1,19 @@
1
+ import type { OpenCodeSelectedElement } from "@vite-plugin-opencode-assistant/shared";
2
+ export declare function useSelectedElements(): {
3
+ selectedElements: import("vue").Ref<{
4
+ filePath: string | null;
5
+ line: number | null;
6
+ column: number | null;
7
+ innerText: string;
8
+ description?: string | undefined;
9
+ }[], OpenCodeSelectedElement[] | {
10
+ filePath: string | null;
11
+ line: number | null;
12
+ column: number | null;
13
+ innerText: string;
14
+ description?: string | undefined;
15
+ }[]>;
16
+ addElement: (element: OpenCodeSelectedElement) => boolean;
17
+ removeElement: (index: number) => void;
18
+ clearElements: () => void;
19
+ };
@@ -0,0 +1,66 @@
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 useSelectedElements_exports = {};
19
+ __export(useSelectedElements_exports, {
20
+ useSelectedElements: () => useSelectedElements
21
+ });
22
+ module.exports = __toCommonJS(useSelectedElements_exports);
23
+ var import_vue = require("vue");
24
+ function useSelectedElements() {
25
+ const selectedElements = (0, import_vue.ref)([]);
26
+ try {
27
+ const stored = sessionStorage.getItem("__opencode_selected_elements__");
28
+ if (stored) {
29
+ selectedElements.value = JSON.parse(stored);
30
+ }
31
+ } catch (e) {
32
+ }
33
+ (0, import_vue.watch)(
34
+ selectedElements,
35
+ (val) => {
36
+ sessionStorage.setItem("__opencode_selected_elements__", JSON.stringify(val));
37
+ },
38
+ { deep: true }
39
+ );
40
+ const addElement = (element) => {
41
+ const exists = selectedElements.value.some(
42
+ (el) => el.filePath === element.filePath && el.line === element.line
43
+ );
44
+ if (!exists) {
45
+ selectedElements.value.push(element);
46
+ return true;
47
+ }
48
+ return false;
49
+ };
50
+ const removeElement = (index) => {
51
+ selectedElements.value.splice(index, 1);
52
+ };
53
+ const clearElements = () => {
54
+ selectedElements.value = [];
55
+ };
56
+ return {
57
+ selectedElements,
58
+ addElement,
59
+ removeElement,
60
+ clearElements
61
+ };
62
+ }
63
+ // Annotate the CommonJS export names for ESM import in node:
64
+ 0 && (module.exports = {
65
+ useSelectedElements
66
+ });
@@ -0,0 +1,13 @@
1
+ import type { ServiceStartupTask, ServiceStatus } from "@vite-plugin-opencode-assistant/shared";
2
+ export declare function useServiceStatus(): {
3
+ currentTask: import("vue").Ref<"" | ServiceStartupTask, "" | ServiceStartupTask>;
4
+ serviceStatus: import("vue").Ref<ServiceStatus, ServiceStatus>;
5
+ chromeMcpFailed: import("vue").Ref<boolean, boolean>;
6
+ chromeMcpErrorType: import("vue").Ref<string | undefined, string | undefined>;
7
+ chromeMcpErrorMessage: import("vue").Ref<string | undefined, string | undefined>;
8
+ thinking: import("vue").Ref<boolean, boolean>;
9
+ loadingText: import("vue").ComputedRef<string>;
10
+ updateStatusFromTask: (task: ServiceStartupTask | "", errorType?: string, errorMessage?: string) => void;
11
+ setStarting: () => void;
12
+ setThinking: (value: boolean) => void;
13
+ };
@@ -0,0 +1,76 @@
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 useServiceStatus_exports = {};
19
+ __export(useServiceStatus_exports, {
20
+ useServiceStatus: () => useServiceStatus
21
+ });
22
+ module.exports = __toCommonJS(useServiceStatus_exports);
23
+ var import_vue = require("vue");
24
+ var import_shared = require("@vite-plugin-opencode-assistant/shared");
25
+ function useServiceStatus() {
26
+ const currentTask = (0, import_vue.ref)("");
27
+ const serviceStatus = (0, import_vue.ref)("idle");
28
+ const chromeMcpFailed = (0, import_vue.ref)(false);
29
+ const chromeMcpErrorType = (0, import_vue.ref)(void 0);
30
+ const chromeMcpErrorMessage = (0, import_vue.ref)(void 0);
31
+ const thinking = (0, import_vue.ref)(false);
32
+ const loadingText = (0, import_vue.computed)(() => {
33
+ if (!currentTask.value) return "\u52A0\u8F7D\u4E2D...";
34
+ return import_shared.SERVICE_STARTUP_TASKS[currentTask.value] || "\u52A0\u8F7D\u4E2D...";
35
+ });
36
+ const updateStatusFromTask = (task, errorType, errorMessage) => {
37
+ currentTask.value = task;
38
+ if (task === "ready") {
39
+ serviceStatus.value = "ready";
40
+ chromeMcpFailed.value = false;
41
+ chromeMcpErrorType.value = void 0;
42
+ chromeMcpErrorMessage.value = void 0;
43
+ } else if (task === "chrome_mcp_failed") {
44
+ serviceStatus.value = "partial";
45
+ chromeMcpFailed.value = true;
46
+ chromeMcpErrorType.value = errorType;
47
+ chromeMcpErrorMessage.value = errorMessage;
48
+ } else if (task === "session_creation_failed" || task === "opencode_not_installed" || task === "web_start_timeout") {
49
+ serviceStatus.value = "failed";
50
+ } else if (serviceStatus.value === "idle" && task) {
51
+ serviceStatus.value = "starting";
52
+ }
53
+ };
54
+ const setStarting = () => {
55
+ serviceStatus.value = "starting";
56
+ };
57
+ const setThinking = (value) => {
58
+ thinking.value = value;
59
+ };
60
+ return {
61
+ currentTask,
62
+ serviceStatus,
63
+ chromeMcpFailed,
64
+ chromeMcpErrorType,
65
+ chromeMcpErrorMessage,
66
+ thinking,
67
+ loadingText,
68
+ updateStatusFromTask,
69
+ setStarting,
70
+ setThinking
71
+ };
72
+ }
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ useServiceStatus
76
+ });
@@ -0,0 +1,26 @@
1
+ import type { OpenCodeWidgetSession } from "@vite-plugin-opencode-assistant/shared";
2
+ export declare function useSessions(showNotification: (msg: string) => void): {
3
+ sessions: import("vue").Ref<{
4
+ id: string;
5
+ title?: string | undefined;
6
+ updatedAt?: (string | number | Date) | undefined;
7
+ meta?: string | undefined;
8
+ directory?: string | undefined;
9
+ url?: string | undefined;
10
+ }[], OpenCodeWidgetSession[] | {
11
+ id: string;
12
+ title?: string | undefined;
13
+ updatedAt?: (string | number | Date) | undefined;
14
+ meta?: string | undefined;
15
+ directory?: string | undefined;
16
+ url?: string | undefined;
17
+ }[]>;
18
+ loadingSessionList: import("vue").Ref<boolean | undefined, boolean | undefined>;
19
+ currentSessionId: import("vue").Ref<string | null, string | null>;
20
+ iframeSrc: import("vue").ComputedRef<string>;
21
+ iframeLoading: import("vue").Ref<boolean, boolean>;
22
+ loadSessions: () => Promise<void>;
23
+ createSession: () => Promise<void>;
24
+ deleteSession: (session: OpenCodeWidgetSession) => Promise<void>;
25
+ selectSession: (session: OpenCodeWidgetSession) => void;
26
+ };