@gethmy/mcp 2.3.2 → 2.3.3

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.
@@ -1,195 +0,0 @@
1
- import { createRequire } from "node:module";
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __toESM = (mod, isNodeMode, target) => {
8
- target = mod != null ? __create(__getProtoOf(mod)) : {};
9
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
- for (let key of __getOwnPropNames(mod))
11
- if (!__hasOwnProp.call(to, key))
12
- __defProp(to, key, {
13
- get: () => mod[key],
14
- enumerable: true
15
- });
16
- return to;
17
- };
18
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
- var __export = (target, all) => {
20
- for (var name in all)
21
- __defProp(target, name, {
22
- get: all[name],
23
- enumerable: true,
24
- configurable: true,
25
- set: (newValue) => all[name] = () => newValue
26
- });
27
- };
28
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
29
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
30
-
31
- // src/auto-session.ts
32
- var CLIENT_DISPLAY_NAMES = {
33
- "claude-code": "Claude Code",
34
- "claude-desktop": "Claude Desktop",
35
- cursor: "Cursor",
36
- windsurf: "Windsurf",
37
- cline: "Cline",
38
- continue: "Continue",
39
- "codex-cli": "OpenAI Codex",
40
- zed: "Zed",
41
- "gemini-cli": "Gemini CLI"
42
- };
43
- function toIdentifier(name) {
44
- return name.toLowerCase().replace(/\s+/g, "-");
45
- }
46
- function resolveAgentIdentity(info) {
47
- if (!info?.name) {
48
- return { agentIdentifier: "unknown", agentName: "Unknown Agent" };
49
- }
50
- const key = toIdentifier(info.name);
51
- const displayName = CLIENT_DISPLAY_NAMES[key] ?? info.name;
52
- return { agentIdentifier: key, agentName: displayName };
53
- }
54
- var AUTO_START_TRIGGERS = new Set([
55
- "harmony_generate_prompt",
56
- "harmony_update_card",
57
- "harmony_move_card",
58
- "harmony_create_subtask",
59
- "harmony_toggle_subtask",
60
- "harmony_add_label_to_card",
61
- "harmony_remove_label_from_card"
62
- ]);
63
- var INACTIVITY_TIMEOUT_MS = 10 * 60 * 1000;
64
- var CHECK_INTERVAL_MS = 60 * 1000;
65
- var activeSessions = new Map;
66
- var inactivityTimer = null;
67
- var endCallback = null;
68
- var clientGetter = null;
69
- var clientInfoGetter = null;
70
- function initAutoSession(callback, getClient, getClientInfo) {
71
- endCallback = callback;
72
- clientGetter = getClient;
73
- clientInfoGetter = getClientInfo ?? null;
74
- if (inactivityTimer)
75
- clearInterval(inactivityTimer);
76
- inactivityTimer = setInterval(checkInactivity, CHECK_INTERVAL_MS);
77
- }
78
- async function trackActivity(cardId, options) {
79
- const now = Date.now();
80
- const existing = activeSessions.get(cardId);
81
- if (existing) {
82
- existing.lastActivityAt = now;
83
- return;
84
- }
85
- if (!options?.autoStart)
86
- return;
87
- const client = options?.client ?? clientGetter?.();
88
- if (!client)
89
- return;
90
- const toEnd = [];
91
- for (const [otherCardId, session] of activeSessions) {
92
- if (otherCardId !== cardId && !session.isExplicit) {
93
- toEnd.push(otherCardId);
94
- }
95
- }
96
- for (const otherCardId of toEnd) {
97
- await autoEndSession(client, otherCardId, "completed");
98
- }
99
- const info = clientInfoGetter?.() ?? null;
100
- const { agentIdentifier, agentName } = resolveAgentIdentity(info);
101
- try {
102
- await client.startAgentSession(cardId, {
103
- agentIdentifier,
104
- agentName,
105
- status: "working"
106
- });
107
- } catch {}
108
- activeSessions.set(cardId, {
109
- cardId,
110
- startedAt: now,
111
- lastActivityAt: now,
112
- isExplicit: false,
113
- agentIdentifier,
114
- agentName
115
- });
116
- }
117
- function markExplicit(cardId, options) {
118
- const existing = activeSessions.get(cardId);
119
- if (existing) {
120
- existing.isExplicit = true;
121
- if (options?.agentIdentifier)
122
- existing.agentIdentifier = options.agentIdentifier;
123
- if (options?.agentName)
124
- existing.agentName = options.agentName;
125
- } else {
126
- activeSessions.set(cardId, {
127
- cardId,
128
- startedAt: Date.now(),
129
- lastActivityAt: Date.now(),
130
- isExplicit: true,
131
- agentIdentifier: options?.agentIdentifier ?? "explicit",
132
- agentName: options?.agentName ?? "Explicit Agent"
133
- });
134
- }
135
- }
136
- function untrack(cardId) {
137
- activeSessions.delete(cardId);
138
- }
139
- async function shutdownAllSessions() {
140
- const client = clientGetter?.();
141
- if (!client)
142
- return;
143
- const cardIds = [...activeSessions.keys()];
144
- const promises = cardIds.map((cardId) => autoEndSession(client, cardId, "paused"));
145
- await Promise.allSettled(promises);
146
- }
147
- function destroyAutoSession() {
148
- if (inactivityTimer) {
149
- clearInterval(inactivityTimer);
150
- inactivityTimer = null;
151
- }
152
- activeSessions.clear();
153
- endCallback = null;
154
- clientGetter = null;
155
- clientInfoGetter = null;
156
- }
157
- function getActiveSessions() {
158
- return activeSessions;
159
- }
160
- function checkInactivity() {
161
- const now = Date.now();
162
- const client = clientGetter?.();
163
- if (!client)
164
- return;
165
- const entries = [...activeSessions.entries()];
166
- for (const [cardId, session] of entries) {
167
- if (session.isExplicit)
168
- continue;
169
- if (now - session.lastActivityAt > INACTIVITY_TIMEOUT_MS) {
170
- autoEndSession(client, cardId, "completed").catch(() => {});
171
- }
172
- }
173
- }
174
- async function autoEndSession(client, cardId, status) {
175
- activeSessions.delete(cardId);
176
- try {
177
- await client.endAgentSession(cardId, { status });
178
- } catch {}
179
- try {
180
- await endCallback?.(client, cardId, status);
181
- } catch {}
182
- }
183
- export {
184
- untrack,
185
- trackActivity,
186
- shutdownAllSessions,
187
- resolveAgentIdentity,
188
- markExplicit,
189
- initAutoSession,
190
- getActiveSessions,
191
- destroyAutoSession,
192
- checkInactivity,
193
- INACTIVITY_TIMEOUT_MS,
194
- AUTO_START_TRIGGERS
195
- };