@ai-devkit/agent-manager 0.33.0 → 0.33.1
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/AgentManager.d.ts +11 -2
- package/dist/AgentManager.d.ts.map +1 -1
- package/dist/AgentManager.js +37 -6
- package/dist/AgentManager.js.map +1 -1
- package/dist/__tests__/AgentManager.test.js +212 -5
- package/dist/__tests__/AgentManager.test.js.map +1 -1
- package/dist/__tests__/adapters/OpenCodeAdapter.test.js +1 -0
- package/dist/__tests__/adapters/OpenCodeAdapter.test.js.map +1 -1
- package/dist/__tests__/{adapters → providers/copilot}/CopilotAdapter.test.js +19 -14
- package/dist/__tests__/providers/copilot/CopilotAdapter.test.js.map +1 -0
- package/dist/__tests__/{adapters → providers/gemini}/GeminiCliAdapter.test.js +37 -29
- package/dist/__tests__/providers/gemini/GeminiCliAdapter.test.js.map +1 -0
- package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js +164 -0
- package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js.map +1 -0
- package/dist/__tests__/runtime/HerdrAgentRuntime.test.js +37 -1
- package/dist/__tests__/runtime/HerdrAgentRuntime.test.js.map +1 -1
- package/dist/__tests__/utils/AgentRegistry.test.js +20 -13
- package/dist/__tests__/utils/AgentRegistry.test.js.map +1 -1
- package/dist/adapters/OpenCodeAdapter.d.ts +1 -0
- package/dist/adapters/OpenCodeAdapter.d.ts.map +1 -1
- package/dist/adapters/OpenCodeAdapter.js +7 -4
- package/dist/adapters/OpenCodeAdapter.js.map +1 -1
- package/dist/adapters/index.d.ts +2 -2
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +2 -2
- package/dist/adapters/index.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/{adapters → providers/copilot}/CopilotAdapter.d.ts +11 -25
- package/dist/providers/copilot/CopilotAdapter.d.ts.map +1 -0
- package/dist/providers/copilot/CopilotAdapter.js +108 -0
- package/dist/providers/copilot/CopilotAdapter.js.map +1 -0
- package/dist/providers/copilot/CopilotAgentMapper.d.ts +9 -0
- package/dist/providers/copilot/CopilotAgentMapper.d.ts.map +1 -0
- package/dist/providers/copilot/CopilotAgentMapper.js +37 -0
- package/dist/providers/copilot/CopilotAgentMapper.js.map +1 -0
- package/dist/providers/copilot/CopilotSessionLocator.d.ts +19 -0
- package/dist/providers/copilot/CopilotSessionLocator.d.ts.map +1 -0
- package/dist/providers/copilot/CopilotSessionLocator.js +41 -0
- package/dist/providers/copilot/CopilotSessionLocator.js.map +1 -0
- package/dist/providers/copilot/CopilotSessionParser.d.ts +30 -0
- package/dist/providers/copilot/CopilotSessionParser.d.ts.map +1 -0
- package/dist/providers/copilot/CopilotSessionParser.js +181 -0
- package/dist/providers/copilot/CopilotSessionParser.js.map +1 -0
- package/dist/providers/gemini/GeminiAgentMapper.d.ts +9 -0
- package/dist/providers/gemini/GeminiAgentMapper.d.ts.map +1 -0
- package/dist/providers/gemini/GeminiAgentMapper.js +37 -0
- package/dist/providers/gemini/GeminiAgentMapper.js.map +1 -0
- package/dist/providers/gemini/GeminiCliAdapter.d.ts +52 -0
- package/dist/providers/gemini/GeminiCliAdapter.d.ts.map +1 -0
- package/dist/providers/gemini/GeminiCliAdapter.js +188 -0
- package/dist/providers/gemini/GeminiCliAdapter.js.map +1 -0
- package/dist/providers/gemini/GeminiSessionLocator.d.ts +30 -0
- package/dist/providers/gemini/GeminiSessionLocator.d.ts.map +1 -0
- package/dist/providers/gemini/GeminiSessionLocator.js +142 -0
- package/dist/providers/gemini/GeminiSessionLocator.js.map +1 -0
- package/dist/providers/gemini/GeminiSessionParser.d.ts +94 -0
- package/dist/providers/gemini/GeminiSessionParser.d.ts.map +1 -0
- package/dist/providers/gemini/GeminiSessionParser.js +166 -0
- package/dist/providers/gemini/GeminiSessionParser.js.map +1 -0
- package/dist/runtime/herdr/HerdrAgentDiscovery.d.ts +18 -0
- package/dist/runtime/herdr/HerdrAgentDiscovery.d.ts.map +1 -0
- package/dist/runtime/herdr/HerdrAgentDiscovery.js +183 -0
- package/dist/runtime/herdr/HerdrAgentDiscovery.js.map +1 -0
- package/dist/runtime/herdr/HerdrAgentRuntime.d.ts +5 -0
- package/dist/runtime/herdr/HerdrAgentRuntime.d.ts.map +1 -1
- package/dist/runtime/herdr/HerdrAgentRuntime.js +26 -8
- package/dist/runtime/herdr/HerdrAgentRuntime.js.map +1 -1
- package/dist/runtime/herdr/HerdrResponseParsers.d.ts +2 -0
- package/dist/runtime/herdr/HerdrResponseParsers.d.ts.map +1 -1
- package/dist/runtime/herdr/HerdrResponseParsers.js +12 -1
- package/dist/runtime/herdr/HerdrResponseParsers.js.map +1 -1
- package/dist/utils/AgentRegistry.d.ts.map +1 -1
- package/dist/utils/AgentRegistry.js +5 -5
- package/dist/utils/AgentRegistry.js.map +1 -1
- package/package.json +1 -1
- package/src/AgentManager.ts +67 -5
- package/src/__tests__/AgentManager.test.ts +231 -5
- package/src/__tests__/adapters/OpenCodeAdapter.test.ts +1 -0
- package/src/__tests__/{adapters → providers/copilot}/CopilotAdapter.test.ts +13 -16
- package/src/__tests__/{adapters → providers/gemini}/GeminiCliAdapter.test.ts +39 -31
- package/src/__tests__/runtime/HerdrAgentDiscovery.test.ts +131 -0
- package/src/__tests__/runtime/HerdrAgentRuntime.test.ts +20 -1
- package/src/__tests__/utils/AgentRegistry.test.ts +20 -10
- package/src/adapters/OpenCodeAdapter.ts +8 -4
- package/src/adapters/index.ts +2 -2
- package/src/index.ts +10 -3
- package/src/providers/copilot/CopilotAdapter.ts +145 -0
- package/src/providers/copilot/CopilotAgentMapper.ts +36 -0
- package/src/providers/copilot/CopilotSessionLocator.ts +57 -0
- package/src/providers/copilot/CopilotSessionParser.ts +289 -0
- package/src/providers/gemini/GeminiAgentMapper.ts +36 -0
- package/src/providers/gemini/GeminiCliAdapter.ts +266 -0
- package/src/providers/gemini/GeminiSessionLocator.ts +183 -0
- package/src/providers/gemini/GeminiSessionParser.ts +271 -0
- package/src/runtime/herdr/HerdrAgentDiscovery.ts +178 -0
- package/src/runtime/herdr/HerdrAgentRuntime.ts +33 -7
- package/src/runtime/herdr/HerdrResponseParsers.ts +11 -1
- package/src/utils/AgentRegistry.ts +8 -6
- package/dist/__tests__/adapters/CopilotAdapter.test.js.map +0 -1
- package/dist/__tests__/adapters/GeminiCliAdapter.test.js.map +0 -1
- package/dist/adapters/CopilotAdapter.d.ts.map +0 -1
- package/dist/adapters/CopilotAdapter.js +0 -329
- package/dist/adapters/CopilotAdapter.js.map +0 -1
- package/dist/adapters/GeminiCliAdapter.d.ts +0 -98
- package/dist/adapters/GeminiCliAdapter.d.ts.map +0 -1
- package/dist/adapters/GeminiCliAdapter.js +0 -513
- package/dist/adapters/GeminiCliAdapter.js.map +0 -1
- package/src/adapters/CopilotAdapter.ts +0 -483
- package/src/adapters/GeminiCliAdapter.ts +0 -699
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/adapters/OpenCodeAdapter.ts"],"sourcesContent":["/**\n * OpenCode Adapter\n *\n * Detects running OpenCode agents by:\n * 1. Filtering OpenCode processes from a shared asynchronous process snapshot\n * 2. Using snapshot CWD and start-time enrichment\n * 3. Querying OpenCode's SQLite DB (~/.local/share/opencode/opencode.db) to\n * find the session matching each process's CWD and read status from message.time.completed\n *\n * sessionFilePath encodes \"<dbPath>::<sessionId>\" so getConversation() can open the right\n * DB row without extending the AgentAdapter interface.\n */\n\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport Database from \"better-sqlite3\";\nimport type {\n AgentAdapter,\n AgentInfo,\n ProcessInfo,\n ConversationMessage,\n SessionSummary,\n ListSessionsOptions,\n AgentDetectionContext,\n} from \"./AgentAdapter.js\";\nimport { AgentStatus } from \"./AgentAdapter.js\";\nimport {\n captureProcessSnapshot,\n executableBasename,\n filterByProcessNames,\n} from \"../utils/process.js\";\nimport { generateAgentName } from \"../utils/matching.js\";\n\nconst SESSION_REF_SEP = \"::\";\n\nfunction encodeSessionRef(dbPath: string, sessionId: string): string {\n return `${dbPath}${SESSION_REF_SEP}${sessionId}`;\n}\n\nfunction decodeSessionRef(ref: string): { dbPath: string; sessionId: string } | null {\n const idx = ref.lastIndexOf(SESSION_REF_SEP);\n if (idx === -1) return null;\n return { dbPath: ref.slice(0, idx), sessionId: ref.slice(idx + SESSION_REF_SEP.length) };\n}\n\ninterface OpenCodeSession {\n sessionId: string;\n directory: string;\n timeCreated: number;\n}\n\ninterface OpenCodeSessionStats {\n lastRole: string | null;\n lastTimeUpdated: number;\n /** OpenCode writes `time.completed` on the assistant message only when the turn finishes. */\n lastAssistantCompleted: boolean;\n lastAssistantErrored: boolean;\n summary: string;\n}\n\nexport class OpenCodeAdapter implements AgentAdapter {\n readonly type = \"opencode\" as const;\n readonly processNames = [\"opencode\"] as const;\n\n private static readonly IDLE_THRESHOLD_MINUTES = 5;\n\n private readonly dbPath: string;\n private db: Database.Database | null = null;\n\n constructor() {\n this.dbPath = OpenCodeAdapter.resolveDbPath();\n const cleanup = (): void => this.close();\n process.once(\"exit\", cleanup);\n process.once(\"SIGINT\", cleanup);\n process.once(\"SIGTERM\", cleanup);\n }\n\n close(): void {\n if (this.db) {\n try {\n this.db.close();\n } catch {\n /* ignore */\n }\n this.db = null;\n }\n }\n\n private static resolveDbPath(): string {\n const xdg = process.env.XDG_DATA_HOME;\n const home = process.env.HOME || process.env.USERPROFILE || \"\";\n const base = xdg || path.join(home, \".local\", \"share\");\n return path.join(base, \"opencode\", \"opencode.db\");\n }\n\n canHandle(processInfo: ProcessInfo): boolean {\n const base = executableBasename(processInfo.command);\n return base === \"opencode\" || base === \"opencode.exe\";\n }\n\n async detectAgents(context?: AgentDetectionContext): Promise<AgentInfo[]> {\n const snapshot = context?.processes ?? (await captureProcessSnapshot(this.processNames));\n const relevant = filterByProcessNames(snapshot, this.processNames);\n const processes = relevant.filter((process) => this.canHandle(process));\n if (processes.length === 0) return [];\n\n const db = this.openDb();\n if (!db) return processes.map((p) => this.mapProcessOnlyAgent(p));\n\n const agents: AgentInfo[] = [];\n for (const proc of processes) {\n if (!proc.cwd) {\n agents.push(this.mapProcessOnlyAgent(proc));\n continue;\n }\n\n const session = this.findSessionForDirectory(db, proc.cwd);\n if (!session) {\n agents.push(this.mapProcessOnlyAgent(proc));\n continue;\n }\n\n const stats = this.getSessionStats(db, session.sessionId);\n agents.push(this.mapSessionToAgent(session, stats, proc));\n }\n\n return agents;\n }\n\n getConversation(sessionFilePath: string, options?: { verbose?: boolean }): ConversationMessage[] {\n const verbose = options?.verbose ?? false;\n const ref = decodeSessionRef(sessionFilePath);\n if (!ref) return [];\n\n const db = this.openDb();\n if (!db) return [];\n\n try {\n const rows = db\n .prepare<[string], { role: string; partData: string; timeCreated: number }>(`\n SELECT json_extract(m.data, '$.role') AS role,\n p.data AS partData,\n p.time_created AS timeCreated\n FROM part p\n JOIN message m ON p.message_id = m.id\n WHERE p.session_id = ?\n ORDER BY p.time_created ASC\n `)\n .all(ref.sessionId);\n\n const messages: ConversationMessage[] = [];\n\n for (const row of rows) {\n let partData: { type?: string; text?: string; reasoning?: string; tool?: string } = {};\n try {\n partData = JSON.parse(row.partData);\n } catch {\n continue;\n }\n\n const role = row.role === \"user\" ? \"user\" : \"assistant\";\n\n if (partData.type === \"text\" && partData.text) {\n messages.push({ role, content: partData.text });\n } else if (partData.type === \"reasoning\" && verbose) {\n const text = partData.reasoning || partData.text || \"\";\n if (text) messages.push({ role: \"assistant\", content: `[thinking] ${text}` });\n } else if (partData.type === \"tool\" && verbose) {\n const toolName = partData.tool || \"tool\";\n messages.push({ role: \"assistant\", content: `[tool: ${toolName}]` });\n }\n }\n\n return messages;\n } catch {\n this.close();\n return [];\n }\n }\n\n async listSessions(opts?: ListSessionsOptions): Promise<SessionSummary[]> {\n const db = this.openDb();\n if (!db) return [];\n\n try {\n const rows = db\n .prepare<[], { id: string; directory: string; timeCreated: number }>(`\n SELECT id, directory, time_created AS timeCreated\n FROM session\n ORDER BY time_created DESC\n `)\n .all();\n\n const summaries: SessionSummary[] = [];\n\n for (const row of rows) {\n if (opts?.cwd !== undefined && row.directory !== opts.cwd) continue;\n\n const stats = this.getSessionStats(db, row.id);\n const lastActive =\n stats.lastTimeUpdated > 0 ? new Date(stats.lastTimeUpdated) : new Date(row.timeCreated);\n const startedAt = new Date(row.timeCreated);\n\n summaries.push({\n type: \"opencode\",\n sessionId: row.id,\n cwd: row.directory,\n firstUserMessage: stats.summary,\n lastActive,\n startedAt,\n sessionFilePath: encodeSessionRef(this.dbPath, row.id),\n });\n }\n\n return summaries;\n } catch {\n this.close();\n return [];\n }\n }\n\n private findSessionForDirectory(\n db: Database.Database,\n directory: string,\n ): OpenCodeSession | null {\n try {\n const row = db\n .prepare<[string], { id: string; directory: string; time_created: number }>(`\n SELECT id, directory, time_created\n FROM session\n WHERE directory = ?\n ORDER BY time_created DESC\n LIMIT 1\n `)\n .get(directory);\n\n if (!row) return null;\n return { sessionId: row.id, directory: row.directory, timeCreated: row.time_created };\n } catch {\n return null;\n }\n }\n\n private getSessionStats(db: Database.Database, sessionId: string): OpenCodeSessionStats {\n const empty: OpenCodeSessionStats = {\n lastRole: null,\n lastTimeUpdated: 0,\n lastAssistantCompleted: false,\n lastAssistantErrored: false,\n summary: \"\",\n };\n\n try {\n // Order by time_created — time_updated can lag when OpenCode appends\n // metadata (e.g. summary diffs) to user messages after a turn finishes.\n const last = db\n .prepare<[string], { role: string; timeUpdated: number }>(`\n SELECT json_extract(data, '$.role') AS role,\n time_updated AS timeUpdated\n FROM message\n WHERE session_id = ?\n ORDER BY time_created DESC\n LIMIT 1\n `)\n .get(sessionId);\n\n const heartbeat = db\n .prepare<[string], { maxUpdated: number }>(`\n SELECT MAX(time_updated) AS maxUpdated FROM message WHERE session_id = ?\n `)\n .get(sessionId);\n\n const lastAssistant = db\n .prepare<\n [string],\n {\n completed: number | null;\n errored: number | null;\n }\n >(`\n SELECT json_extract(data, '$.time.completed') AS completed,\n json_extract(data, '$.time.error') AS errored\n FROM message\n WHERE session_id = ? AND json_extract(data, '$.role') = 'assistant'\n ORDER BY time_created DESC\n LIMIT 1\n `)\n .get(sessionId);\n\n const first = db\n .prepare<[string], { text: string }>(`\n SELECT json_extract(p.data, '$.text') AS text\n FROM part p\n JOIN message m ON p.message_id = m.id\n WHERE p.session_id = ?\n AND json_extract(m.data, '$.role') = 'user'\n AND json_extract(p.data, '$.type') = 'text'\n AND json_extract(p.data, '$.text') IS NOT NULL\n ORDER BY p.time_created ASC\n LIMIT 1\n `)\n .get(sessionId);\n\n return {\n lastRole: last?.role ?? null,\n lastTimeUpdated: heartbeat?.maxUpdated ?? last?.timeUpdated ?? 0,\n lastAssistantCompleted: lastAssistant?.completed != null,\n lastAssistantErrored: lastAssistant?.errored != null,\n summary: first?.text?.trim() ?? \"\",\n };\n } catch {\n return empty;\n }\n }\n\n private mapSessionToAgent(\n session: OpenCodeSession,\n stats: OpenCodeSessionStats,\n proc: ProcessInfo,\n ): AgentInfo {\n const lastActive =\n stats.lastTimeUpdated > 0 ? new Date(stats.lastTimeUpdated) : new Date(session.timeCreated);\n\n return {\n name: generateAgentName(session.directory || proc.cwd || \"\", proc.pid),\n type: this.type,\n status: this.determineStatus(stats, lastActive),\n summary: stats.summary || \"OpenCode session active\",\n pid: proc.pid,\n projectPath: session.directory || proc.cwd || \"\",\n sessionId: session.sessionId,\n lastActive,\n sessionFilePath: encodeSessionRef(this.dbPath, session.sessionId),\n };\n }\n\n private mapProcessOnlyAgent(proc: ProcessInfo): AgentInfo {\n return {\n name: generateAgentName(proc.cwd || \"\", proc.pid),\n type: this.type,\n status: AgentStatus.RUNNING,\n summary: \"OpenCode process running\",\n pid: proc.pid,\n projectPath: proc.cwd || \"\",\n sessionId: `pid-${proc.pid}`,\n lastActive: new Date(),\n };\n }\n\n private determineStatus(stats: OpenCodeSessionStats, lastActive: Date): AgentStatus {\n const ageMin = (Date.now() - lastActive.getTime()) / 60000;\n if (ageMin > OpenCodeAdapter.IDLE_THRESHOLD_MINUTES) return AgentStatus.IDLE;\n\n if (stats.lastRole === \"assistant\" && !stats.lastAssistantCompleted) return AgentStatus.RUNNING;\n if (stats.lastRole === \"assistant\") return AgentStatus.WAITING;\n return AgentStatus.RUNNING;\n }\n\n private openDb(): Database.Database | null {\n if (this.db) return this.db;\n if (!fs.existsSync(this.dbPath)) return null;\n try {\n this.db = new Database(this.dbPath, { readonly: true });\n return this.db;\n } catch {\n return null;\n }\n }\n}\n"],"names":["fs","path","Database","AgentStatus","captureProcessSnapshot","executableBasename","filterByProcessNames","generateAgentName","SESSION_REF_SEP","encodeSessionRef","dbPath","sessionId","decodeSessionRef","ref","idx","lastIndexOf","slice","length","OpenCodeAdapter","type","processNames","IDLE_THRESHOLD_MINUTES","db","resolveDbPath","cleanup","close","process","once","xdg","env","XDG_DATA_HOME","home","HOME","USERPROFILE","base","join","canHandle","processInfo","command","detectAgents","context","snapshot","processes","relevant","filter","openDb","map","p","mapProcessOnlyAgent","agents","proc","cwd","push","session","findSessionForDirectory","stats","getSessionStats","mapSessionToAgent","getConversation","sessionFilePath","options","verbose","rows","prepare","all","messages","row","partData","JSON","parse","role","text","content","reasoning","toolName","tool","listSessions","opts","summaries","undefined","directory","id","lastActive","lastTimeUpdated","Date","timeCreated","startedAt","firstUserMessage","summary","get","time_created","empty","lastRole","lastAssistantCompleted","lastAssistantErrored","last","heartbeat","lastAssistant","first","maxUpdated","timeUpdated","completed","errored","trim","name","pid","status","determineStatus","projectPath","RUNNING","ageMin","now","getTime","IDLE","WAITING","existsSync","readonly"],"mappings":"AAAA;;;;;;;;;;;CAWC,GAED,YAAYA,QAAQ,KAAK;AACzB,YAAYC,UAAU,OAAO;AAC7B,OAAOC,cAAc,iBAAiB;AAUtC,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SACEC,sBAAsB,EACtBC,kBAAkB,EAClBC,oBAAoB,QACf,sBAAsB;AAC7B,SAASC,iBAAiB,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AAY0G,OAAO;YAC3BrB,SAAS;YACTiB,KAAKvD,KAAKuD,GAAG;YACbG,aAAa1D,KAAKC,GAAG,IAAI;YACzBxC,WAAW,CAAC,IAAI,EAAEuC,KAAKuD,GAAG,EAAE;YAC5BvB,YAAY,IAAIE;QAClB;IACF;IAEQuB,gBAAgBpD,KAA2B,EAAE2B,UAAgB,EAAe;QAClF,MAAM4B,SAAS,AAAC1B,CAAAA,KAAK2B,GAAG,KAAK7B,WAAW8B,OAAO,EAAC,IAAK;QACrD,IAAIF,SAAS5F,gBAAgBG,sBAAsB,EAAE,OAAOlB,YAAY8G,IAAI;QAE5E,IAAI1D,MAAMqC,QAAQ,KAAK,eAAe,CAACrC,MAAMsC,sBAAsB,EAAE,OAAO1F,YAAY0G,OAAO;QAC/F,IAAItD,MAAMqC,QAAQ,KAAK,aAAa,OAAOzF,YAAY+G,OAAO;QAC9D,OAAO/G,YAAY0G,OAAO;IAC5B;IAEQhE,SAAmC;QACzC,IAAI,IAAI,CAACvB,EAAE,EAAE,OAAO,IAAI,CAACA,EAAE;QAC3B,IAAI,CAACtB,GAAGmH,UAAU,CAAC,IAAI,CAACzG,MAAM,GAAG,OAAO;QACxC,IAAI;YACF,IAAI,CAACY,EAAE,GAAG,IAAIpB,SAAS,IAAI,CAACQ,MAAM,EAAE;gBAAE0G,UAAU;YAAK;YACrD,OAAO,IAAI,CAAC9F,EAAE;QAChB,EAAE,OAAM;YACN,OAAO;QACT;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/OpenCodeAdapter.ts"],"sourcesContent":["/**\n * OpenCode Adapter\n *\n * Detects running OpenCode agents by:\n * 1. Filtering OpenCode processes from a shared asynchronous process snapshot\n * 2. Using snapshot CWD and start-time enrichment\n * 3. Querying OpenCode's SQLite DB (~/.local/share/opencode/opencode.db) to\n * find the session matching each process's CWD and read status from message.time.completed\n *\n * sessionFilePath encodes \"<dbPath>::<sessionId>\" so getConversation() can open the right\n * DB row without extending the AgentAdapter interface.\n */\n\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport Database from \"better-sqlite3\";\nimport type {\n AgentAdapter,\n AgentInfo,\n ProcessInfo,\n ConversationMessage,\n SessionSummary,\n ListSessionsOptions,\n AgentDetectionContext,\n} from \"./AgentAdapter.js\";\nimport { AgentStatus } from \"./AgentAdapter.js\";\nimport {\n captureProcessSnapshot,\n executableBasename,\n filterByProcessNames,\n} from \"../utils/process.js\";\nimport { generateAgentName } from \"../utils/matching.js\";\n\nconst SESSION_REF_SEP = \"::\";\n\nfunction encodeSessionRef(dbPath: string, sessionId: string): string {\n return `${dbPath}${SESSION_REF_SEP}${sessionId}`;\n}\n\nfunction decodeSessionRef(ref: string): { dbPath: string; sessionId: string } | null {\n const idx = ref.lastIndexOf(SESSION_REF_SEP);\n if (idx === -1) return null;\n return { dbPath: ref.slice(0, idx), sessionId: ref.slice(idx + SESSION_REF_SEP.length) };\n}\n\ninterface OpenCodeSession {\n sessionId: string;\n directory: string;\n timeCreated: number;\n}\n\ninterface OpenCodeSessionStats {\n lastRole: string | null;\n lastTimeUpdated: number;\n /** OpenCode writes `time.completed` on the assistant message only when the turn finishes. */\n lastAssistantCompleted: boolean;\n lastAssistantErrored: boolean;\n summary: string;\n}\n\nexport class OpenCodeAdapter implements AgentAdapter {\n readonly type = \"opencode\" as const;\n readonly processNames = [\"opencode\"] as const;\n\n private static readonly IDLE_THRESHOLD_MINUTES = 5;\n\n private readonly dbPath: string;\n private readonly cleanup = (): void => this.close();\n private db: Database.Database | null = null;\n\n constructor() {\n this.dbPath = OpenCodeAdapter.resolveDbPath();\n process.once(\"exit\", this.cleanup);\n process.once(\"SIGINT\", this.cleanup);\n process.once(\"SIGTERM\", this.cleanup);\n }\n\n close(): void {\n process.off(\"exit\", this.cleanup);\n process.off(\"SIGINT\", this.cleanup);\n process.off(\"SIGTERM\", this.cleanup);\n\n if (this.db) {\n try {\n this.db.close();\n } catch {\n /* ignore */\n }\n this.db = null;\n }\n }\n\n private static resolveDbPath(): string {\n const xdg = process.env.XDG_DATA_HOME;\n const home = process.env.HOME || process.env.USERPROFILE || \"\";\n const base = xdg || path.join(home, \".local\", \"share\");\n return path.join(base, \"opencode\", \"opencode.db\");\n }\n\n canHandle(processInfo: ProcessInfo): boolean {\n const base = executableBasename(processInfo.command);\n return base === \"opencode\" || base === \"opencode.exe\";\n }\n\n async detectAgents(context?: AgentDetectionContext): Promise<AgentInfo[]> {\n const snapshot = context?.processes ?? (await captureProcessSnapshot(this.processNames));\n const relevant = filterByProcessNames(snapshot, this.processNames);\n const processes = relevant.filter((process) => this.canHandle(process));\n if (processes.length === 0) return [];\n\n const db = this.openDb();\n if (!db) return processes.map((p) => this.mapProcessOnlyAgent(p));\n\n const agents: AgentInfo[] = [];\n for (const proc of processes) {\n if (!proc.cwd) {\n agents.push(this.mapProcessOnlyAgent(proc));\n continue;\n }\n\n const session = this.findSessionForDirectory(db, proc.cwd);\n if (!session) {\n agents.push(this.mapProcessOnlyAgent(proc));\n continue;\n }\n\n const stats = this.getSessionStats(db, session.sessionId);\n agents.push(this.mapSessionToAgent(session, stats, proc));\n }\n\n return agents;\n }\n\n getConversation(sessionFilePath: string, options?: { verbose?: boolean }): ConversationMessage[] {\n const verbose = options?.verbose ?? false;\n const ref = decodeSessionRef(sessionFilePath);\n if (!ref) return [];\n\n const db = this.openDb();\n if (!db) return [];\n\n try {\n const rows = db\n .prepare<[string], { role: string; partData: string; timeCreated: number }>(`\n SELECT json_extract(m.data, '$.role') AS role,\n p.data AS partData,\n p.time_created AS timeCreated\n FROM part p\n JOIN message m ON p.message_id = m.id\n WHERE p.session_id = ?\n ORDER BY p.time_created ASC\n `)\n .all(ref.sessionId);\n\n const messages: ConversationMessage[] = [];\n\n for (const row of rows) {\n let partData: { type?: string; text?: string; reasoning?: string; tool?: string } = {};\n try {\n partData = JSON.parse(row.partData);\n } catch {\n continue;\n }\n\n const role = row.role === \"user\" ? \"user\" : \"assistant\";\n\n if (partData.type === \"text\" && partData.text) {\n messages.push({ role, content: partData.text });\n } else if (partData.type === \"reasoning\" && verbose) {\n const text = partData.reasoning || partData.text || \"\";\n if (text) messages.push({ role: \"assistant\", content: `[thinking] ${text}` });\n } else if (partData.type === \"tool\" && verbose) {\n const toolName = partData.tool || \"tool\";\n messages.push({ role: \"assistant\", content: `[tool: ${toolName}]` });\n }\n }\n\n return messages;\n } catch {\n this.close();\n return [];\n }\n }\n\n async listSessions(opts?: ListSessionsOptions): Promise<SessionSummary[]> {\n const db = this.openDb();\n if (!db) return [];\n\n try {\n const rows = db\n .prepare<[], { id: string; directory: string; timeCreated: number }>(`\n SELECT id, directory, time_created AS timeCreated\n FROM session\n ORDER BY time_created DESC\n `)\n .all();\n\n const summaries: SessionSummary[] = [];\n\n for (const row of rows) {\n if (opts?.cwd !== undefined && row.directory !== opts.cwd) continue;\n\n const stats = this.getSessionStats(db, row.id);\n const lastActive =\n stats.lastTimeUpdated > 0 ? new Date(stats.lastTimeUpdated) : new Date(row.timeCreated);\n const startedAt = new Date(row.timeCreated);\n\n summaries.push({\n type: \"opencode\",\n sessionId: row.id,\n cwd: row.directory,\n firstUserMessage: stats.summary,\n lastActive,\n startedAt,\n sessionFilePath: encodeSessionRef(this.dbPath, row.id),\n });\n }\n\n return summaries;\n } catch {\n this.close();\n return [];\n }\n }\n\n private findSessionForDirectory(\n db: Database.Database,\n directory: string,\n ): OpenCodeSession | null {\n try {\n const row = db\n .prepare<[string], { id: string; directory: string; time_created: number }>(`\n SELECT id, directory, time_created\n FROM session\n WHERE directory = ?\n ORDER BY time_created DESC\n LIMIT 1\n `)\n .get(directory);\n\n if (!row) return null;\n return { sessionId: row.id, directory: row.directory, timeCreated: row.time_created };\n } catch {\n return null;\n }\n }\n\n private getSessionStats(db: Database.Database, sessionId: string): OpenCodeSessionStats {\n const empty: OpenCodeSessionStats = {\n lastRole: null,\n lastTimeUpdated: 0,\n lastAssistantCompleted: false,\n lastAssistantErrored: false,\n summary: \"\",\n };\n\n try {\n // Order by time_created — time_updated can lag when OpenCode appends\n // metadata (e.g. summary diffs) to user messages after a turn finishes.\n const last = db\n .prepare<[string], { role: string; timeUpdated: number }>(`\n SELECT json_extract(data, '$.role') AS role,\n time_updated AS timeUpdated\n FROM message\n WHERE session_id = ?\n ORDER BY time_created DESC\n LIMIT 1\n `)\n .get(sessionId);\n\n const heartbeat = db\n .prepare<[string], { maxUpdated: number }>(`\n SELECT MAX(time_updated) AS maxUpdated FROM message WHERE session_id = ?\n `)\n .get(sessionId);\n\n const lastAssistant = db\n .prepare<\n [string],\n {\n completed: number | null;\n errored: number | null;\n }\n >(`\n SELECT json_extract(data, '$.time.completed') AS completed,\n json_extract(data, '$.time.error') AS errored\n FROM message\n WHERE session_id = ? AND json_extract(data, '$.role') = 'assistant'\n ORDER BY time_created DESC\n LIMIT 1\n `)\n .get(sessionId);\n\n const first = db\n .prepare<[string], { text: string }>(`\n SELECT json_extract(p.data, '$.text') AS text\n FROM part p\n JOIN message m ON p.message_id = m.id\n WHERE p.session_id = ?\n AND json_extract(m.data, '$.role') = 'user'\n AND json_extract(p.data, '$.type') = 'text'\n AND json_extract(p.data, '$.text') IS NOT NULL\n ORDER BY p.time_created ASC\n LIMIT 1\n `)\n .get(sessionId);\n\n return {\n lastRole: last?.role ?? null,\n lastTimeUpdated: heartbeat?.maxUpdated ?? last?.timeUpdated ?? 0,\n lastAssistantCompleted: lastAssistant?.completed != null,\n lastAssistantErrored: lastAssistant?.errored != null,\n summary: first?.text?.trim() ?? \"\",\n };\n } catch {\n return empty;\n }\n }\n\n private mapSessionToAgent(\n session: OpenCodeSession,\n stats: OpenCodeSessionStats,\n proc: ProcessInfo,\n ): AgentInfo {\n const lastActive =\n stats.lastTimeUpdated > 0 ? new Date(stats.lastTimeUpdated) : new Date(session.timeCreated);\n\n return {\n name: generateAgentName(session.directory || proc.cwd || \"\", proc.pid),\n type: this.type,\n status: this.determineStatus(stats, lastActive),\n summary: stats.summary || \"OpenCode session active\",\n pid: proc.pid,\n projectPath: session.directory || proc.cwd || \"\",\n sessionId: session.sessionId,\n lastActive,\n sessionFilePath: encodeSessionRef(this.dbPath, session.sessionId),\n };\n }\n\n private mapProcessOnlyAgent(proc: ProcessInfo): AgentInfo {\n return {\n name: generateAgentName(proc.cwd || \"\", proc.pid),\n type: this.type,\n status: AgentStatus.RUNNING,\n summary: \"OpenCode process running\",\n pid: proc.pid,\n projectPath: proc.cwd || \"\",\n sessionId: `pid-${proc.pid}`,\n lastActive: new Date(),\n };\n }\n\n private determineStatus(stats: OpenCodeSessionStats, lastActive: Date): AgentStatus {\n const ageMin = (Date.now() - lastActive.getTime()) / 60000;\n if (ageMin > OpenCodeAdapter.IDLE_THRESHOLD_MINUTES) return AgentStatus.IDLE;\n\n if (stats.lastRole === \"assistant\" && !stats.lastAssistantCompleted) return AgentStatus.RUNNING;\n if (stats.lastRole === \"assistant\") return AgentStatus.WAITING;\n return AgentStatus.RUNNING;\n }\n\n private openDb(): Database.Database | null {\n if (this.db) return this.db;\n if (!fs.existsSync(this.dbPath)) return null;\n try {\n this.db = new Database(this.dbPath, { readonly: true });\n return this.db;\n } catch {\n return null;\n }\n }\n}\n"],"names":["fs","path","Database","AgentStatus","captureProcessSnapshot","executableBasename","filterByProcessNames","generateAgentName","SESSION_REF_SEP","encodeSessionRef","dbPath","sessionId","decodeSessionRef","ref","idx","lastIndexOf","slice","length","OpenCodeAdapter","type","processNames","IDLE_THRESHOLD_MINUTES","cleanup","close","db","resolveDbPath","process","once","off","xdg","env","XDG_DATA_HOME","home","HOME","USERPROFILE","base","join","canHandle","processInfo","command","detectAgents","context","snapshot","processes","relevant","filter","openDb","map","p","mapProcessOnlyAgent","agents","proc","cwd","push","session","findSessionForDirectory","stats","getSessionStats","mapSessionToAgent","getConversation","sessionFilePath","options","verbose","rows","prepare","all","messages","row","partData","JSON","parse","role","text","content","reasoning","toolName","tool","listSessions","opts","summaries","undefined","directory","id","lastActive","lastTimeUpdated","Date","timeCreated","startedAt","firstUserMessage","summary","get","time_created","empty","lastRole","lastAssistantCompleted","lastAssistantErrored","last","heartbeat","lastAssistant","first","maxUpdated","timeUpdated","completed","errored","trim","name","pid","status","determineStatus","projectPath","RUNNING","ageMin","now","getTime","IDLE","WAITING","existsSync","readonly"],"mappings":"AAAA;;;;;;;;;;;CAWC,GAED,YAAYA,QAAQ,KAAK;AACzB,YAAYC,UAAU,OAAO;AAC7B,OAAOC,cAAc,iBAAiB;AAUtC,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SACEC,sBAAsB,EACtBC,kBAAkB,EAClBC,oBAAoB,QACf,sBAAsB;AAC7B,SAASC,iBAAiB,QAAQ,uBAAuB;AAEzD,MAAMC,kBAAkB;AAExB,SAASC,iBAAiBC,MAAc,EAAEC,SAAiB;IACzD,OAAO,GAAGD,SAASF,kBAAkBG,WAAW;AAClD;AAEA,SAASC,iBAAiBC,GAAW;IACnC,MAAMC,MAAMD,IAAIE,WAAW,CAACP;IAC5B,IAAIM,QAAQ,CAAC,GAAG,OAAO;IACvB,OAAO;QAAEJ,QAAQG,IAAIG,KAAK,CAAC,GAAGF;QAAMH,WAAWE,IAAIG,KAAK,CAACF,MAAMN,gBAAgBS,MAAM;IAAE;AACzF;AAiBA,OAAO,MAAMC;IACFC,OAAO,WAAoB;IAC3BC,eAAe;QAAC;KAAW,CAAU;IAE9C,OAAwBC,yBAAyB,EAAE;IAElCX,OAAe;IACfY,UAAU,IAAY,IAAI,CAACC,KAAK,GAAG;IAC5CC,KAA+B,KAAK;IAE5C,aAAc;QACZ,IAAI,CAACd,MAAM,GAAGQ,gBAAgBO,aAAa;QAC3CC,QAAQC,IAAI,CAAC,QAAQ,IAAI,CAACL,OAAO;QACjCI,QAAQC,IAAI,CAAC,UAAU,IAAI,CAACL,OAAO;QACnCI,QAAQC,IAAI,CAAC,WAAW,IAAI,CAACL,OAAO;IACtC;IAEAC,QAAc;QACZG,QAAQE,GAAG,CAAC,QAAQ,IAAI,CAACN,OAAO;QAChCI,QAAQE,GAAG,CAAC,UAAU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EAAE;QAC3B,IAAI,CAACxB,GAAGoH,UAAU,CAAC,IAAI,CAAC1G,MAAM,GAAG,OAAO;QACxC,IAAI;YACF,IAAI,CAACc,EAAE,GAAG,IAAItB,SAAS,IAAI,CAACQ,MAAM,EAAE;gBAAE2G,UAAU;YAAK;YACrD,OAAO,IAAI,CAAC7F,EAAE;QAChB,EAAE,OAAM;YACN,OAAO;QACT;IACF;AACF"}
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { ClaudeCodeAdapter } from "../providers/claude/ClaudeCodeAdapter.js";
|
|
2
2
|
export { CodexAdapter } from "../providers/codex/CodexAdapter.js";
|
|
3
|
-
export { CopilotAdapter } from "
|
|
4
|
-
export { GeminiCliAdapter } from "
|
|
3
|
+
export { CopilotAdapter } from "../providers/copilot/CopilotAdapter.js";
|
|
4
|
+
export { GeminiCliAdapter } from "../providers/gemini/GeminiCliAdapter.js";
|
|
5
5
|
export { GrokCliAdapter } from "./GrokCliAdapter.js";
|
|
6
6
|
export { OpenCodeAdapter } from "./OpenCodeAdapter.js";
|
|
7
7
|
export { PiAdapter } from "../providers/pi/PiAdapter.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EACT,WAAW,EACX,qBAAqB,GACtB,MAAM,mBAAmB,CAAC"}
|
package/dist/adapters/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { ClaudeCodeAdapter } from "../providers/claude/ClaudeCodeAdapter.js";
|
|
2
2
|
export { CodexAdapter } from "../providers/codex/CodexAdapter.js";
|
|
3
|
-
export { CopilotAdapter } from "
|
|
4
|
-
export { GeminiCliAdapter } from "
|
|
3
|
+
export { CopilotAdapter } from "../providers/copilot/CopilotAdapter.js";
|
|
4
|
+
export { GeminiCliAdapter } from "../providers/gemini/GeminiCliAdapter.js";
|
|
5
5
|
export { GrokCliAdapter } from "./GrokCliAdapter.js";
|
|
6
6
|
export { OpenCodeAdapter } from "./OpenCodeAdapter.js";
|
|
7
7
|
export { PiAdapter } from "../providers/pi/PiAdapter.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/adapters/index.ts"],"sourcesContent":["export { ClaudeCodeAdapter } from \"../providers/claude/ClaudeCodeAdapter.js\";\nexport { CodexAdapter } from \"../providers/codex/CodexAdapter.js\";\nexport { CopilotAdapter } from \"
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/index.ts"],"sourcesContent":["export { ClaudeCodeAdapter } from \"../providers/claude/ClaudeCodeAdapter.js\";\nexport { CodexAdapter } from \"../providers/codex/CodexAdapter.js\";\nexport { CopilotAdapter } from \"../providers/copilot/CopilotAdapter.js\";\nexport { GeminiCliAdapter } from \"../providers/gemini/GeminiCliAdapter.js\";\nexport { GrokCliAdapter } from \"./GrokCliAdapter.js\";\nexport { OpenCodeAdapter } from \"./OpenCodeAdapter.js\";\nexport { PiAdapter } from \"../providers/pi/PiAdapter.js\";\nexport { AgentStatus } from \"./AgentAdapter.js\";\nexport type {\n AgentAdapter,\n AgentType,\n AgentInfo,\n ProcessInfo,\n AgentDetectionContext,\n} from \"./AgentAdapter.js\";\n"],"names":["ClaudeCodeAdapter","CodexAdapter","CopilotAdapter","GeminiCliAdapter","GrokCliAdapter","OpenCodeAdapter","PiAdapter","AgentStatus"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,2CAA2C;AAC7E,SAASC,YAAY,QAAQ,qCAAqC;AAClE,SAASC,cAAc,QAAQ,yCAAyC;AACxE,SAASC,gBAAgB,QAAQ,0CAA0C;AAC3E,SAASC,cAAc,QAAQ,sBAAsB;AACrD,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,SAAS,QAAQ,+BAA+B;AACzD,SAASC,WAAW,QAAQ,oBAAoB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export { getAgentReadinessReport, getAgentReadinessReports, worstReadinessStatus
|
|
|
5
5
|
export type { AgentReadinessOptions, AgentReadinessReport, AuthReadinessCheck, BuiltInSkillsReadinessCheck, DirectoryReadinessCheck, ExecutableReadinessCheck, IntegrationReadinessCheck, ReadinessAgentType, ReadinessAuthState, ReadinessCheck, ReadinessStatus, } from "./readiness/AgentReadiness.js";
|
|
6
6
|
export { ClaudeCodeAdapter } from "./providers/claude/ClaudeCodeAdapter.js";
|
|
7
7
|
export { CodexAdapter } from "./providers/codex/CodexAdapter.js";
|
|
8
|
-
export { CopilotAdapter } from "./
|
|
9
|
-
export { GeminiCliAdapter } from "./
|
|
8
|
+
export { CopilotAdapter } from "./providers/copilot/CopilotAdapter.js";
|
|
9
|
+
export { GeminiCliAdapter } from "./providers/gemini/GeminiCliAdapter.js";
|
|
10
10
|
export { GrokCliAdapter } from "./adapters/GrokCliAdapter.js";
|
|
11
11
|
export { OpenCodeAdapter } from "./adapters/OpenCodeAdapter.js";
|
|
12
12
|
export { PiAdapter } from "./providers/pi/PiAdapter.js";
|
|
@@ -15,7 +15,9 @@ export type { AgentAdapter, AgentType, AgentInfo, ProcessInfo, ConversationMessa
|
|
|
15
15
|
export { TerminalFocusManager, TerminalType } from "./terminal/TerminalFocusManager.js";
|
|
16
16
|
export type { TerminalLocation } from "./terminal/TerminalFocusManager.js";
|
|
17
17
|
export { TtyWriter } from "./terminal/TtyWriter.js";
|
|
18
|
-
export type { ListAgentsOptions } from "./AgentManager.js";
|
|
18
|
+
export type { AgentManagerOptions, ListAgentsOptions } from "./AgentManager.js";
|
|
19
|
+
export { extractHerdrAgentPanes, fetchHerdrAgentPanes, findMatchingHerdrPane, herdrPaneToRuntimeRef, } from "./runtime/herdr/HerdrAgentDiscovery.js";
|
|
20
|
+
export type { HerdrAgentPane } from "./runtime/herdr/HerdrAgentDiscovery.js";
|
|
19
21
|
export { AgentRegistry, RenameNotFoundError, RenameConflictError, AGENT_RUNTIME_PROVIDERS, parseTmuxRuntimeRef, } from "./utils/AgentRegistry.js";
|
|
20
22
|
export type { AgentRegistryOptions, RegistryEntry, AgentRuntimeProvider, TmuxRuntimeRef, } from "./utils/AgentRegistry.js";
|
|
21
23
|
export { TmuxManager } from "./terminal/TmuxManager.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,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChG,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EACV,qB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AAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAClE,YAAY,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,YAAY,EACV,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAC;AACpF,YAAY,EACV,0BAA0B,EAC1B,iBAAiB,GAClB,MAAM,+CAA+C,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,14 +3,15 @@ export { getCodexCapacityReport } from "./capacity/index.js";
|
|
|
3
3
|
export { getAgentReadinessReport, getAgentReadinessReports, worstReadinessStatus } from "./readiness/AgentReadiness.js";
|
|
4
4
|
export { ClaudeCodeAdapter } from "./providers/claude/ClaudeCodeAdapter.js";
|
|
5
5
|
export { CodexAdapter } from "./providers/codex/CodexAdapter.js";
|
|
6
|
-
export { CopilotAdapter } from "./
|
|
7
|
-
export { GeminiCliAdapter } from "./
|
|
6
|
+
export { CopilotAdapter } from "./providers/copilot/CopilotAdapter.js";
|
|
7
|
+
export { GeminiCliAdapter } from "./providers/gemini/GeminiCliAdapter.js";
|
|
8
8
|
export { GrokCliAdapter } from "./adapters/GrokCliAdapter.js";
|
|
9
9
|
export { OpenCodeAdapter } from "./adapters/OpenCodeAdapter.js";
|
|
10
10
|
export { PiAdapter } from "./providers/pi/PiAdapter.js";
|
|
11
11
|
export { AgentStatus } from "./adapters/AgentAdapter.js";
|
|
12
12
|
export { TerminalFocusManager, TerminalType } from "./terminal/TerminalFocusManager.js";
|
|
13
13
|
export { TtyWriter } from "./terminal/TtyWriter.js";
|
|
14
|
+
export { extractHerdrAgentPanes, fetchHerdrAgentPanes, findMatchingHerdrPane, herdrPaneToRuntimeRef } from "./runtime/herdr/HerdrAgentDiscovery.js";
|
|
14
15
|
export { AgentRegistry, RenameNotFoundError, RenameConflictError, AGENT_RUNTIME_PROVIDERS, parseTmuxRuntimeRef } from "./utils/AgentRegistry.js";
|
|
15
16
|
export { TmuxManager } from "./terminal/TmuxManager.js";
|
|
16
17
|
export { startAgent, stopAgent, focusAgent, sendAgentPrompt, TmuxUnavailableError, AgentNameInUseError, AgentPidPollTimeoutError, AgentRuntimeUnavailableError, AgentTerminalNotFoundError, DEFAULT_PID_POLL_INTERVAL_MS, DEFAULT_PID_POLL_TIMEOUT_MS } from "./runtime/ManagedAgentRuntime.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { AgentManager, AgentNotRunningError } from \"./AgentManager.js\";\nexport { getCodexCapacityReport } from \"./capacity/index.js\";\nexport type { CapacityProbeOptions, CapacityReport, CapacityWindow } from \"./capacity/index.js\";\nexport {\n getAgentReadinessReport,\n getAgentReadinessReports,\n worstReadinessStatus,\n} from \"./readiness/AgentReadiness.js\";\nexport type {\n AgentReadinessOptions,\n AgentReadinessReport,\n AuthReadinessCheck,\n BuiltInSkillsReadinessCheck,\n DirectoryReadinessCheck,\n ExecutableReadinessCheck,\n IntegrationReadinessCheck,\n ReadinessAgentType,\n ReadinessAuthState,\n ReadinessCheck,\n ReadinessStatus,\n} from \"./readiness/AgentReadiness.js\";\n\nexport { ClaudeCodeAdapter } from \"./providers/claude/ClaudeCodeAdapter.js\";\nexport { CodexAdapter } from \"./providers/codex/CodexAdapter.js\";\nexport { CopilotAdapter } from \"./
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { AgentManager, AgentNotRunningError } from \"./AgentManager.js\";\nexport { getCodexCapacityReport } from \"./capacity/index.js\";\nexport type { CapacityProbeOptions, CapacityReport, CapacityWindow } from \"./capacity/index.js\";\nexport {\n getAgentReadinessReport,\n getAgentReadinessReports,\n worstReadinessStatus,\n} from \"./readiness/AgentReadiness.js\";\nexport type {\n AgentReadinessOptions,\n AgentReadinessReport,\n AuthReadinessCheck,\n BuiltInSkillsReadinessCheck,\n DirectoryReadinessCheck,\n ExecutableReadinessCheck,\n IntegrationReadinessCheck,\n ReadinessAgentType,\n ReadinessAuthState,\n ReadinessCheck,\n ReadinessStatus,\n} from \"./readiness/AgentReadiness.js\";\n\nexport { ClaudeCodeAdapter } from \"./providers/claude/ClaudeCodeAdapter.js\";\nexport { CodexAdapter } from \"./providers/codex/CodexAdapter.js\";\nexport { CopilotAdapter } from \"./providers/copilot/CopilotAdapter.js\";\nexport { GeminiCliAdapter } from \"./providers/gemini/GeminiCliAdapter.js\";\nexport { GrokCliAdapter } from \"./adapters/GrokCliAdapter.js\";\nexport { OpenCodeAdapter } from \"./adapters/OpenCodeAdapter.js\";\nexport { PiAdapter } from \"./providers/pi/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 AgentDetectionContext,\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 type { AgentManagerOptions, ListAgentsOptions } from \"./AgentManager.js\";\nexport {\n extractHerdrAgentPanes,\n fetchHerdrAgentPanes,\n findMatchingHerdrPane,\n herdrPaneToRuntimeRef,\n} from \"./runtime/herdr/HerdrAgentDiscovery.js\";\nexport type { HerdrAgentPane } from \"./runtime/herdr/HerdrAgentDiscovery.js\";\n\nexport {\n AgentRegistry,\n RenameNotFoundError,\n RenameConflictError,\n AGENT_RUNTIME_PROVIDERS,\n parseTmuxRuntimeRef,\n} from \"./utils/AgentRegistry.js\";\nexport type {\n AgentRegistryOptions,\n RegistryEntry,\n AgentRuntimeProvider,\n TmuxRuntimeRef,\n} from \"./utils/AgentRegistry.js\";\nexport { TmuxManager } from \"./terminal/TmuxManager.js\";\nexport type { AgentRuntimeAvailability, InteractiveAgentRuntime } from \"./runtime/types.js\";\nexport {\n startAgent,\n stopAgent,\n focusAgent,\n sendAgentPrompt,\n TmuxUnavailableError,\n AgentNameInUseError,\n AgentPidPollTimeoutError,\n AgentRuntimeUnavailableError,\n AgentTerminalNotFoundError,\n DEFAULT_PID_POLL_INTERVAL_MS,\n DEFAULT_PID_POLL_TIMEOUT_MS,\n} from \"./runtime/ManagedAgentRuntime.js\";\nexport type {\n FocusAgentDeps,\n StartAgentDeps,\n StartAgentOptions,\n StopAgentDeps,\n StopAgentResult,\n FocusAgentResult,\n SendAgentPromptDeps,\n} from \"./runtime/ManagedAgentRuntime.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 {\n getAgentRequestPath,\n readLatestAgentRequest,\n writeAgentRequest,\n} from \"./utils/agent-requests.js\";\n\nexport {\n AGENT_MODES,\n DurableAgentError,\n DurableAgentBusyError,\n DurableAgentNotFoundError,\n DurableAgentRepositoryError,\n DurableAgentNameConflictError,\n ClaudePrintError,\n CodexPrintError,\n PiPrintError,\n} from \"./durable/DurableAgent.js\";\nexport type {\n DurableAgent,\n DurableAgentBase,\n ClaudeDurableAgent,\n CodexDurableAgent,\n PiDurableAgent,\n DurableProvider,\n CodexPrintErrorCode,\n DurableAgentState,\n DurableSessionHealth,\n DurableRunStatus,\n DurableActiveRun,\n DurableLastResult,\n PiPrintErrorCode,\n ProcessIdentity,\n} from \"./durable/DurableAgent.js\";\nexport { DurableAgentRepository } from \"./durable/DurableAgentRepository.js\";\nexport type {\n CreateDurableAgentInput,\n DurableAgentRepositoryOptions,\n ProcessInspector,\n DurableRunCompletion,\n} from \"./durable/DurableAgentRepository.js\";\nexport { ClaudePrintAgentService } from \"./providers/claude/durable/ClaudePrintAgentService.js\";\nexport type {\n ClaudePrintAgentServiceOptions,\n ClaudePrintSendResult,\n} from \"./providers/claude/durable/ClaudePrintAgentService.js\";\nexport { CodexCliProbe } from \"./providers/codex/durable/CodexCliProbe.js\";\nexport type { CodexCliProbeOptions } from \"./providers/codex/durable/CodexCliProbe.js\";\nexport { CodexPrintRunner } from \"./providers/codex/durable/CodexPrintRunner.js\";\nexport type {\n CodexPrintRunnerOptions,\n CodexPrintRunRequest,\n CodexPrintRunResult,\n} from \"./providers/codex/durable/CodexPrintRunner.js\";\nexport { CodexPrintAgentService } from \"./providers/codex/durable/CodexPrintAgentService.js\";\nexport type {\n CodexPrintAgentServiceOptions,\n CodexPrintSendResult,\n} from \"./providers/codex/durable/CodexPrintAgentService.js\";\nexport { PiCliProbe } from \"./providers/pi/durable/PiCliProbe.js\";\nexport type { PiCliProbeOptions } from \"./providers/pi/durable/PiCliProbe.js\";\nexport { PiPrintRunner } from \"./providers/pi/durable/PiPrintRunner.js\";\nexport type {\n PiPrintRunnerOptions,\n PiPrintRunRequest,\n PiPrintRunResult,\n} from \"./providers/pi/durable/PiPrintRunner.js\";\nexport { PiPrintAgentService } from \"./providers/pi/durable/PiPrintAgentService.js\";\nexport type {\n PiPrintAgentServiceOptions,\n PiPrintSendResult,\n} from \"./providers/pi/durable/PiPrintAgentService.js\";\n"],"names":["AgentManager","AgentNotRunningError","getCodexCapacityReport","getAgentReadinessReport","getAgentReadinessReports","worstReadinessStatus","ClaudeCodeAdapter","CodexAdapter","CopilotAdapter","GeminiCliAdapter","GrokCliAdapter","OpenCodeAdapter","PiAdapter","AgentStatus","TerminalFocusManager","TerminalType","TtyWriter","extractHerdrAgentPanes","fetchHerdrAgentPanes","findMatchingHerdrPane","herdrPaneToRuntimeRef","AgentRegistry","RenameNotFoundError","RenameConflictError","AGENT_RUNTIME_PROVIDERS","parseTmuxRuntimeRef","TmuxManager","startAgent","stopAgent","focusAgent","sendAgentPrompt","TmuxUnavailableError","AgentNameInUseError","AgentPidPollTimeoutError","AgentRuntimeUnavailableError","AgentTerminalNotFoundError","DEFAULT_PID_POLL_INTERVAL_MS","DEFAULT_PID_POLL_TIMEOUT_MS","AGENTS","getAgentRequestPath","readLatestAgentRequest","writeAgentRequest","AGENT_MODES","DurableAgentError","DurableAgentBusyError","DurableAgentNotFoundError","DurableAgentRepositoryError","DurableAgentNameConflictError","ClaudePrintError","CodexPrintError","PiPrintError","DurableAgentRepository","ClaudePrintAgentService","CodexCliProbe","CodexPrintRunner","CodexPrintAgentService","PiCliProbe","PiPrintRunner","PiPrintAgentService"],"mappings":"AAAA,SAASA,YAAY,EAAEC,oBAAoB,QAAQ,oBAAoB;AACvE,SAASC,sBAAsB,QAAQ,sBAAsB;AAE7D,SACEC,uBAAuB,EACvBC,wBAAwB,EACxBC,oBAAoB,QACf,gCAAgC;AAevC,SAASC,iBAAiB,QAAQ,0CAA0C;AAC5E,SAASC,YAAY,QAAQ,oCAAoC;AACjE,SAASC,cAAc,QAAQ,wCAAwC;AACvE,SAASC,gBAAgB,QAAQ,yCAAyC;AAC1E,SAASC,cAAc,QAAQ,+BAA+B;AAC9D,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,SAAS,QAAQ,8BAA8B;AACxD,SAASC,WAAW,QAAQ,6BAA6B;AAYzD,SAASC,oBAAoB,EAAEC,YAAY,QAAQ,qCAAqC;AAExF,SAASC,SAAS,QAAQ,0BAA0B;AAGpD,SACEC,sBAAsB,EACtBC,oBAAoB,EACpBC,qBAAqB,EACrBC,qBAAqB,QAChB,yCAAyC;AAGhD,SACEC,aAAa,EACbC,mBAAmB,EACnBC,mBAAmB,EACnBC,uBAAuB,EACvBC,mBAAmB,QACd,2BAA2B;AAOlC,SAASC,WAAW,QAAQ,4BAA4B;AAExD,SACEC,UAAU,EACVC,SAAS,EACTC,UAAU,EACVC,eAAe,EACfC,oBAAoB,EACpBC,mBAAmB,EACnBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,0BAA0B,EAC1BC,4BAA4B,EAC5BC,2BAA2B,QACtB,mCAAmC;AAU1C,SAASC,MAAM,QAAQ,oBAAoB;AAI3C,SACEC,mBAAmB,EACnBC,sBAAsB,EACtBC,iBAAiB,QACZ,4BAA4B;AAEnC,SACEC,WAAW,EACXC,iBAAiB,EACjBC,qBAAqB,EACrBC,yBAAyB,EACzBC,2BAA2B,EAC3BC,6BAA6B,EAC7BC,gBAAgB,EAChBC,eAAe,EACfC,YAAY,QACP,4BAA4B;AAiBnC,SAASC,sBAAsB,QAAQ,sCAAsC;AAO7E,SAASC,uBAAuB,QAAQ,wDAAwD;AAKhG,SAASC,aAAa,QAAQ,6CAA6C;AAE3E,SAASC,gBAAgB,QAAQ,gDAAgD;AAMjF,SAASC,sBAAsB,QAAQ,sDAAsD;AAK7F,SAASC,UAAU,QAAQ,uCAAuC;AAElE,SAASC,aAAa,QAAQ,0CAA0C;AAMxE,SAASC,mBAAmB,QAAQ,gDAAgD"}
|
|
@@ -8,40 +8,26 @@
|
|
|
8
8
|
* 4. Reading events.jsonl as the primary session/conversation source
|
|
9
9
|
* 5. Reading workspace.yaml as a flat fallback metadata source
|
|
10
10
|
*/
|
|
11
|
-
import type { AgentAdapter, AgentInfo, ConversationMessage, ListSessionsOptions, ProcessInfo, SessionSummary, AgentDetectionContext } from "
|
|
12
|
-
import { AgentRegistry } from "
|
|
11
|
+
import type { AgentAdapter, AgentInfo, ConversationMessage, ListSessionsOptions, ProcessInfo, SessionSummary, AgentDetectionContext } from "../../adapters/AgentAdapter.js";
|
|
12
|
+
import { AgentRegistry } from "../../utils/AgentRegistry.js";
|
|
13
|
+
export interface CopilotAdapterOptions {
|
|
14
|
+
sessionStateDir?: string;
|
|
15
|
+
}
|
|
13
16
|
export declare class CopilotAdapter implements AgentAdapter {
|
|
14
17
|
readonly type: "copilot";
|
|
15
18
|
readonly processNames: readonly ["copilot"];
|
|
16
|
-
private
|
|
17
|
-
private
|
|
18
|
-
private
|
|
19
|
-
private
|
|
20
|
-
|
|
21
|
-
constructor(registry?: AgentRegistry);
|
|
19
|
+
private readonly registry;
|
|
20
|
+
private readonly parser;
|
|
21
|
+
private readonly mapper;
|
|
22
|
+
private readonly locator;
|
|
23
|
+
constructor(registry?: AgentRegistry, options?: CopilotAdapterOptions);
|
|
22
24
|
canHandle(processInfo: ProcessInfo): boolean;
|
|
23
25
|
detectAgents(context?: AgentDetectionContext): Promise<AgentInfo[]>;
|
|
24
|
-
private applyWrapperRegistryName;
|
|
25
26
|
getConversation(sessionFilePath: string, options?: {
|
|
26
27
|
verbose?: boolean;
|
|
27
28
|
}): ConversationMessage[];
|
|
28
29
|
listSessions(opts?: ListSessionsOptions): Promise<SessionSummary[]>;
|
|
29
|
-
private
|
|
30
|
-
private discoverActiveLocks;
|
|
31
|
-
private readSessionDir;
|
|
32
|
-
private readEvents;
|
|
33
|
-
private summarizeEvents;
|
|
34
|
-
private hasWorkspaceMetadata;
|
|
35
|
-
private readWorkspace;
|
|
36
|
-
private stripYamlScalar;
|
|
37
|
-
private parseEventLines;
|
|
38
|
-
private roleForEvent;
|
|
39
|
-
private extractEventText;
|
|
40
|
-
private mapSessionToAgent;
|
|
41
|
-
private mapProcessOnlyAgent;
|
|
42
|
-
private determineStatus;
|
|
43
|
-
private parseTimestamp;
|
|
44
|
-
private truncate;
|
|
30
|
+
private applyWrapperRegistryName;
|
|
45
31
|
private isCopilotExecutable;
|
|
46
32
|
}
|
|
47
33
|
//# sourceMappingURL=CopilotAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopilotAdapter.d.ts","sourceRoot":"","sources":["../../../src/providers/copilot/CopilotAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,qBAAqB,EACtB,MAAM,gCAAgC,CAAC;AAQxC,OAAO,EAAE,aAAa,EAAsB,MAAM,8BAA8B,CAAC;AAKjF,MAAM,WAAW,qBAAqB;IACpC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,cAAe,YAAW,YAAY;IACjD,QAAQ,CAAC,IAAI,EAAG,SAAS,CAAU;IACnC,QAAQ,CAAC,YAAY,uBAAwB;IAE7C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuB;IAC9C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;gBAG9C,QAAQ,GAAE,aAAuC,EACjD,OAAO,GAAE,qBAA0B;IAWrC,SAAS,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO;IAItC,YAAY,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAsCzE,eAAe,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,mBAAmB,EAAE;IAI1F,YAAY,CAAC,IAAI,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAsBzE,OAAO,CAAC,wBAAwB;IAahC,OAAO,CAAC,mBAAmB;CAI5B"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copilot Adapter
|
|
3
|
+
*
|
|
4
|
+
* Detects running GitHub Copilot CLI agents by:
|
|
5
|
+
* 1. Filtering Copilot processes from a shared asynchronous process snapshot
|
|
6
|
+
* 2. Using snapshot CWD and start-time enrichment
|
|
7
|
+
* 3. Mapping active ~/.copilot/session-state/{sessionId}/inuse.{pid}.lock files to processes
|
|
8
|
+
* 4. Reading events.jsonl as the primary session/conversation source
|
|
9
|
+
* 5. Reading workspace.yaml as a flat fallback metadata source
|
|
10
|
+
*/ import * as path from "path";
|
|
11
|
+
import { captureProcessSnapshot, executableBasename, filterByProcessNames, findWrapperProcess, findWrapperProcessPids } from "../../utils/process.js";
|
|
12
|
+
import { AgentRegistry } from "../../utils/AgentRegistry.js";
|
|
13
|
+
import { CopilotAgentMapper } from "./CopilotAgentMapper.js";
|
|
14
|
+
import { CopilotSessionLocator } from "./CopilotSessionLocator.js";
|
|
15
|
+
import { CopilotSessionParser } from "./CopilotSessionParser.js";
|
|
16
|
+
export class CopilotAdapter {
|
|
17
|
+
type = "copilot";
|
|
18
|
+
processNames = [
|
|
19
|
+
"copilot"
|
|
20
|
+
];
|
|
21
|
+
registry;
|
|
22
|
+
parser;
|
|
23
|
+
mapper;
|
|
24
|
+
locator;
|
|
25
|
+
constructor(registry = AgentRegistry.default(), options = {}){
|
|
26
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
27
|
+
this.registry = registry;
|
|
28
|
+
this.parser = new CopilotSessionParser();
|
|
29
|
+
this.mapper = new CopilotAgentMapper(this.parser);
|
|
30
|
+
this.locator = new CopilotSessionLocator({
|
|
31
|
+
sessionStateDir: options.sessionStateDir ?? path.join(homeDir, ".copilot", "session-state")
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
canHandle(processInfo) {
|
|
35
|
+
return this.isCopilotExecutable(processInfo.command);
|
|
36
|
+
}
|
|
37
|
+
async detectAgents(context) {
|
|
38
|
+
const snapshot = context?.processes ?? await captureProcessSnapshot(this.processNames);
|
|
39
|
+
const relevant = filterByProcessNames(snapshot, this.processNames);
|
|
40
|
+
const processes = relevant.filter((process1)=>this.canHandle(process1));
|
|
41
|
+
if (processes.length === 0) return [];
|
|
42
|
+
const processByPid = new Map(processes.map((proc)=>[
|
|
43
|
+
proc.pid,
|
|
44
|
+
proc
|
|
45
|
+
]));
|
|
46
|
+
const registryEntriesByPid = new Map(this.registry.list().map((entry)=>[
|
|
47
|
+
entry.pid,
|
|
48
|
+
entry
|
|
49
|
+
]));
|
|
50
|
+
const matchedPids = new Set();
|
|
51
|
+
const matchedProcesses = [];
|
|
52
|
+
const agents = [];
|
|
53
|
+
for (const lock of this.locator.discoverActiveLocks()){
|
|
54
|
+
const proc = processByPid.get(lock.pid);
|
|
55
|
+
if (!proc) continue;
|
|
56
|
+
const session = this.parser.readSessionDir(lock.sessionDir, lock.sessionId);
|
|
57
|
+
if (!session) continue;
|
|
58
|
+
const agent = this.mapper.mapSessionToAgent(session, proc);
|
|
59
|
+
this.applyWrapperRegistryName(agent, proc, processes, registryEntriesByPid);
|
|
60
|
+
agents.push(agent);
|
|
61
|
+
matchedPids.add(proc.pid);
|
|
62
|
+
matchedProcesses.push(proc);
|
|
63
|
+
}
|
|
64
|
+
const wrapperPids = findWrapperProcessPids(processes, matchedProcesses);
|
|
65
|
+
for (const proc of processes){
|
|
66
|
+
if (!matchedPids.has(proc.pid) && !wrapperPids.has(proc.pid)) {
|
|
67
|
+
const agent = this.mapper.mapProcessOnlyAgent(proc);
|
|
68
|
+
this.applyWrapperRegistryName(agent, proc, processes, registryEntriesByPid);
|
|
69
|
+
agents.push(agent);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return agents;
|
|
73
|
+
}
|
|
74
|
+
getConversation(sessionFilePath, options) {
|
|
75
|
+
return this.parser.getConversation(sessionFilePath, options);
|
|
76
|
+
}
|
|
77
|
+
async listSessions(opts) {
|
|
78
|
+
const summaries = [];
|
|
79
|
+
for (const { sessionDir, sessionId } of this.locator.listSessionDirs()){
|
|
80
|
+
const session = this.parser.readSessionDir(sessionDir, sessionId);
|
|
81
|
+
if (!session) continue;
|
|
82
|
+
if (opts?.cwd !== undefined && session.projectPath !== opts.cwd) continue;
|
|
83
|
+
summaries.push({
|
|
84
|
+
type: this.type,
|
|
85
|
+
sessionId: session.sessionId,
|
|
86
|
+
cwd: session.projectPath,
|
|
87
|
+
firstUserMessage: session.firstUserMessage,
|
|
88
|
+
lastActive: session.lastActive,
|
|
89
|
+
startedAt: session.sessionStart,
|
|
90
|
+
sessionFilePath: session.eventsFilePath
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return summaries;
|
|
94
|
+
}
|
|
95
|
+
applyWrapperRegistryName(agent, processInfo, processes, registryEntriesByPid) {
|
|
96
|
+
const wrapper = findWrapperProcess(processes, processInfo);
|
|
97
|
+
const wrapperEntry = wrapper ? registryEntriesByPid.get(wrapper.pid) : undefined;
|
|
98
|
+
if (wrapperEntry?.type === this.type) {
|
|
99
|
+
agent.name = wrapperEntry.name;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
isCopilotExecutable(command) {
|
|
103
|
+
const base = executableBasename(command);
|
|
104
|
+
return base === "copilot" || base === "copilot.exe";
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=CopilotAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/providers/copilot/CopilotAdapter.ts"],"sourcesContent":["/**\n * Copilot Adapter\n *\n * Detects running GitHub Copilot CLI agents by:\n * 1. Filtering Copilot processes from a shared asynchronous process snapshot\n * 2. Using snapshot CWD and start-time enrichment\n * 3. Mapping active ~/.copilot/session-state/{sessionId}/inuse.{pid}.lock files to processes\n * 4. Reading events.jsonl as the primary session/conversation source\n * 5. Reading workspace.yaml as a flat fallback metadata source\n */\n\nimport * as path from \"path\";\nimport type {\n AgentAdapter,\n AgentInfo,\n ConversationMessage,\n ListSessionsOptions,\n ProcessInfo,\n SessionSummary,\n AgentDetectionContext,\n} from \"../../adapters/AgentAdapter.js\";\nimport {\n captureProcessSnapshot,\n executableBasename,\n filterByProcessNames,\n findWrapperProcess,\n findWrapperProcessPids,\n} from \"../../utils/process.js\";\nimport { AgentRegistry, type RegistryEntry } from \"../../utils/AgentRegistry.js\";\nimport { CopilotAgentMapper } from \"./CopilotAgentMapper.js\";\nimport { CopilotSessionLocator } from \"./CopilotSessionLocator.js\";\nimport { CopilotSessionParser } from \"./CopilotSessionParser.js\";\n\nexport interface CopilotAdapterOptions {\n sessionStateDir?: string;\n}\n\nexport class CopilotAdapter implements AgentAdapter {\n readonly type = \"copilot\" as const;\n readonly processNames = [\"copilot\"] as const;\n\n private readonly registry: AgentRegistry;\n private readonly parser: CopilotSessionParser;\n private readonly mapper: CopilotAgentMapper;\n private readonly locator: CopilotSessionLocator;\n\n constructor(\n registry: AgentRegistry = AgentRegistry.default(),\n options: CopilotAdapterOptions = {},\n ) {\n const homeDir = process.env.HOME || process.env.USERPROFILE || \"\";\n this.registry = registry;\n this.parser = new CopilotSessionParser();\n this.mapper = new CopilotAgentMapper(this.parser);\n this.locator = new CopilotSessionLocator({\n sessionStateDir: options.sessionStateDir ?? path.join(homeDir, \".copilot\", \"session-state\"),\n });\n }\n\n canHandle(processInfo: ProcessInfo): boolean {\n return this.isCopilotExecutable(processInfo.command);\n }\n\n async detectAgents(context?: AgentDetectionContext): Promise<AgentInfo[]> {\n const snapshot = context?.processes ?? (await captureProcessSnapshot(this.processNames));\n const relevant = filterByProcessNames(snapshot, this.processNames);\n const processes = relevant.filter((process) => this.canHandle(process));\n if (processes.length === 0) return [];\n\n const processByPid = new Map(processes.map((proc) => [proc.pid, proc]));\n const registryEntriesByPid = new Map(this.registry.list().map((entry) => [entry.pid, entry]));\n const matchedPids = new Set<number>();\n const matchedProcesses: ProcessInfo[] = [];\n const agents: AgentInfo[] = [];\n\n for (const lock of this.locator.discoverActiveLocks()) {\n const proc = processByPid.get(lock.pid);\n if (!proc) continue;\n\n const session = this.parser.readSessionDir(lock.sessionDir, lock.sessionId);\n if (!session) continue;\n\n const agent = this.mapper.mapSessionToAgent(session, proc);\n this.applyWrapperRegistryName(agent, proc, processes, registryEntriesByPid);\n agents.push(agent);\n matchedPids.add(proc.pid);\n matchedProcesses.push(proc);\n }\n\n const wrapperPids = findWrapperProcessPids(processes, matchedProcesses);\n for (const proc of processes) {\n if (!matchedPids.has(proc.pid) && !wrapperPids.has(proc.pid)) {\n const agent = this.mapper.mapProcessOnlyAgent(proc);\n this.applyWrapperRegistryName(agent, proc, processes, registryEntriesByPid);\n agents.push(agent);\n }\n }\n\n return agents;\n }\n\n getConversation(sessionFilePath: string, options?: { verbose?: boolean }): ConversationMessage[] {\n return this.parser.getConversation(sessionFilePath, options);\n }\n\n async listSessions(opts?: ListSessionsOptions): Promise<SessionSummary[]> {\n const summaries: SessionSummary[] = [];\n\n for (const { sessionDir, sessionId } of this.locator.listSessionDirs()) {\n const session = this.parser.readSessionDir(sessionDir, sessionId);\n if (!session) continue;\n if (opts?.cwd !== undefined && session.projectPath !== opts.cwd) continue;\n\n summaries.push({\n type: this.type,\n sessionId: session.sessionId,\n cwd: session.projectPath,\n firstUserMessage: session.firstUserMessage,\n lastActive: session.lastActive,\n startedAt: session.sessionStart,\n sessionFilePath: session.eventsFilePath,\n });\n }\n\n return summaries;\n }\n\n private applyWrapperRegistryName(\n agent: AgentInfo,\n processInfo: ProcessInfo,\n processes: ProcessInfo[],\n registryEntriesByPid: Map<number, RegistryEntry>,\n ): void {\n const wrapper = findWrapperProcess(processes, processInfo);\n const wrapperEntry = wrapper ? registryEntriesByPid.get(wrapper.pid) : undefined;\n if (wrapperEntry?.type === this.type) {\n agent.name = wrapperEntry.name;\n }\n }\n\n private isCopilotExecutable(command: string): boolean {\n const base = executableBasename(command);\n return base === \"copilot\" || base === \"copilot.exe\";\n }\n}\n"],"names":["path","captureProcessSnapshot","executableBasename","filterByProcessNames","findWrapperProcess","findWrapperProcessPids","AgentRegistry","CopilotAgentMapper","CopilotSessionLocator","CopilotSessionParser","CopilotAdapter","type","processNames","registry","parser","mapper","locator","default","options","homeDir","process","env","HOME","USERPROFILE","sessionStateDir","join","canHandle","processInfo","isCopilotExecutable","command","detectAgents","context","snapshot","processes","relevant","filter","length","processByPid","Map","map","proc","pid","registryEntriesByPid","list","entry","matchedPids","Set","matchedProcesses","agents","lock","discoverActiveLocks","get","session","readSessionDir","sessionDir","sessionId","agent","mapSessionToAgent","applyWrapperRegistryName","push","add","wrapperPids","has","mapProcessOnlyAgent","getConversation","sessionFilePath","listSessions","opts","summaries","listSessionDirs","cwd","undefined","projectPath","firstUserMessage","lastActive","startedAt","sessionStart","eventsFilePath","wrapper","wrapperEntry","name","base"],"mappings":"AAAA;;;;;;;;;CASC,GAED,YAAYA,UAAU,OAAO;AAU7B,SACEC,sBAAsB,EACtBC,kBAAkB,EAClBC,oBAAoB,EACpBC,kBAAkB,EAClBC,sBAAsB,QACjB,yBAAyB;AAChC,SAASC,aAAa,QAA4B,+BAA+B;AACjF,SAASC,kBAAkB,QAAQ,0BAA0B;AAC7D,SAASC,qBAAqB,QAAQ,6BAA6B;AACnE,SAASC,oBAAoB,QAAQ,4BAA4B;AAMjE,OAAO,MAAMC;IACFC,OAAO,UAAmB;IAC1BC,eAAe;QAAC;KAAU,CAAU;IAE5BC,SAAwB;IACxBC,OAA6B;IAC7BC,OAA2B;IAC3BC,QAA+B;IAEhD,YACEH,WAA0BP,cAAcW,OAAO,EAAE,EACjDC,UAAiC,CAAC,CAAC,CACnC;QACA,MAAMC,UAAUC,QAAQC,GAAG,CAACC,IAAI,IAAIF,QAAQC,GAAG,CAACE,WAAW,IAAI;QAC/D,IAAI,CAACV,QAAQ,GAAGA;QAChB,IAAI,CAACC,MAAM,GAAG,IAAIL;QAClB,IAAI,CAACM,MAAM,GAAG,IAAIR,mBAAmB,IAAI,CAACO,MAAM;QAChD,IAAI,CAACE,OAAO,GAAG,IAAIR,sBAAsB;YACvCgB,iBAAiBN,QAAQM,eAAe,IAAIxB,KAAKyB,IAAI,CAACN,SAAS,YAAY;QAC7E;IACF;IAEAO,UAAUC,WAAwB,EAAW;QAC3C,OAAO,IAAI,CAACC,mBAAmB,CAACD,YAAYE,OAAO;IACrD;IAEA,MAAMC,aAAaC,OAA+B,EAAwB;QACxE,MAAMC,WAAWD,SAASE,aAAc,MAAMhC,uBAAuB,IAAI,CAACW,YAAY;QACtF,MAAMsB,WAAW/B,qBAAqB6B,UAAU,IAAI,CAACpB,YAAY;QACjE,MAAMqB,YAAYC,SAASC,MAAM,CAAC,CAACf,WAAY,IAAI,CAACM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
import { CopilotSessionParser, type CopilotSession } from "./CopilotSessionParser.js";
|
|
3
|
+
export declare class CopilotAgentMapper {
|
|
4
|
+
private readonly parser;
|
|
5
|
+
constructor(parser?: CopilotSessionParser);
|
|
6
|
+
mapSessionToAgent(session: CopilotSession, processInfo: ProcessInfo): AgentInfo;
|
|
7
|
+
mapProcessOnlyAgent(processInfo: ProcessInfo): AgentInfo;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=CopilotAgentMapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopilotAgentMapper.d.ts","sourceRoot":"","sources":["../../../src/providers/copilot/CopilotAgentMapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAG7E,OAAO,EAAE,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEtF,qBAAa,kBAAkB;IACjB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,GAAE,oBAAiD;IAEtF,iBAAiB,CAAC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,GAAG,SAAS;IAe/E,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,SAAS;CAYzD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AgentStatus } from "../../adapters/AgentAdapter.js";
|
|
2
|
+
import { generateAgentName } from "../../utils/matching.js";
|
|
3
|
+
import { CopilotSessionParser } from "./CopilotSessionParser.js";
|
|
4
|
+
export class CopilotAgentMapper {
|
|
5
|
+
parser;
|
|
6
|
+
constructor(parser = new CopilotSessionParser()){
|
|
7
|
+
this.parser = parser;
|
|
8
|
+
}
|
|
9
|
+
mapSessionToAgent(session, processInfo) {
|
|
10
|
+
const projectPath = session.projectPath || processInfo.cwd || "";
|
|
11
|
+
return {
|
|
12
|
+
name: generateAgentName(projectPath, processInfo.pid),
|
|
13
|
+
type: "copilot",
|
|
14
|
+
status: this.parser.determineStatus(session),
|
|
15
|
+
summary: session.summary || "Copilot session active",
|
|
16
|
+
pid: processInfo.pid,
|
|
17
|
+
projectPath,
|
|
18
|
+
sessionId: session.sessionId,
|
|
19
|
+
lastActive: session.lastActive,
|
|
20
|
+
sessionFilePath: session.eventsFilePath
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
mapProcessOnlyAgent(processInfo) {
|
|
24
|
+
return {
|
|
25
|
+
name: generateAgentName(processInfo.cwd || "", processInfo.pid),
|
|
26
|
+
type: "copilot",
|
|
27
|
+
status: AgentStatus.RUNNING,
|
|
28
|
+
summary: "Copilot process running",
|
|
29
|
+
pid: processInfo.pid,
|
|
30
|
+
projectPath: processInfo.cwd || "",
|
|
31
|
+
sessionId: `pid-${processInfo.pid}`,
|
|
32
|
+
lastActive: new Date()
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=CopilotAgentMapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/providers/copilot/CopilotAgentMapper.ts"],"sourcesContent":["import type { AgentInfo, ProcessInfo } from \"../../adapters/AgentAdapter.js\";\nimport { AgentStatus } from \"../../adapters/AgentAdapter.js\";\nimport { generateAgentName } from \"../../utils/matching.js\";\nimport { CopilotSessionParser, type CopilotSession } from \"./CopilotSessionParser.js\";\n\nexport class CopilotAgentMapper {\n constructor(private readonly parser: CopilotSessionParser = new CopilotSessionParser()) {}\n\n mapSessionToAgent(session: CopilotSession, processInfo: ProcessInfo): AgentInfo {\n const projectPath = session.projectPath || processInfo.cwd || \"\";\n return {\n name: generateAgentName(projectPath, processInfo.pid),\n type: \"copilot\",\n status: this.parser.determineStatus(session),\n summary: session.summary || \"Copilot session active\",\n pid: processInfo.pid,\n projectPath,\n sessionId: session.sessionId,\n lastActive: session.lastActive,\n sessionFilePath: session.eventsFilePath,\n };\n }\n\n mapProcessOnlyAgent(processInfo: ProcessInfo): AgentInfo {\n return {\n name: generateAgentName(processInfo.cwd || \"\", processInfo.pid),\n type: \"copilot\",\n status: AgentStatus.RUNNING,\n summary: \"Copilot process running\",\n pid: processInfo.pid,\n projectPath: processInfo.cwd || \"\",\n sessionId: `pid-${processInfo.pid}`,\n lastActive: new Date(),\n };\n }\n}\n"],"names":["AgentStatus","generateAgentName","CopilotSessionParser","CopilotAgentMapper","parser","mapSessionToAgent","session","processInfo","projectPath","cwd","name","pid","type","status","determineStatus","summary","sessionId","lastActive","sessionFilePath","eventsFilePath","mapProcessOnlyAgent","RUNNING","Date"],"mappings":"AACA,SAASA,WAAW,QAAQ,iCAAiC;AAC7D,SAASC,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,oBAAoB,QAA6B,4BAA4B;AAEtF,OAAO,MAAMC;;IACX,YAAY,AAAiBC,SAA+B,IAAIF,sBAAsB,CAAE;aAA3DE,SAAAA;IAA4D;IAEzFC,kBAAkBC,OAAuB,EAAEC,WAAwB,EAAa;QAC9E,MAAMC,cAAcF,QAAQE,WAAW,IAAID,YAAYE,GAAG,IAAI;QAC9D,OAAO;YACLC,MAAMT,kBAAkBO,aAAaD,YAAYI,GAAG;YACpDC,MAAM;YACNC,QAAQ,IAAI,CAACT,MAAM,CAACU,eAAe,CAACR;YACpCS,SAAST,QAAQS,OAAO,IAAI;YAC5BJ,KAAKJ,YAAYI,GAAG;YACpBH;YACAQ,WAAWV,QAAQU,SAAS;YAC5BC,YAAYX,QAAQW,UAAU;YAC9BC,iBAAiBZ,QAAQa,cAAc;QACzC;IACF;IAEAC,oBAAoBb,WAAwB,EAAa;QACvD,OAAO;YACLG,MAAMT,kBAAkBM,YAAYE,GAAG,IAAI,IAAIF,YAAYI,GAAG;YAC9DC,MAAM;YACNC,QAAQb,YAAYqB,OAAO;YAC3BN,SAAS;YACTJ,KAAKJ,YAAYI,GAAG;YACpBH,aAAaD,YAAYE,GAAG,IAAI;YAChCO,WAAW,CAAC,IAAI,EAAET,YAAYI,GAAG,EAAE;YACnCM,YAAY,IAAIK;QAClB;IACF;AACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface CopilotLock {
|
|
2
|
+
sessionDir: string;
|
|
3
|
+
sessionId: string;
|
|
4
|
+
pid: number;
|
|
5
|
+
}
|
|
6
|
+
export interface CopilotSessionDir {
|
|
7
|
+
sessionDir: string;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
}
|
|
10
|
+
export interface CopilotSessionLocatorOptions {
|
|
11
|
+
sessionStateDir?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class CopilotSessionLocator {
|
|
14
|
+
private readonly sessionStateDir;
|
|
15
|
+
constructor(options?: CopilotSessionLocatorOptions);
|
|
16
|
+
listSessionDirs(): CopilotSessionDir[];
|
|
17
|
+
discoverActiveLocks(): CopilotLock[];
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=CopilotSessionLocator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopilotSessionLocator.d.ts","sourceRoot":"","sources":["../../../src/providers/copilot/CopilotSessionLocator.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,4BAA4B;IAC3C,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;gBAE7B,OAAO,GAAE,4BAAiC;IAMtD,eAAe,IAAI,iBAAiB,EAAE;IActC,mBAAmB,IAAI,WAAW,EAAE;CAerC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
import { isDirectory, safeReaddir } from "../../utils/session.js";
|
|
3
|
+
export class CopilotSessionLocator {
|
|
4
|
+
sessionStateDir;
|
|
5
|
+
constructor(options = {}){
|
|
6
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
7
|
+
this.sessionStateDir = options.sessionStateDir ?? path.join(homeDir, ".copilot", "session-state");
|
|
8
|
+
}
|
|
9
|
+
listSessionDirs() {
|
|
10
|
+
if (!isDirectory(this.sessionStateDir)) return [];
|
|
11
|
+
const sessionDirs = [];
|
|
12
|
+
for (const sessionId of safeReaddir(this.sessionStateDir)){
|
|
13
|
+
const sessionDir = path.join(this.sessionStateDir, sessionId);
|
|
14
|
+
if (!isDirectory(sessionDir)) continue;
|
|
15
|
+
sessionDirs.push({
|
|
16
|
+
sessionDir,
|
|
17
|
+
sessionId
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return sessionDirs;
|
|
21
|
+
}
|
|
22
|
+
discoverActiveLocks() {
|
|
23
|
+
const locks = [];
|
|
24
|
+
for (const { sessionDir, sessionId } of this.listSessionDirs()){
|
|
25
|
+
for (const entry of safeReaddir(sessionDir)){
|
|
26
|
+
const match = entry.match(/^inuse\.(\d+)\.lock$/);
|
|
27
|
+
if (!match) continue;
|
|
28
|
+
const pid = Number.parseInt(match[1], 10);
|
|
29
|
+
if (!Number.isFinite(pid)) continue;
|
|
30
|
+
locks.push({
|
|
31
|
+
sessionDir,
|
|
32
|
+
sessionId,
|
|
33
|
+
pid
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return locks;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=CopilotSessionLocator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/providers/copilot/CopilotSessionLocator.ts"],"sourcesContent":["import * as path from \"path\";\nimport { isDirectory, safeReaddir } from \"../../utils/session.js\";\n\nexport interface CopilotLock {\n sessionDir: string;\n sessionId: string;\n pid: number;\n}\n\nexport interface CopilotSessionDir {\n sessionDir: string;\n sessionId: string;\n}\n\nexport interface CopilotSessionLocatorOptions {\n sessionStateDir?: string;\n}\n\nexport class CopilotSessionLocator {\n private readonly sessionStateDir: string;\n\n constructor(options: CopilotSessionLocatorOptions = {}) {\n const homeDir = process.env.HOME || process.env.USERPROFILE || \"\";\n this.sessionStateDir =\n options.sessionStateDir ?? path.join(homeDir, \".copilot\", \"session-state\");\n }\n\n listSessionDirs(): CopilotSessionDir[] {\n if (!isDirectory(this.sessionStateDir)) return [];\n\n const sessionDirs: CopilotSessionDir[] = [];\n for (const sessionId of safeReaddir(this.sessionStateDir)) {\n const sessionDir = path.join(this.sessionStateDir, sessionId);\n if (!isDirectory(sessionDir)) continue;\n\n sessionDirs.push({ sessionDir, sessionId });\n }\n\n return sessionDirs;\n }\n\n discoverActiveLocks(): CopilotLock[] {\n const locks: CopilotLock[] = [];\n for (const { sessionDir, sessionId } of this.listSessionDirs()) {\n for (const entry of safeReaddir(sessionDir)) {\n const match = entry.match(/^inuse\\.(\\d+)\\.lock$/);\n if (!match) continue;\n\n const pid = Number.parseInt(match[1], 10);\n if (!Number.isFinite(pid)) continue;\n locks.push({ sessionDir, sessionId, pid });\n }\n }\n\n return locks;\n }\n}\n"],"names":["path","isDirectory","safeReaddir","CopilotSessionLocator","sessionStateDir","options","homeDir","process","env","HOME","USERPROFILE","join","listSessionDirs","sessionDirs","sessionId","sessionDir","push","discoverActiveLocks","locks","entry","match","pid","Number","parseInt","isFinite"],"mappings":"AAAA,YAAYA,UAAU,OAAO;AAC7B,SAASC,WAAW,EAAEC,WAAW,QAAQ,yBAAyB;AAiBlE,OAAO,MAAMC;IACMC,gBAAwB;IAEzC,YAAYC,UAAwC,CAAC,CAAC,CAAE;QACtD,MAAMC,UAAUC,QAAQC,GAAG,CAACC,IAAI,IAAIF,QAAQC,GAAG,CAACE,WAAW,IAAI;QAC/D,IAAI,CAACN,eAAe,GAClBC,QAAQD,eAAe,IAAIJ,KAAKW,IAAI,CAACL,SAAS,YAAY;IAC9D;IAEAM,kBAAuC;QACrC,IAAI,CAACX,YAAY,IAAI,CAACG,eAAe,GAAG,OAAO,EAAE;QAEjD,MAAMS,cAAmC,EAAE;QAC3C,KAAK,MAAMC,aAAaZ,YAAY,IAAI,CAACE,eAAe,EAAG;YACzD,MAAMW,aAAaf,KAAKW,IAAI,CAAC,IAAI,CAACP,eAAe,EAAEU;YACnD,IAAI,CAACb,YAAYc,aAAa;YAE9BF,YAAYG,IAAI,CAAC;gBAAED;gBAAYD;YAAU;QAC3C;QAEA,OAAOD;IACT;IAEAI,sBAAqC;QACnC,MAAMC,QAAuB,EAAE;QAC/B,KAAK,MAAM,EAAEH,UAAU,EAAED,SAAS,EAAE,IAAI,IAAI,CAACF,eAAe,GAAI;YAC9D,KAAK,MAAMO,SAASjB,YAAYa,YAAa;gBAC3C,MAAMK,QAAQD,MAAMC,KAAK,CAAC;gBAC1B,IAAI,CAACA,OAAO;gBAEZ,MAAMC,MAAMC,OAAOC,QAAQ,CAACH,KAAK,CAAC,EAAE,EAAE;gBACtC,IAAI,CAACE,OAAOE,QAAQ,CAACH,MAAM;gBAC3BH,MAAMF,IAAI,CAAC;oBAAED;oBAAYD;oBAAWO;gBAAI;YAC1C;QACF;QAEA,OAAOH;IACT;AACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ConversationMessage } from "../../adapters/AgentAdapter.js";
|
|
2
|
+
import { AgentStatus } from "../../adapters/AgentAdapter.js";
|
|
3
|
+
export interface CopilotSession {
|
|
4
|
+
sessionId: string;
|
|
5
|
+
projectPath: string;
|
|
6
|
+
summary: string;
|
|
7
|
+
sessionStart: Date;
|
|
8
|
+
lastActive: Date;
|
|
9
|
+
lastEventType?: string;
|
|
10
|
+
firstUserMessage: string;
|
|
11
|
+
eventsFilePath: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class CopilotSessionParser {
|
|
14
|
+
readSessionDir(sessionDir: string, fallbackSessionId: string): CopilotSession | null;
|
|
15
|
+
getConversation(sessionFilePath: string, options?: {
|
|
16
|
+
verbose?: boolean;
|
|
17
|
+
}): ConversationMessage[];
|
|
18
|
+
determineStatus(session: CopilotSession): AgentStatus;
|
|
19
|
+
private readEventEntries;
|
|
20
|
+
private buildSessionFromEntries;
|
|
21
|
+
private hasWorkspaceMetadata;
|
|
22
|
+
private readWorkspaceMetadata;
|
|
23
|
+
private stripYamlScalar;
|
|
24
|
+
private parseEventLines;
|
|
25
|
+
private roleForEvent;
|
|
26
|
+
private extractEventText;
|
|
27
|
+
private parseTimestamp;
|
|
28
|
+
private truncate;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=CopilotSessionParser.d.ts.map
|