@ai-devkit/agent-manager 0.24.0 → 0.25.0
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/dist/__tests__/adapters/GrokCliAdapter.test.js +403 -0
- package/dist/__tests__/adapters/GrokCliAdapter.test.js.map +1 -0
- package/dist/__tests__/utils/agents.test.js +6 -0
- package/dist/__tests__/utils/agents.test.js.map +1 -1
- package/dist/adapters/AgentAdapter.d.ts +1 -1
- package/dist/adapters/AgentAdapter.d.ts.map +1 -1
- package/dist/adapters/AgentAdapter.js.map +1 -1
- package/dist/adapters/GrokCliAdapter.d.ts +79 -0
- package/dist/adapters/GrokCliAdapter.d.ts.map +1 -0
- package/dist/adapters/GrokCliAdapter.js +306 -0
- package/dist/adapters/GrokCliAdapter.js.map +1 -0
- package/dist/adapters/index.d.ts +1 -0
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +1 -0
- package/dist/adapters/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/agents.d.ts +1 -1
- package/dist/utils/agents.d.ts.map +1 -1
- package/dist/utils/agents.js +4 -0
- package/dist/utils/agents.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/adapters/GrokCliAdapter.test.ts +307 -0
- package/src/__tests__/utils/agents.test.ts +7 -0
- package/src/adapters/AgentAdapter.ts +1 -1
- package/src/adapters/GrokCliAdapter.ts +394 -0
- package/src/adapters/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/utils/agents.ts +2 -1
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { AgentStatus } from './AgentAdapter.js';
|
|
3
|
+
import { listAgentProcesses, enrichProcesses } from '../utils/process.js';
|
|
4
|
+
import { isDirectory, safeReadFile, safeReaddir, safeStat } from '../utils/session.js';
|
|
5
|
+
import { generateAgentName } from '../utils/matching.js';
|
|
6
|
+
/**
|
|
7
|
+
* Grok Build CLI Adapter
|
|
8
|
+
*
|
|
9
|
+
* Detects running Grok Build CLI agents by:
|
|
10
|
+
* 1. Finding running `grok` processes via shared listAgentProcesses() — Grok is
|
|
11
|
+
* a native binary at ~/.grok/bin/grok, so argv[0] basename is `grok`.
|
|
12
|
+
* 2. Resolving each live process to its working directory via
|
|
13
|
+
* ~/.grok/active_sessions.json, which Grok maintains as a list of
|
|
14
|
+
* { pid, cwd, opened_at } for every running session. The cwd is then encoded
|
|
15
|
+
* into the session group dir ~/.grok/sessions/<encodeURIComponent(cwd)>/, and
|
|
16
|
+
* the most recently active session subdirectory is picked from it. The
|
|
17
|
+
* process cwd from lsof is only a fallback when the PID is not registered.
|
|
18
|
+
* 3. Reading the session transcript from chat_history.jsonl (the authoritative
|
|
19
|
+
* record of the conversation). The last user turn (the text inside
|
|
20
|
+
* <user_query>...</user_query>) is the summary; the file's mtime is the last
|
|
21
|
+
* activity time. summary.json / updates.jsonl are intentionally not used.
|
|
22
|
+
*/ const CHAT_HISTORY_FILE = 'chat_history.jsonl';
|
|
23
|
+
const ACTIVE_SESSIONS_FILE = 'active_sessions.json';
|
|
24
|
+
const CWD_FILE = '.cwd';
|
|
25
|
+
const IDLE_THRESHOLD_MINUTES = 5;
|
|
26
|
+
export class GrokCliAdapter {
|
|
27
|
+
type = 'grok_cli';
|
|
28
|
+
base;
|
|
29
|
+
sessionsDir;
|
|
30
|
+
constructor(){
|
|
31
|
+
// GROK_HOME overrides the ~/.grok base directory; sessions live under
|
|
32
|
+
// <base>/sessions/ and the active-session registry at
|
|
33
|
+
// <base>/active_sessions.json.
|
|
34
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || '';
|
|
35
|
+
this.base = process.env.GROK_HOME || path.join(homeDir, '.grok');
|
|
36
|
+
this.sessionsDir = path.join(this.base, 'sessions');
|
|
37
|
+
}
|
|
38
|
+
canHandle(processInfo) {
|
|
39
|
+
return this.isGrokExecutable(processInfo.command);
|
|
40
|
+
}
|
|
41
|
+
isGrokExecutable(command) {
|
|
42
|
+
const executable = command.trim().split(/\s+/)[0] || '';
|
|
43
|
+
const base = path.basename(executable).toLowerCase();
|
|
44
|
+
return base === 'grok' || base === 'grok.exe';
|
|
45
|
+
}
|
|
46
|
+
async detectAgents() {
|
|
47
|
+
const processes = enrichProcesses(listAgentProcesses('grok'));
|
|
48
|
+
if (processes.length === 0) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
// active_sessions.json is the authoritative pid -> cwd map for live
|
|
52
|
+
// sessions; the lsof-derived process cwd is only a fallback.
|
|
53
|
+
const pidToCwd = this.readActiveSessions();
|
|
54
|
+
const agents = [];
|
|
55
|
+
for (const proc of processes){
|
|
56
|
+
const cwd = pidToCwd.get(proc.pid) || proc.cwd || '';
|
|
57
|
+
const sessionDir = cwd ? this.latestSessionDir(cwd) : null;
|
|
58
|
+
const session = sessionDir ? this.readSession(sessionDir, cwd) : null;
|
|
59
|
+
if (session && sessionDir) {
|
|
60
|
+
agents.push(this.mapSessionToAgent(session, proc, sessionDir));
|
|
61
|
+
} else {
|
|
62
|
+
agents.push(this.mapProcessOnlyAgent(proc, cwd));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return agents;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Read ~/.grok/active_sessions.json into a pid -> cwd map. Grok writes one
|
|
69
|
+
* { pid, cwd, opened_at } entry per running session and removes it on exit,
|
|
70
|
+
* so this is the reliable way to learn a live process's working directory.
|
|
71
|
+
*/ readActiveSessions() {
|
|
72
|
+
const map = new Map();
|
|
73
|
+
const content = safeReadFile(path.join(this.base, ACTIVE_SESSIONS_FILE));
|
|
74
|
+
if (content === undefined) return map;
|
|
75
|
+
let entries;
|
|
76
|
+
try {
|
|
77
|
+
entries = JSON.parse(content);
|
|
78
|
+
} catch {
|
|
79
|
+
return map;
|
|
80
|
+
}
|
|
81
|
+
if (!Array.isArray(entries)) return map;
|
|
82
|
+
for (const entry of entries){
|
|
83
|
+
if (typeof entry?.pid === 'number' && typeof entry?.cwd === 'string' && entry.cwd) {
|
|
84
|
+
map.set(entry.pid, entry.cwd);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return map;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Full paths of the session subdirectories directly under a group dir,
|
|
91
|
+
* skipping any non-directory entries. Shared by latestSessionDir() and
|
|
92
|
+
* listSessions() so both enumerate session dirs the same way.
|
|
93
|
+
*/ listSessionDirs(groupDir) {
|
|
94
|
+
return safeReaddir(groupDir).map((sessionId)=>path.join(groupDir, sessionId)).filter((sessionDir)=>isDirectory(sessionDir));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Return the most recently active session subdirectory for a cwd, i.e. the
|
|
98
|
+
* ~/.grok/sessions/<encodeURIComponent(cwd)>/<id>/ whose chat_history.jsonl
|
|
99
|
+
* was written last. Returns null when the group dir or any transcript is
|
|
100
|
+
* missing.
|
|
101
|
+
*/ latestSessionDir(cwd) {
|
|
102
|
+
const groupDir = this.getProjectDir(cwd);
|
|
103
|
+
if (!isDirectory(groupDir)) return null;
|
|
104
|
+
let best = null;
|
|
105
|
+
for (const sessionDir of this.listSessionDirs(groupDir)){
|
|
106
|
+
const stat = safeStat(path.join(sessionDir, CHAT_HISTORY_FILE));
|
|
107
|
+
if (!stat) continue;
|
|
108
|
+
if (!best || stat.mtimeMs > best.mtimeMs) {
|
|
109
|
+
best = {
|
|
110
|
+
dir: sessionDir,
|
|
111
|
+
mtimeMs: stat.mtimeMs
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return best?.dir ?? null;
|
|
116
|
+
}
|
|
117
|
+
mapSessionToAgent(session, processInfo, sessionDir) {
|
|
118
|
+
const projectPath = session.projectPath || processInfo.cwd || '';
|
|
119
|
+
return {
|
|
120
|
+
name: generateAgentName(projectPath, processInfo.pid),
|
|
121
|
+
type: this.type,
|
|
122
|
+
status: this.determineStatus(session),
|
|
123
|
+
summary: session.summary || 'Grok CLI session active',
|
|
124
|
+
pid: processInfo.pid,
|
|
125
|
+
projectPath,
|
|
126
|
+
sessionId: session.sessionId,
|
|
127
|
+
lastActive: session.lastActive,
|
|
128
|
+
sessionFilePath: path.join(sessionDir, CHAT_HISTORY_FILE)
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
mapProcessOnlyAgent(processInfo, cwd) {
|
|
132
|
+
const projectPath = cwd || processInfo.cwd || '';
|
|
133
|
+
return {
|
|
134
|
+
name: generateAgentName(projectPath, processInfo.pid),
|
|
135
|
+
type: this.type,
|
|
136
|
+
status: AgentStatus.RUNNING,
|
|
137
|
+
summary: 'Grok CLI process running',
|
|
138
|
+
pid: processInfo.pid,
|
|
139
|
+
projectPath,
|
|
140
|
+
sessionId: `pid-${processInfo.pid}`,
|
|
141
|
+
lastActive: new Date()
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
getConversation(sessionFilePath, options) {
|
|
145
|
+
return this.parseChatHistory(this.resolveChatPath(sessionFilePath), options?.verbose ?? false).messages;
|
|
146
|
+
}
|
|
147
|
+
async listSessions(opts) {
|
|
148
|
+
if (!isDirectory(this.sessionsDir)) return [];
|
|
149
|
+
const filterCwd = opts?.cwd;
|
|
150
|
+
const summaries = [];
|
|
151
|
+
for (const groupName of safeReaddir(this.sessionsDir)){
|
|
152
|
+
const groupDir = path.join(this.sessionsDir, groupName);
|
|
153
|
+
if (!isDirectory(groupDir)) continue;
|
|
154
|
+
const decodedCwd = this.decodeGroupCwd(groupName, groupDir);
|
|
155
|
+
for (const sessionDir of this.listSessionDirs(groupDir)){
|
|
156
|
+
const session = this.readSession(sessionDir, decodedCwd);
|
|
157
|
+
if (!session) continue;
|
|
158
|
+
const cwd = session.projectPath || decodedCwd;
|
|
159
|
+
if (filterCwd !== undefined && cwd !== filterCwd) continue;
|
|
160
|
+
summaries.push({
|
|
161
|
+
type: this.type,
|
|
162
|
+
sessionId: session.sessionId,
|
|
163
|
+
cwd,
|
|
164
|
+
firstUserMessage: session.firstUserMessage || '',
|
|
165
|
+
lastActive: session.lastActive,
|
|
166
|
+
startedAt: session.sessionStart,
|
|
167
|
+
sessionFilePath: path.join(sessionDir, CHAT_HISTORY_FILE)
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return summaries;
|
|
172
|
+
}
|
|
173
|
+
// --- Session parsing (chat_history.jsonl) ---
|
|
174
|
+
/**
|
|
175
|
+
* Parse a session directory into a {@link GrokSession} from its
|
|
176
|
+
* chat_history.jsonl transcript. Returns null when the transcript is
|
|
177
|
+
* missing — i.e. there is no real session to surface.
|
|
178
|
+
*/ readSession(sessionDir, defaultCwd) {
|
|
179
|
+
const chatPath = path.join(sessionDir, CHAT_HISTORY_FILE);
|
|
180
|
+
const chatStat = safeStat(chatPath);
|
|
181
|
+
if (!chatStat) return null;
|
|
182
|
+
const scan = this.parseChatHistory(chatPath, false);
|
|
183
|
+
const dirStat = safeStat(sessionDir);
|
|
184
|
+
const lastActive = chatStat.mtime;
|
|
185
|
+
return {
|
|
186
|
+
sessionId: path.basename(sessionDir),
|
|
187
|
+
projectPath: defaultCwd || '',
|
|
188
|
+
summary: scan.lastUserMessage || 'Grok CLI session active',
|
|
189
|
+
sessionStart: dirStat?.birthtime || lastActive,
|
|
190
|
+
lastActive,
|
|
191
|
+
firstUserMessage: scan.firstUserMessage,
|
|
192
|
+
lastUserMessage: scan.lastUserMessage,
|
|
193
|
+
lastRole: scan.lastRole
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Determine agent status from parsed session state.
|
|
198
|
+
*
|
|
199
|
+
* - past the idle threshold → IDLE
|
|
200
|
+
* - last transcript turn is an assistant message → WAITING (awaiting user)
|
|
201
|
+
* - otherwise (last turn was a user message, or unknown) → RUNNING
|
|
202
|
+
*/ determineStatus(session) {
|
|
203
|
+
const diffMinutes = (Date.now() - session.lastActive.getTime()) / 60000;
|
|
204
|
+
if (diffMinutes > IDLE_THRESHOLD_MINUTES) {
|
|
205
|
+
return AgentStatus.IDLE;
|
|
206
|
+
}
|
|
207
|
+
if (session.lastRole === 'assistant') {
|
|
208
|
+
return AgentStatus.WAITING;
|
|
209
|
+
}
|
|
210
|
+
return AgentStatus.RUNNING;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Single pass over chat_history.jsonl. Each line is a
|
|
214
|
+
* { type: 'system' | 'user' | 'assistant', content } record where content is
|
|
215
|
+
* either a string or an array of { type: 'text', text } blocks.
|
|
216
|
+
*
|
|
217
|
+
* Grok wraps the real user prompt in <user_query>...</user_query>; the other
|
|
218
|
+
* user records are context injections (<user_info>, <system-reminder>, ...)
|
|
219
|
+
* and are skipped so the summary is the actual prompt, not boilerplate.
|
|
220
|
+
*/ parseChatHistory(chatPath, verbose) {
|
|
221
|
+
const empty = {
|
|
222
|
+
messages: []
|
|
223
|
+
};
|
|
224
|
+
const content = safeReadFile(chatPath);
|
|
225
|
+
if (content === undefined) return empty;
|
|
226
|
+
const messages = [];
|
|
227
|
+
let lastRole;
|
|
228
|
+
for (const line of content.trim().split('\n')){
|
|
229
|
+
if (!line.trim()) continue;
|
|
230
|
+
let record;
|
|
231
|
+
try {
|
|
232
|
+
record = JSON.parse(line);
|
|
233
|
+
} catch {
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
const text = this.extractText(record.content);
|
|
237
|
+
if (record.type === 'user') {
|
|
238
|
+
const query = this.extractUserQuery(text);
|
|
239
|
+
if (query === null) continue; // context injection, not a real prompt
|
|
240
|
+
messages.push({
|
|
241
|
+
role: 'user',
|
|
242
|
+
content: query
|
|
243
|
+
});
|
|
244
|
+
lastRole = 'user';
|
|
245
|
+
} else if (record.type === 'assistant') {
|
|
246
|
+
if (!text) continue;
|
|
247
|
+
messages.push({
|
|
248
|
+
role: 'assistant',
|
|
249
|
+
content: text
|
|
250
|
+
});
|
|
251
|
+
lastRole = 'assistant';
|
|
252
|
+
} else if (verbose && record.type === 'system') {
|
|
253
|
+
if (!text) continue;
|
|
254
|
+
messages.push({
|
|
255
|
+
role: 'system',
|
|
256
|
+
content: text
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const userTurns = messages.filter((m)=>m.role === 'user');
|
|
261
|
+
return {
|
|
262
|
+
messages,
|
|
263
|
+
firstUserMessage: userTurns[0]?.content,
|
|
264
|
+
lastUserMessage: userTurns[userTurns.length - 1]?.content,
|
|
265
|
+
lastRole
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
/** Flatten a chat record's content (string or text-block array) to text. */ extractText(content) {
|
|
269
|
+
if (typeof content === 'string') return content;
|
|
270
|
+
if (Array.isArray(content)) {
|
|
271
|
+
return content.map((block)=>block && typeof block === 'object' && typeof block.text === 'string' ? block.text : '').join('');
|
|
272
|
+
}
|
|
273
|
+
return '';
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Extract the prompt inside <user_query>...</user_query>. Returns null when
|
|
277
|
+
* the record has no such tag (a context injection rather than a prompt).
|
|
278
|
+
*/ extractUserQuery(text) {
|
|
279
|
+
const match = text.match(/<user_query>\s*([\s\S]*?)\s*<\/user_query>/);
|
|
280
|
+
return match ? match[1].trim() : null;
|
|
281
|
+
}
|
|
282
|
+
/** Resolve a session dir or an explicit chat_history.jsonl path to the file. */ resolveChatPath(sessionPath) {
|
|
283
|
+
return sessionPath.endsWith('.jsonl') ? sessionPath : path.join(sessionPath, CHAT_HISTORY_FILE);
|
|
284
|
+
}
|
|
285
|
+
getProjectDir(cwd) {
|
|
286
|
+
return path.join(this.sessionsDir, encodeURIComponent(cwd));
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Resolve the working directory a session group dir was created for.
|
|
290
|
+
*
|
|
291
|
+
* The common case is `decodeURIComponent(<group-name>)`. For paths whose
|
|
292
|
+
* encoded form exceeds the filesystem limit Grok uses a slug+hash and records
|
|
293
|
+
* the original path in a `.cwd` file inside the group — prefer that when
|
|
294
|
+
* present.
|
|
295
|
+
*/ decodeGroupCwd(groupName, groupDir) {
|
|
296
|
+
const fromFile = safeReadFile(path.join(groupDir, CWD_FILE));
|
|
297
|
+
if (fromFile !== undefined && fromFile.trim()) return fromFile.trim();
|
|
298
|
+
try {
|
|
299
|
+
return decodeURIComponent(groupName);
|
|
300
|
+
} catch {
|
|
301
|
+
return '';
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
//# sourceMappingURL=GrokCliAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/GrokCliAdapter.ts"],"sourcesContent":["import * as path from 'path';\nimport type {\n AgentAdapter,\n AgentInfo,\n ProcessInfo,\n ConversationMessage,\n SessionSummary,\n ListSessionsOptions,\n} from './AgentAdapter.js';\nimport { AgentStatus } from './AgentAdapter.js';\nimport { listAgentProcesses, enrichProcesses } from '../utils/process.js';\nimport { isDirectory, safeReadFile, safeReaddir, safeStat } from '../utils/session.js';\nimport { generateAgentName } from '../utils/matching.js';\n\n/**\n * Grok Build CLI Adapter\n *\n * Detects running Grok Build CLI agents by:\n * 1. Finding running `grok` processes via shared listAgentProcesses() — Grok is\n * a native binary at ~/.grok/bin/grok, so argv[0] basename is `grok`.\n * 2. Resolving each live process to its working directory via\n * ~/.grok/active_sessions.json, which Grok maintains as a list of\n * { pid, cwd, opened_at } for every running session. The cwd is then encoded\n * into the session group dir ~/.grok/sessions/<encodeURIComponent(cwd)>/, and\n * the most recently active session subdirectory is picked from it. The\n * process cwd from lsof is only a fallback when the PID is not registered.\n * 3. Reading the session transcript from chat_history.jsonl (the authoritative\n * record of the conversation). The last user turn (the text inside\n * <user_query>...</user_query>) is the summary; the file's mtime is the last\n * activity time. summary.json / updates.jsonl are intentionally not used.\n */\n\nconst CHAT_HISTORY_FILE = 'chat_history.jsonl';\nconst ACTIVE_SESSIONS_FILE = 'active_sessions.json';\nconst CWD_FILE = '.cwd';\nconst IDLE_THRESHOLD_MINUTES = 5;\n\n/** One entry of ~/.grok/active_sessions.json. */\ninterface ActiveSessionEntry {\n pid?: number;\n cwd?: string;\n opened_at?: number | string;\n}\n\n/** One line of chat_history.jsonl. */\ninterface ChatRecord {\n type?: string;\n content?: unknown;\n}\n\ninterface ChatScan {\n messages: ConversationMessage[];\n firstUserMessage?: string;\n lastUserMessage?: string;\n lastRole?: ConversationMessage['role'];\n}\n\n/** Parsed state for a single ~/.grok/sessions/<cwd>/<id>/ directory. */\ninterface GrokSession {\n sessionId: string;\n projectPath: string;\n summary: string;\n sessionStart: Date;\n lastActive: Date;\n firstUserMessage?: string;\n lastUserMessage?: string;\n lastRole?: ConversationMessage['role'];\n}\n\nexport class GrokCliAdapter implements AgentAdapter {\n readonly type = 'grok_cli' as const;\n\n private base: string;\n private sessionsDir: string;\n\n constructor() {\n // GROK_HOME overrides the ~/.grok base directory; sessions live under\n // <base>/sessions/ and the active-session registry at\n // <base>/active_sessions.json.\n const homeDir = process.env.HOME || process.env.USERPROFILE || '';\n this.base = process.env.GROK_HOME || path.join(homeDir, '.grok');\n this.sessionsDir = path.join(this.base, 'sessions');\n }\n\n canHandle(processInfo: ProcessInfo): boolean {\n return this.isGrokExecutable(processInfo.command);\n }\n\n private isGrokExecutable(command: string): boolean {\n const executable = command.trim().split(/\\s+/)[0] || '';\n const base = path.basename(executable).toLowerCase();\n return base === 'grok' || base === 'grok.exe';\n }\n\n async detectAgents(): Promise<AgentInfo[]> {\n const processes = enrichProcesses(listAgentProcesses('grok'));\n if (processes.length === 0) {\n return [];\n }\n\n // active_sessions.json is the authoritative pid -> cwd map for live\n // sessions; the lsof-derived process cwd is only a fallback.\n const pidToCwd = this.readActiveSessions();\n\n const agents: AgentInfo[] = [];\n for (const proc of processes) {\n const cwd = pidToCwd.get(proc.pid) || proc.cwd || '';\n const sessionDir = cwd ? this.latestSessionDir(cwd) : null;\n const session = sessionDir ? this.readSession(sessionDir, cwd) : null;\n\n if (session && sessionDir) {\n agents.push(this.mapSessionToAgent(session, proc, sessionDir));\n } else {\n agents.push(this.mapProcessOnlyAgent(proc, cwd));\n }\n }\n\n return agents;\n }\n\n /**\n * Read ~/.grok/active_sessions.json into a pid -> cwd map. Grok writes one\n * { pid, cwd, opened_at } entry per running session and removes it on exit,\n * so this is the reliable way to learn a live process's working directory.\n */\n private readActiveSessions(): Map<number, string> {\n const map = new Map<number, string>();\n const content = safeReadFile(path.join(this.base, ACTIVE_SESSIONS_FILE));\n if (content === undefined) return map;\n\n let entries: unknown;\n try {\n entries = JSON.parse(content);\n } catch {\n return map;\n }\n if (!Array.isArray(entries)) return map;\n\n for (const entry of entries as ActiveSessionEntry[]) {\n if (typeof entry?.pid === 'number' && typeof entry?.cwd === 'string' && entry.cwd) {\n map.set(entry.pid, entry.cwd);\n }\n }\n return map;\n }\n\n /**\n * Full paths of the session subdirectories directly under a group dir,\n * skipping any non-directory entries. Shared by latestSessionDir() and\n * listSessions() so both enumerate session dirs the same way.\n */\n private listSessionDirs(groupDir: string): string[] {\n return safeReaddir(groupDir)\n .map((sessionId) => path.join(groupDir, sessionId))\n .filter((sessionDir) => isDirectory(sessionDir));\n }\n\n /**\n * Return the most recently active session subdirectory for a cwd, i.e. the\n * ~/.grok/sessions/<encodeURIComponent(cwd)>/<id>/ whose chat_history.jsonl\n * was written last. Returns null when the group dir or any transcript is\n * missing.\n */\n private latestSessionDir(cwd: string): string | null {\n const groupDir = this.getProjectDir(cwd);\n if (!isDirectory(groupDir)) return null;\n\n let best: { dir: string; mtimeMs: number } | null = null;\n for (const sessionDir of this.listSessionDirs(groupDir)) {\n const stat = safeStat(path.join(sessionDir, CHAT_HISTORY_FILE));\n if (!stat) continue;\n if (!best || stat.mtimeMs > best.mtimeMs) {\n best = { dir: sessionDir, mtimeMs: stat.mtimeMs };\n }\n }\n return best?.dir ?? null;\n }\n\n private mapSessionToAgent(session: GrokSession, processInfo: ProcessInfo, sessionDir: string): AgentInfo {\n const projectPath = session.projectPath || processInfo.cwd || '';\n return {\n name: generateAgentName(projectPath, processInfo.pid),\n type: this.type,\n status: this.determineStatus(session),\n summary: session.summary || 'Grok CLI session active',\n pid: processInfo.pid,\n projectPath,\n sessionId: session.sessionId,\n lastActive: session.lastActive,\n sessionFilePath: path.join(sessionDir, CHAT_HISTORY_FILE),\n };\n }\n\n private mapProcessOnlyAgent(processInfo: ProcessInfo, cwd: string): AgentInfo {\n const projectPath = cwd || processInfo.cwd || '';\n return {\n name: generateAgentName(projectPath, processInfo.pid),\n type: this.type,\n status: AgentStatus.RUNNING,\n summary: 'Grok CLI process running',\n pid: processInfo.pid,\n projectPath,\n sessionId: `pid-${processInfo.pid}`,\n lastActive: new Date(),\n };\n }\n\n getConversation(sessionFilePath: string, options?: { verbose?: boolean }): ConversationMessage[] {\n return this.parseChatHistory(this.resolveChatPath(sessionFilePath), options?.verbose ?? false).messages;\n }\n\n async listSessions(opts?: ListSessionsOptions): Promise<SessionSummary[]> {\n if (!isDirectory(this.sessionsDir)) return [];\n\n const filterCwd = opts?.cwd;\n const summaries: SessionSummary[] = [];\n\n for (const groupName of safeReaddir(this.sessionsDir)) {\n const groupDir = path.join(this.sessionsDir, groupName);\n if (!isDirectory(groupDir)) continue;\n\n const decodedCwd = this.decodeGroupCwd(groupName, groupDir);\n\n for (const sessionDir of this.listSessionDirs(groupDir)) {\n const session = this.readSession(sessionDir, decodedCwd);\n if (!session) continue;\n\n const cwd = session.projectPath || decodedCwd;\n if (filterCwd !== undefined && cwd !== filterCwd) continue;\n\n summaries.push({\n type: this.type,\n sessionId: session.sessionId,\n cwd,\n firstUserMessage: session.firstUserMessage || '',\n lastActive: session.lastActive,\n startedAt: session.sessionStart,\n sessionFilePath: path.join(sessionDir, CHAT_HISTORY_FILE),\n });\n }\n }\n\n return summaries;\n }\n\n // --- Session parsing (chat_history.jsonl) ---\n\n /**\n * Parse a session directory into a {@link GrokSession} from its\n * chat_history.jsonl transcript. Returns null when the transcript is\n * missing — i.e. there is no real session to surface.\n */\n private readSession(sessionDir: string, defaultCwd: string): GrokSession | null {\n const chatPath = path.join(sessionDir, CHAT_HISTORY_FILE);\n const chatStat = safeStat(chatPath);\n if (!chatStat) return null;\n\n const scan = this.parseChatHistory(chatPath, false);\n const dirStat = safeStat(sessionDir);\n const lastActive = chatStat.mtime;\n\n return {\n sessionId: path.basename(sessionDir),\n projectPath: defaultCwd || '',\n summary: scan.lastUserMessage || 'Grok CLI session active',\n sessionStart: dirStat?.birthtime || lastActive,\n lastActive,\n firstUserMessage: scan.firstUserMessage,\n lastUserMessage: scan.lastUserMessage,\n lastRole: scan.lastRole,\n };\n }\n\n /**\n * Determine agent status from parsed session state.\n *\n * - past the idle threshold → IDLE\n * - last transcript turn is an assistant message → WAITING (awaiting user)\n * - otherwise (last turn was a user message, or unknown) → RUNNING\n */\n private determineStatus(session: GrokSession): AgentStatus {\n const diffMinutes = (Date.now() - session.lastActive.getTime()) / 60000;\n if (diffMinutes > IDLE_THRESHOLD_MINUTES) {\n return AgentStatus.IDLE;\n }\n if (session.lastRole === 'assistant') {\n return AgentStatus.WAITING;\n }\n return AgentStatus.RUNNING;\n }\n\n /**\n * Single pass over chat_history.jsonl. Each line is a\n * { type: 'system' | 'user' | 'assistant', content } record where content is\n * either a string or an array of { type: 'text', text } blocks.\n *\n * Grok wraps the real user prompt in <user_query>...</user_query>; the other\n * user records are context injections (<user_info>, <system-reminder>, ...)\n * and are skipped so the summary is the actual prompt, not boilerplate.\n */\n private parseChatHistory(chatPath: string, verbose: boolean): ChatScan {\n const empty: ChatScan = { messages: [] };\n const content = safeReadFile(chatPath);\n if (content === undefined) return empty;\n\n const messages: ConversationMessage[] = [];\n let lastRole: ConversationMessage['role'] | undefined;\n\n for (const line of content.trim().split('\\n')) {\n if (!line.trim()) continue;\n\n let record: ChatRecord;\n try {\n record = JSON.parse(line);\n } catch {\n continue;\n }\n\n const text = this.extractText(record.content);\n if (record.type === 'user') {\n const query = this.extractUserQuery(text);\n if (query === null) continue; // context injection, not a real prompt\n messages.push({ role: 'user', content: query });\n lastRole = 'user';\n } else if (record.type === 'assistant') {\n if (!text) continue;\n messages.push({ role: 'assistant', content: text });\n lastRole = 'assistant';\n } else if (verbose && record.type === 'system') {\n if (!text) continue;\n messages.push({ role: 'system', content: text });\n }\n }\n\n const userTurns = messages.filter((m) => m.role === 'user');\n return {\n messages,\n firstUserMessage: userTurns[0]?.content,\n lastUserMessage: userTurns[userTurns.length - 1]?.content,\n lastRole,\n };\n }\n\n /** Flatten a chat record's content (string or text-block array) to text. */\n private extractText(content: unknown): string {\n if (typeof content === 'string') return content;\n if (Array.isArray(content)) {\n return content\n .map((block) =>\n block && typeof block === 'object' && typeof (block as { text?: unknown }).text === 'string'\n ? (block as { text: string }).text\n : '',\n )\n .join('');\n }\n return '';\n }\n\n /**\n * Extract the prompt inside <user_query>...</user_query>. Returns null when\n * the record has no such tag (a context injection rather than a prompt).\n */\n private extractUserQuery(text: string): string | null {\n const match = text.match(/<user_query>\\s*([\\s\\S]*?)\\s*<\\/user_query>/);\n return match ? match[1].trim() : null;\n }\n\n /** Resolve a session dir or an explicit chat_history.jsonl path to the file. */\n private resolveChatPath(sessionPath: string): string {\n return sessionPath.endsWith('.jsonl') ? sessionPath : path.join(sessionPath, CHAT_HISTORY_FILE);\n }\n\n private getProjectDir(cwd: string): string {\n return path.join(this.sessionsDir, encodeURIComponent(cwd));\n }\n\n /**\n * Resolve the working directory a session group dir was created for.\n *\n * The common case is `decodeURIComponent(<group-name>)`. For paths whose\n * encoded form exceeds the filesystem limit Grok uses a slug+hash and records\n * the original path in a `.cwd` file inside the group — prefer that when\n * present.\n */\n private decodeGroupCwd(groupName: string, groupDir: string): string {\n const fromFile = safeReadFile(path.join(groupDir, CWD_FILE));\n if (fromFile !== undefined && fromFile.trim()) return fromFile.trim();\n try {\n return decodeURIComponent(groupName);\n } catch {\n return '';\n }\n }\n}\n"],"names":["path","AgentStatus","listAgentProcesses","enrichProcesses","isDirectory","safeReadFile","safeReaddir","safeStat","generateAgentName","CHAT_HISTORY_FILE","ACTIVE_SESSIONS_FILE","CWD_FILE","IDLE_THRESHOLD_MINUTES","GrokCliAdapter","type","base","sessionsDir","homeDir","process","env","HOME","USERPROFILE","GROK_HOME","join","canHandle","processInfo","isGrokExecutable","command","executable","trim","split","basename","toLowerCase","detectAgents","processes","length","pidToCwd","readActiveSessions","agents","proc","cwd","get","pid","sessionDir","latestSessionDir","session","readSession","push","mapSessionToAgent","mapProcessOnlyAgent","map","Map","content","undefined","entries","JSON","parse","Array","isArray","entry","set","listSessionDirs","groupDir","sessionId","filter","getProjectDir","best","stat","mtimeMs","dir","projectPath","name","status","determineStatus","summary","lastActive","sessionFilePath","RUNNING","Date","getConversation","options","parseChatHistory","resolveChatPath","verbose","messages","listSessions","opts","filterCwd","summaries","groupName","decodedCwd","decodeGroupCwd","firstUserMessage","startedAt","sessionStart","defaultCwd","chatPath","chatStat","scan","dirStat","mtime","lastUserMessage","birthtime","lastRole","diffMinutes","now","getTime","IDLE","WAITING","empty","line","record","text","extractText","query","extractUserQuery","role","userTurns","m","block","match","sessionPath","endsWith","encodeURIComponent","fromFile","decodeURIComponent"],"mappings":"AAAA,YAAYA,UAAU,OAAO;AAS7B,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASC,kBAAkB,EAAEC,eAAe,QAAQ,sBAAsB;AAC1E,SAASC,WAAW,EAAEC,YAAY,EAAEC,WAAW,EAAEC,QAAQ,QAAQ,sBAAsB;AACvF,SAASC,iBAAiB,QAAQ,uBAAuB;AAEzD;;;;;;;;;;;;;;;;CAgBC,GAED,MAAMC,oBAAoB;AAC1B,MAAMC,uBAAuB;AAC7B,MAAMC,WAAW;AACjB,MAAMC,yBAAyB;AAkC/B,OAAO,MAAMC;IACAC,OAAO,WAAoB;IAE5BC,KAAa;IACbC,YAAoB;IAE5B,aAAc;QACV,sEAAsE;QACtE,sDAAsD;QACtD,+BAA+B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B,EAAE,OAAM;YACJ,OAAO;QACX;IACJ;AACJ"}
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { ClaudeCodeAdapter } from './ClaudeCodeAdapter.js';
|
|
|
2
2
|
export { CodexAdapter } from './CodexAdapter.js';
|
|
3
3
|
export { CopilotAdapter } from './CopilotAdapter.js';
|
|
4
4
|
export { GeminiCliAdapter } from './GeminiCliAdapter.js';
|
|
5
|
+
export { GrokCliAdapter } from './GrokCliAdapter.js';
|
|
5
6
|
export { OpenCodeAdapter } from './OpenCodeAdapter.js';
|
|
6
7
|
export { PiAdapter } from './PiAdapter.js';
|
|
7
8
|
export { AgentStatus } from './AgentAdapter.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/adapters/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { ClaudeCodeAdapter } from './ClaudeCodeAdapter.js';
|
|
|
2
2
|
export { CodexAdapter } from './CodexAdapter.js';
|
|
3
3
|
export { CopilotAdapter } from './CopilotAdapter.js';
|
|
4
4
|
export { GeminiCliAdapter } from './GeminiCliAdapter.js';
|
|
5
|
+
export { GrokCliAdapter } from './GrokCliAdapter.js';
|
|
5
6
|
export { OpenCodeAdapter } from './OpenCodeAdapter.js';
|
|
6
7
|
export { PiAdapter } from './PiAdapter.js';
|
|
7
8
|
export { AgentStatus } from './AgentAdapter.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/adapters/index.ts"],"sourcesContent":["export { ClaudeCodeAdapter } from './ClaudeCodeAdapter.js';\nexport { CodexAdapter } from './CodexAdapter.js';\nexport { CopilotAdapter } from './CopilotAdapter.js';\nexport { GeminiCliAdapter } from './GeminiCliAdapter.js';\nexport { OpenCodeAdapter } from './OpenCodeAdapter.js';\nexport { PiAdapter } from './PiAdapter.js';\nexport { AgentStatus } from './AgentAdapter.js';\nexport type { AgentAdapter, AgentType, AgentInfo, ProcessInfo } from './AgentAdapter.js';\n"],"names":["ClaudeCodeAdapter","CodexAdapter","CopilotAdapter","GeminiCliAdapter","OpenCodeAdapter","PiAdapter","AgentStatus"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,cAAc,QAAQ,sBAAsB;AACrD,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,WAAW,QAAQ,oBAAoB"}
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/index.ts"],"sourcesContent":["export { ClaudeCodeAdapter } from './ClaudeCodeAdapter.js';\nexport { CodexAdapter } from './CodexAdapter.js';\nexport { CopilotAdapter } from './CopilotAdapter.js';\nexport { GeminiCliAdapter } from './GeminiCliAdapter.js';\nexport { GrokCliAdapter } from './GrokCliAdapter.js';\nexport { OpenCodeAdapter } from './OpenCodeAdapter.js';\nexport { PiAdapter } from './PiAdapter.js';\nexport { AgentStatus } from './AgentAdapter.js';\nexport type { AgentAdapter, AgentType, AgentInfo, ProcessInfo } from './AgentAdapter.js';\n"],"names":["ClaudeCodeAdapter","CodexAdapter","CopilotAdapter","GeminiCliAdapter","GrokCliAdapter","OpenCodeAdapter","PiAdapter","AgentStatus"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,cAAc,QAAQ,sBAAsB;AACrD,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,cAAc,QAAQ,sBAAsB;AACrD,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,WAAW,QAAQ,oBAAoB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { ClaudeCodeAdapter } from './adapters/ClaudeCodeAdapter.js';
|
|
|
3
3
|
export { CodexAdapter } from './adapters/CodexAdapter.js';
|
|
4
4
|
export { CopilotAdapter } from './adapters/CopilotAdapter.js';
|
|
5
5
|
export { GeminiCliAdapter } from './adapters/GeminiCliAdapter.js';
|
|
6
|
+
export { GrokCliAdapter } from './adapters/GrokCliAdapter.js';
|
|
6
7
|
export { OpenCodeAdapter } from './adapters/OpenCodeAdapter.js';
|
|
7
8
|
export { PiAdapter } from './adapters/PiAdapter.js';
|
|
8
9
|
export { AgentStatus } from './adapters/AgentAdapter.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,YAAY,EACR,YAAY,EACZ,SAAS,EACT,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,mBAAmB,GACtB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACxF,YAAY,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACnG,YAAY,EAAE,aAAa,EAAE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EAAE,MAAM,uBAAuB,CAAC;AAC1D,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACnG,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEzE,YAAY,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export { ClaudeCodeAdapter } from './adapters/ClaudeCodeAdapter.js';
|
|
|
3
3
|
export { CodexAdapter } from './adapters/CodexAdapter.js';
|
|
4
4
|
export { CopilotAdapter } from './adapters/CopilotAdapter.js';
|
|
5
5
|
export { GeminiCliAdapter } from './adapters/GeminiCliAdapter.js';
|
|
6
|
+
export { GrokCliAdapter } from './adapters/GrokCliAdapter.js';
|
|
6
7
|
export { OpenCodeAdapter } from './adapters/OpenCodeAdapter.js';
|
|
7
8
|
export { PiAdapter } from './adapters/PiAdapter.js';
|
|
8
9
|
export { AgentStatus } from './adapters/AgentAdapter.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { AgentManager } from './AgentManager.js';\n\nexport { ClaudeCodeAdapter } from './adapters/ClaudeCodeAdapter.js';\nexport { CodexAdapter } from './adapters/CodexAdapter.js';\nexport { CopilotAdapter } from './adapters/CopilotAdapter.js';\nexport { GeminiCliAdapter } from './adapters/GeminiCliAdapter.js';\nexport { OpenCodeAdapter } from './adapters/OpenCodeAdapter.js';\nexport { PiAdapter } from './adapters/PiAdapter.js';\nexport { AgentStatus } from './adapters/AgentAdapter.js';\nexport type {\n AgentAdapter,\n AgentType,\n AgentInfo,\n ProcessInfo,\n ConversationMessage,\n SessionSummary,\n ListSessionsOptions,\n} from './adapters/AgentAdapter.js';\n\nexport { TerminalFocusManager, TerminalType } from './terminal/TerminalFocusManager.js';\nexport type { TerminalLocation } from './terminal/TerminalFocusManager.js';\nexport { TtyWriter } from './terminal/TtyWriter.js';\n\nexport { getProcessTty } from './utils/process.js';\nexport type { AgentSortKey } from './utils/sortAgents.js';\nexport type { ListAgentsOptions } from './AgentManager.js';\n\nexport { AgentRegistry, RenameNotFoundError, RenameConflictError } from './utils/AgentRegistry.js';\nexport type { RegistryEntry } from './utils/AgentRegistry.js';\nexport { TmuxManager } from './terminal/TmuxManager.js';\nexport { AGENTS } from './utils/agents.js';\nexport type { AgentConfig, StartableAgentType } from './utils/agents.js';\n\nexport type { AgentRequest } from './utils/agent-requests.js';\nexport { getAgentRequestPath, readLatestAgentRequest, writeAgentRequest } from './utils/agent-requests.js';\n"],"names":["AgentManager","ClaudeCodeAdapter","CodexAdapter","CopilotAdapter","GeminiCliAdapter","OpenCodeAdapter","PiAdapter","AgentStatus","TerminalFocusManager","TerminalType","TtyWriter","getProcessTty","AgentRegistry","RenameNotFoundError","RenameConflictError","TmuxManager","AGENTS","getAgentRequestPath","readLatestAgentRequest","writeAgentRequest"],"mappings":"AAAA,SAASA,YAAY,QAAQ,oBAAoB;AAEjD,SAASC,iBAAiB,QAAQ,kCAAkC;AACpE,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,cAAc,QAAQ,+BAA+B;AAC9D,SAASC,gBAAgB,QAAQ,iCAAiC;AAClE,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,SAAS,QAAQ,0BAA0B;AACpD,SAASC,WAAW,QAAQ,6BAA6B;AAWzD,SAASC,oBAAoB,EAAEC,YAAY,QAAQ,qCAAqC;AAExF,SAASC,SAAS,QAAQ,0BAA0B;AAEpD,SAASC,aAAa,QAAQ,qBAAqB;AAInD,SAASC,aAAa,EAAEC,mBAAmB,EAAEC,mBAAmB,QAAQ,2BAA2B;AAEnG,SAASC,WAAW,QAAQ,4BAA4B;AACxD,SAASC,MAAM,QAAQ,oBAAoB;AAI3C,SAASC,mBAAmB,EAAEC,sBAAsB,EAAEC,iBAAiB,QAAQ,4BAA4B"}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { AgentManager } from './AgentManager.js';\n\nexport { ClaudeCodeAdapter } from './adapters/ClaudeCodeAdapter.js';\nexport { CodexAdapter } from './adapters/CodexAdapter.js';\nexport { CopilotAdapter } from './adapters/CopilotAdapter.js';\nexport { GeminiCliAdapter } from './adapters/GeminiCliAdapter.js';\nexport { GrokCliAdapter } from './adapters/GrokCliAdapter.js';\nexport { OpenCodeAdapter } from './adapters/OpenCodeAdapter.js';\nexport { PiAdapter } from './adapters/PiAdapter.js';\nexport { AgentStatus } from './adapters/AgentAdapter.js';\nexport type {\n AgentAdapter,\n AgentType,\n AgentInfo,\n ProcessInfo,\n ConversationMessage,\n SessionSummary,\n ListSessionsOptions,\n} from './adapters/AgentAdapter.js';\n\nexport { TerminalFocusManager, TerminalType } from './terminal/TerminalFocusManager.js';\nexport type { TerminalLocation } from './terminal/TerminalFocusManager.js';\nexport { TtyWriter } from './terminal/TtyWriter.js';\n\nexport { getProcessTty } from './utils/process.js';\nexport type { AgentSortKey } from './utils/sortAgents.js';\nexport type { ListAgentsOptions } from './AgentManager.js';\n\nexport { AgentRegistry, RenameNotFoundError, RenameConflictError } from './utils/AgentRegistry.js';\nexport type { RegistryEntry } from './utils/AgentRegistry.js';\nexport { TmuxManager } from './terminal/TmuxManager.js';\nexport { AGENTS } from './utils/agents.js';\nexport type { AgentConfig, StartableAgentType } from './utils/agents.js';\n\nexport type { AgentRequest } from './utils/agent-requests.js';\nexport { getAgentRequestPath, readLatestAgentRequest, writeAgentRequest } from './utils/agent-requests.js';\n"],"names":["AgentManager","ClaudeCodeAdapter","CodexAdapter","CopilotAdapter","GeminiCliAdapter","GrokCliAdapter","OpenCodeAdapter","PiAdapter","AgentStatus","TerminalFocusManager","TerminalType","TtyWriter","getProcessTty","AgentRegistry","RenameNotFoundError","RenameConflictError","TmuxManager","AGENTS","getAgentRequestPath","readLatestAgentRequest","writeAgentRequest"],"mappings":"AAAA,SAASA,YAAY,QAAQ,oBAAoB;AAEjD,SAASC,iBAAiB,QAAQ,kCAAkC;AACpE,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,cAAc,QAAQ,+BAA+B;AAC9D,SAASC,gBAAgB,QAAQ,iCAAiC;AAClE,SAASC,cAAc,QAAQ,+BAA+B;AAC9D,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,SAAS,QAAQ,0BAA0B;AACpD,SAASC,WAAW,QAAQ,6BAA6B;AAWzD,SAASC,oBAAoB,EAAEC,YAAY,QAAQ,qCAAqC;AAExF,SAASC,SAAS,QAAQ,0BAA0B;AAEpD,SAASC,aAAa,QAAQ,qBAAqB;AAInD,SAASC,aAAa,EAAEC,mBAAmB,EAAEC,mBAAmB,QAAQ,2BAA2B;AAEnG,SAASC,WAAW,QAAQ,4BAA4B;AACxD,SAASC,MAAM,QAAQ,oBAAoB;AAI3C,SAASC,mBAAmB,EAAEC,sBAAsB,EAAEC,iBAAiB,QAAQ,4BAA4B"}
|
package/dist/utils/agents.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentType } from '../adapters/AgentAdapter.js';
|
|
2
|
-
export type StartableAgentType = Extract<AgentType, 'claude' | 'codex' | 'copilot' | 'gemini_cli' | 'opencode' | 'pi'>;
|
|
2
|
+
export type StartableAgentType = Extract<AgentType, 'claude' | 'codex' | 'copilot' | 'gemini_cli' | 'grok_cli' | 'opencode' | 'pi'>;
|
|
3
3
|
export interface AgentConfig {
|
|
4
4
|
/** Shell command to launch the agent (sent to tmux via `send-keys`). */
|
|
5
5
|
command: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/utils/agents.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/utils/agents.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,UAAU,GAAG,IAAI,CAAC,CAAC;AAEpI,MAAM,WAAW,WAAW;IACxB,wEAAwE;IACxE,OAAO,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;CAC3C;AAED;;;;GAIG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,kBAAkB,EAAE,WAAW,CAQ1D,CAAC"}
|
package/dist/utils/agents.js
CHANGED
package/dist/utils/agents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/agents.ts"],"sourcesContent":["import path from 'path';\nimport type { AgentType } from '../adapters/AgentAdapter.js';\n\nexport type StartableAgentType = Extract<AgentType, 'claude' | 'codex' | 'copilot' | 'gemini_cli' | 'opencode' | 'pi'>;\n\nexport interface AgentConfig {\n /** Shell command to launch the agent (sent to tmux via `send-keys`). */\n command: string;\n /** Returns true if the given `ps` command line belongs to this agent. */\n matches: (psCommand: string) => boolean;\n}\n\n/**\n * Per-agent configuration: launch command plus a matcher that recognizes the\n * agent's process in `ps` output. Each matcher knows that agent's distribution\n * quirks (e.g. gemini ships as a Node script so its real binary is in argv[1..]).\n */\nexport const AGENTS: Record<StartableAgentType, AgentConfig> = {\n claude: { command: 'claude', matches: matchArgv0('claude') },\n codex: { command: 'codex', matches: matchArgv0('codex') },\n copilot: { command: 'copilot', matches: matchArgv0Name('copilot-cli') },\n gemini_cli: { command: 'gemini', matches: matchAnyToken('gemini') },\n opencode: { command: 'opencode', matches: matchArgv0('opencode') },\n pi: { command: 'pi', matches: matchAnyBasename(['pi']) },\n};\n\nfunction matchArgv0(name: string): (psCommand: string) => boolean {\n const lower = name.toLowerCase();\n return (psCommand) => {\n const token = psCommand.trim().split(/\\s+/)[0];\n return token ? path.basename(token).toLowerCase() === lower : false;\n };\n}\n\nfunction matchArgv0Name(name: string): (psCommand: string) => boolean {\n const lower = name.toLowerCase();\n return (psCommand) => {\n const token = psCommand.trim().split(/\\s+/)[0];\n return token ? token.toLowerCase().includes(lower) : false;\n };\n}\n\nfunction matchAnyToken(name: string): (psCommand: string) => boolean {\n const lower = name.toLowerCase();\n return (psCommand) => {\n for (const token of psCommand.trim().split(/\\s+/)) {\n if (path.basename(token).toLowerCase() === lower) return true;\n }\n return false;\n };\n}\n\nfunction matchAnyBasename(names: string[]): (psCommand: string) => boolean {\n const lowers = new Set(names.map((name) => name.toLowerCase()));\n return (psCommand) => {\n for (const token of psCommand.trim().split(/\\s+/)) {\n if (lowers.has(path.basename(token).toLowerCase())) return true;\n }\n return false;\n };\n}\n"],"names":["path","AGENTS","claude","command","matches","matchArgv0","codex","copilot","matchArgv0Name","gemini_cli","matchAnyToken","opencode","pi","matchAnyBasename","name","lower","toLowerCase","psCommand","token","trim","split","basename","includes","names","lowers","Set","map","has"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AAYxB;;;;CAIC,GACD,OAAO,MAAMC,SAAkD;IAC3DC,QAAY;QAAEC,SAAS;QAAYC,SAASC,WAAW;IAAU;IACjEC,OAAY;QAAEH,SAAS;QAAYC,SAASC,WAAW;IAAS;IAChEE,SAAY;QAAEJ,SAAS;QAAYC,SAASI,eAAe;IAAe;IAC1EC,YAAY;QAAEN,SAAS;QAAYC,SAASM,cAAc;IAAU;IACpEC,UAAY;QAAER,SAAS;QAAYC,SAASC,WAAW;IAAY;
|
|
1
|
+
{"version":3,"sources":["../../src/utils/agents.ts"],"sourcesContent":["import path from 'path';\nimport type { AgentType } from '../adapters/AgentAdapter.js';\n\nexport type StartableAgentType = Extract<AgentType, 'claude' | 'codex' | 'copilot' | 'gemini_cli' | 'grok_cli' | 'opencode' | 'pi'>;\n\nexport interface AgentConfig {\n /** Shell command to launch the agent (sent to tmux via `send-keys`). */\n command: string;\n /** Returns true if the given `ps` command line belongs to this agent. */\n matches: (psCommand: string) => boolean;\n}\n\n/**\n * Per-agent configuration: launch command plus a matcher that recognizes the\n * agent's process in `ps` output. Each matcher knows that agent's distribution\n * quirks (e.g. gemini ships as a Node script so its real binary is in argv[1..]).\n */\nexport const AGENTS: Record<StartableAgentType, AgentConfig> = {\n claude: { command: 'claude', matches: matchArgv0('claude') },\n codex: { command: 'codex', matches: matchArgv0('codex') },\n copilot: { command: 'copilot', matches: matchArgv0Name('copilot-cli') },\n gemini_cli: { command: 'gemini', matches: matchAnyToken('gemini') },\n grok_cli: { command: 'grok', matches: matchArgv0('grok') },\n opencode: { command: 'opencode', matches: matchArgv0('opencode') },\n pi: { command: 'pi', matches: matchAnyBasename(['pi']) },\n};\n\nfunction matchArgv0(name: string): (psCommand: string) => boolean {\n const lower = name.toLowerCase();\n return (psCommand) => {\n const token = psCommand.trim().split(/\\s+/)[0];\n return token ? path.basename(token).toLowerCase() === lower : false;\n };\n}\n\nfunction matchArgv0Name(name: string): (psCommand: string) => boolean {\n const lower = name.toLowerCase();\n return (psCommand) => {\n const token = psCommand.trim().split(/\\s+/)[0];\n return token ? token.toLowerCase().includes(lower) : false;\n };\n}\n\nfunction matchAnyToken(name: string): (psCommand: string) => boolean {\n const lower = name.toLowerCase();\n return (psCommand) => {\n for (const token of psCommand.trim().split(/\\s+/)) {\n if (path.basename(token).toLowerCase() === lower) return true;\n }\n return false;\n };\n}\n\nfunction matchAnyBasename(names: string[]): (psCommand: string) => boolean {\n const lowers = new Set(names.map((name) => name.toLowerCase()));\n return (psCommand) => {\n for (const token of psCommand.trim().split(/\\s+/)) {\n if (lowers.has(path.basename(token).toLowerCase())) return true;\n }\n return false;\n };\n}\n"],"names":["path","AGENTS","claude","command","matches","matchArgv0","codex","copilot","matchArgv0Name","gemini_cli","matchAnyToken","grok_cli","opencode","pi","matchAnyBasename","name","lower","toLowerCase","psCommand","token","trim","split","basename","includes","names","lowers","Set","map","has"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AAYxB;;;;CAIC,GACD,OAAO,MAAMC,SAAkD;IAC3DC,QAAY;QAAEC,SAAS;QAAYC,SAASC,WAAW;IAAU;IACjEC,OAAY;QAAEH,SAAS;QAAYC,SAASC,WAAW;IAAS;IAChEE,SAAY;QAAEJ,SAAS;QAAYC,SAASI,eAAe;IAAe;IAC1EC,YAAY;QAAEN,SAAS;QAAYC,SAASM,cAAc;IAAU;IACpEC,UAAY;QAAER,SAAS;QAAYC,SAASC,WAAW;IAAQ;IAC/DO,UAAY;QAAET,SAAS;QAAYC,SAASC,WAAW;IAAY;IACnEQ,IAAY;QAAEV,SAAS;QAAYC,SAASU,iBAAiB;YAAC;SAAK;IAAE;AACzE,EAAE;AAEF,SAAST,WAAWU,IAAY;IAC5B,MAAMC,QAAQD,KAAKE,WAAW;IAC9B,OAAO,CAACC;QACJ,MAAMC,QAAQD,UAAUE,IAAI,GAAGC,KAAK,CAAC,MAAM,CAAC,EAAE;QAC9C,OAAOF,QAAQnB,KAAKsB,QAAQ,CAACH,OAAOF,WAAW,OAAOD,QAAQ;IAClE;AACJ;AAEA,SAASR,eAAeO,IAAY;IAChC,MAAMC,QAAQD,KAAKE,WAAW;IAC9B,OAAO,CAACC;QACJ,MAAMC,QAAQD,UAAUE,IAAI,GAAGC,KAAK,CAAC,MAAM,CAAC,EAAE;QAC9C,OAAOF,QAAQA,MAAMF,WAAW,GAAGM,QAAQ,CAACP,SAAS;IACzD;AACJ;AAEA,SAASN,cAAcK,IAAY;IAC/B,MAAMC,QAAQD,KAAKE,WAAW;IAC9B,OAAO,CAACC;QACJ,KAAK,MAAMC,SAASD,UAAUE,IAAI,GAAGC,KAAK,CAAC,OAAQ;YAC/C,IAAIrB,KAAKsB,QAAQ,CAACH,OAAOF,WAAW,OAAOD,OAAO,OAAO;QAC7D;QACA,OAAO;IACX;AACJ;AAEA,SAASF,iBAAiBU,KAAe;IACrC,MAAMC,SAAS,IAAIC,IAAIF,MAAMG,GAAG,CAAC,CAACZ,OAASA,KAAKE,WAAW;IAC3D,OAAO,CAACC;QACJ,KAAK,MAAMC,SAASD,UAAUE,IAAI,GAAGC,KAAK,CAAC,OAAQ;YAC/C,IAAII,OAAOG,GAAG,CAAC5B,KAAKsB,QAAQ,CAACH,OAAOF,WAAW,KAAK,OAAO;QAC/D;QACA,OAAO;IACX;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-devkit/agent-manager",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Standalone agent detection and management utilities for AI DevKit",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"directory": "packages/agent-manager"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"better-sqlite3": "
|
|
38
|
+
"better-sqlite3": "12.11.1",
|
|
39
39
|
"uuid": "14.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|