aemeathcli 1.0.9 → 1.0.11
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/LICENSE +21 -0
- package/README.md +609 -608
- package/dist/App-YAHJUWCX.js +4274 -0
- package/dist/App-YAHJUWCX.js.map +1 -0
- package/dist/agent-store/architect.md +32 -0
- package/dist/agent-store/debugger.md +32 -0
- package/dist/agent-store/developer.md +29 -0
- package/dist/agent-store/documenter.md +30 -0
- package/dist/agent-store/researcher.md +31 -0
- package/dist/agent-store/reviewer.md +28 -0
- package/dist/agent-store/supervisor.md +37 -0
- package/dist/agent-store/tester.md +30 -0
- package/dist/api-key-fallback-UN3TJEOO.js +11 -0
- package/dist/{api-key-fallback-YQQBOQIL.js.map → api-key-fallback-UN3TJEOO.js.map} +1 -1
- package/dist/auth-status-EIM5A5KL.js +13 -0
- package/dist/auth-status-EIM5A5KL.js.map +1 -0
- package/dist/{chunk-UY2SYSEZ.js → chunk-25UNNEHN.js} +32 -103
- package/dist/chunk-25UNNEHN.js.map +1 -0
- package/dist/{chunk-CYQNBB25.js → chunk-2GKOK6T7.js} +28 -5
- package/dist/chunk-2GKOK6T7.js.map +1 -0
- package/dist/{chunk-MFBHNWGV.js → chunk-2LF7ALGR.js} +12 -20
- package/dist/chunk-2LF7ALGR.js.map +1 -0
- package/dist/{chunk-H66O5Z2V.js → chunk-2NWNIKBK.js} +42 -7
- package/dist/chunk-2NWNIKBK.js.map +1 -0
- package/dist/chunk-3TSPZRGM.js +26 -0
- package/dist/chunk-3TSPZRGM.js.map +1 -0
- package/dist/{chunk-ZGOHARPV.js → chunk-473JN6M5.js} +2 -2
- package/dist/chunk-473JN6M5.js.map +1 -0
- package/dist/{chunk-IYW62KKR.js → chunk-5XFSV6PF.js} +66 -23
- package/dist/chunk-5XFSV6PF.js.map +1 -0
- package/dist/{chunk-HCIHOHLX.js → chunk-62HSGYQD.js} +2 -2
- package/dist/chunk-62HSGYQD.js.map +1 -0
- package/dist/{chunk-I5PZ4JTS.js → chunk-6GUD7QIM.js} +4 -4
- package/dist/chunk-6GUD7QIM.js.map +1 -0
- package/dist/{chunk-4IJD72YB.js → chunk-AQ23TYSQ.js} +7 -7
- package/dist/chunk-AQ23TYSQ.js.map +1 -0
- package/dist/{chunk-NBR3GHMT.js → chunk-BY4DAKUU.js} +39 -7
- package/dist/chunk-BY4DAKUU.js.map +1 -0
- package/dist/chunk-CC7MGWYY.js +12 -0
- package/dist/chunk-CC7MGWYY.js.map +1 -0
- package/dist/chunk-CTFZTARK.js +155 -0
- package/dist/chunk-CTFZTARK.js.map +1 -0
- package/dist/chunk-FIC7AK4Q.js +232 -0
- package/dist/chunk-FIC7AK4Q.js.map +1 -0
- package/dist/chunk-GU33WKPG.js +140 -0
- package/dist/chunk-GU33WKPG.js.map +1 -0
- package/dist/{chunk-VUG4IZ7J.js → chunk-H2SYKIMI.js} +10 -10
- package/dist/chunk-H2SYKIMI.js.map +1 -0
- package/dist/{chunk-JAXXTYID.js → chunk-HEKFAKVH.js} +2 -2
- package/dist/chunk-HEKFAKVH.js.map +1 -0
- package/dist/chunk-IARA5XYP.js +186 -0
- package/dist/chunk-IARA5XYP.js.map +1 -0
- package/dist/{chunk-HMJRPNPZ.js → chunk-LCYH4T6N.js} +95 -23
- package/dist/chunk-LCYH4T6N.js.map +1 -0
- package/dist/{chunk-CARHU3DO.js → chunk-LDVY5ELP.js} +66 -18
- package/dist/chunk-LDVY5ELP.js.map +1 -0
- package/dist/chunk-OCJPQFOR.js +88 -0
- package/dist/chunk-OCJPQFOR.js.map +1 -0
- package/dist/chunk-ODBY7S4X.js +141 -0
- package/dist/chunk-ODBY7S4X.js.map +1 -0
- package/dist/{chunk-DAHGLHNR.js → chunk-ONQ4WCUI.js} +7 -142
- package/dist/chunk-ONQ4WCUI.js.map +1 -0
- package/dist/{chunk-WPP3PEDE.js → chunk-P5TKZM3T.js} +32 -107
- package/dist/chunk-P5TKZM3T.js.map +1 -0
- package/dist/{chunk-ASGRGXYK.js → chunk-P66WDACW.js} +23 -22
- package/dist/chunk-P66WDACW.js.map +1 -0
- package/dist/{chunk-LSOYPSAT.js → chunk-QCRK4QEL.js} +4 -4
- package/dist/chunk-QCRK4QEL.js.map +1 -0
- package/dist/{chunk-YL5XFHR3.js → chunk-ROJPFPJ7.js} +2 -2
- package/dist/chunk-ROJPFPJ7.js.map +1 -0
- package/dist/chunk-RP2TAL3J.js +71 -0
- package/dist/chunk-RP2TAL3J.js.map +1 -0
- package/dist/{chunk-6PDJ45T4.js → chunk-RYOB3TLZ.js} +51 -26
- package/dist/chunk-RYOB3TLZ.js.map +1 -0
- package/dist/{chunk-Y5XVD2CD.js → chunk-SOQFMNQC.js} +110 -83
- package/dist/chunk-SOQFMNQC.js.map +1 -0
- package/dist/{chunk-TEVZS4FA.js → chunk-TDFTX32B.js} +16 -9
- package/dist/chunk-TDFTX32B.js.map +1 -0
- package/dist/chunk-VBLLDY4R.js +38 -0
- package/dist/chunk-VBLLDY4R.js.map +1 -0
- package/dist/{chunk-CGEV3ARR.js → chunk-VJNQJALF.js} +4 -4
- package/dist/chunk-VJNQJALF.js.map +1 -0
- package/dist/chunk-WAYSJMPS.js +26 -0
- package/dist/chunk-WAYSJMPS.js.map +1 -0
- package/dist/chunk-WC72BRHR.js +241 -0
- package/dist/chunk-WC72BRHR.js.map +1 -0
- package/dist/{chunk-MXZSI3AY.js → chunk-YPFOE2QJ.js} +43 -11
- package/dist/chunk-YPFOE2QJ.js.map +1 -0
- package/dist/claude-adapter-6P4SJH7P.js +7 -0
- package/dist/{claude-adapter-QMLFMSP3.js.map → claude-adapter-6P4SJH7P.js.map} +1 -1
- package/dist/{claude-login-5WELXPKT.js → claude-login-IS5WTBMP.js} +10 -10
- package/dist/claude-login-IS5WTBMP.js.map +1 -0
- package/dist/cli.js +371 -172
- package/dist/cli.js.map +1 -1
- package/dist/{codex-login-DDJBCT43.js → codex-login-GMPF64MR.js} +18 -17
- package/dist/codex-login-GMPF64MR.js.map +1 -0
- package/dist/config-store-POB6I37G.js +7 -0
- package/dist/{config-store-W6FBCQAQ.js.map → config-store-POB6I37G.js.map} +1 -1
- package/dist/conversation-store-PRBHWQMJ.js +4 -0
- package/dist/conversation-store-PRBHWQMJ.js.map +1 -0
- package/dist/detect-providers-C4SVQHFF.js +4 -0
- package/dist/detect-providers-C4SVQHFF.js.map +1 -0
- package/dist/executor-RUX7VK3T.js +4 -0
- package/dist/{executor-6RIKIGXK.js.map → executor-RUX7VK3T.js.map} +1 -1
- package/dist/first-run-GDEVRFPO.js +230 -0
- package/dist/first-run-GDEVRFPO.js.map +1 -0
- package/dist/gemini-adapter-MV3U4QFH.js +7 -0
- package/dist/{gemini-adapter-6JIHZ7WI.js.map → gemini-adapter-MV3U4QFH.js.map} +1 -1
- package/dist/{gemini-login-YEPK6GGW.js → gemini-login-KE224MSW.js} +13 -14
- package/dist/gemini-login-KE224MSW.js.map +1 -0
- package/dist/index.d.ts +47 -17
- package/dist/index.js +86 -471
- package/dist/index.js.map +1 -1
- package/dist/input-history-MIOO3FIW.js +57 -0
- package/dist/input-history-MIOO3FIW.js.map +1 -0
- package/dist/kimi-adapter-UODMNX6K.js +6 -0
- package/dist/{kimi-adapter-JN4HFFHU.js.map → kimi-adapter-UODMNX6K.js.map} +1 -1
- package/dist/{kimi-login-ZR74MIY4.js → kimi-login-DNT5YBKX.js} +18 -17
- package/dist/kimi-login-DNT5YBKX.js.map +1 -0
- package/dist/logger-PLPDWACQ.js +3 -0
- package/dist/logger-PLPDWACQ.js.map +1 -0
- package/dist/model-discovery-O64ZWPX5.js +6 -0
- package/dist/model-discovery-O64ZWPX5.js.map +1 -0
- package/dist/native-cli-adapters-JMZX2C2C.js +8 -0
- package/dist/{native-cli-adapters-OLW3XX57.js.map → native-cli-adapters-JMZX2C2C.js.map} +1 -1
- package/dist/ollama-adapter-GE67BNSS.js +5 -0
- package/dist/{ollama-adapter-OJQ3FKWK.js.map → ollama-adapter-GE67BNSS.js.map} +1 -1
- package/dist/openai-adapter-SHPLK77L.js +7 -0
- package/dist/{openai-adapter-XU46EN7B.js.map → openai-adapter-SHPLK77L.js.map} +1 -1
- package/dist/pathResolver-A6IXQQFE.js +3 -0
- package/dist/pathResolver-A6IXQQFE.js.map +1 -0
- package/dist/profile-loader-TNAXBLDX.js +162 -0
- package/dist/profile-loader-TNAXBLDX.js.map +1 -0
- package/dist/registry-3NHVCXCZ.js +6 -0
- package/dist/{registry-H7B3AHPQ.js.map → registry-3NHVCXCZ.js.map} +1 -1
- package/dist/registry-7CQ3NCAD.js +5 -0
- package/dist/{registry-OYWYT7WL.js.map → registry-7CQ3NCAD.js.map} +1 -1
- package/dist/server-manager-DES23IBQ.js +5 -0
- package/dist/{server-manager-PTGBHCLS.js.map → server-manager-DES23IBQ.js.map} +1 -1
- package/dist/session-manager-EHD7GWM2.js +12 -0
- package/dist/{session-manager-NYB2RKMS.js.map → session-manager-EHD7GWM2.js.map} +1 -1
- package/dist/skills/built-in/code-review/SKILL.md +85 -0
- package/dist/skills/built-in/commit/SKILL.md +83 -0
- package/dist/skills/built-in/debug/SKILL.md +119 -0
- package/dist/skills/built-in/plan/SKILL.md +123 -0
- package/dist/skills/built-in/refactor/SKILL.md +132 -0
- package/dist/skills/built-in/test/SKILL.md +128 -0
- package/dist/sqlite-store-7ZIVOUNI.js +5 -0
- package/dist/sqlite-store-7ZIVOUNI.js.map +1 -0
- package/dist/team-manager-6DCNLGTC.js +11 -0
- package/dist/{team-manager-HC4XGCFY.js.map → team-manager-6DCNLGTC.js.map} +1 -1
- package/dist/team-state-R2D7DT5M.js +3 -0
- package/dist/team-state-R2D7DT5M.js.map +1 -0
- package/dist/tmux-manager-WBKHUHDT.js +6 -0
- package/dist/{tmux-manager-GPYZ3WQH.js.map → tmux-manager-WBKHUHDT.js.map} +1 -1
- package/dist/tools-I6XCTEZY.js +6 -0
- package/dist/{tools-TSMXMHIF.js.map → tools-I6XCTEZY.js.map} +1 -1
- package/package.json +93 -89
- package/dist/App-TE3JJKOW.js +0 -2789
- package/dist/App-TE3JJKOW.js.map +0 -1
- package/dist/api-key-fallback-YQQBOQIL.js +0 -11
- package/dist/chunk-4IJD72YB.js.map +0 -1
- package/dist/chunk-6PDJ45T4.js.map +0 -1
- package/dist/chunk-ASGRGXYK.js.map +0 -1
- package/dist/chunk-CARHU3DO.js.map +0 -1
- package/dist/chunk-CGEV3ARR.js.map +0 -1
- package/dist/chunk-CS5X3BWX.js +0 -27
- package/dist/chunk-CS5X3BWX.js.map +0 -1
- package/dist/chunk-CYQNBB25.js.map +0 -1
- package/dist/chunk-DAHGLHNR.js.map +0 -1
- package/dist/chunk-H66O5Z2V.js.map +0 -1
- package/dist/chunk-HCIHOHLX.js.map +0 -1
- package/dist/chunk-HMJRPNPZ.js.map +0 -1
- package/dist/chunk-I5PZ4JTS.js.map +0 -1
- package/dist/chunk-IYW62KKR.js.map +0 -1
- package/dist/chunk-JAXXTYID.js.map +0 -1
- package/dist/chunk-LSOYPSAT.js.map +0 -1
- package/dist/chunk-MFBHNWGV.js.map +0 -1
- package/dist/chunk-MXZSI3AY.js.map +0 -1
- package/dist/chunk-NBR3GHMT.js.map +0 -1
- package/dist/chunk-TEVZS4FA.js.map +0 -1
- package/dist/chunk-UY2SYSEZ.js.map +0 -1
- package/dist/chunk-VUG4IZ7J.js.map +0 -1
- package/dist/chunk-WAHVZH7V.js +0 -260
- package/dist/chunk-WAHVZH7V.js.map +0 -1
- package/dist/chunk-WPP3PEDE.js.map +0 -1
- package/dist/chunk-Y5XVD2CD.js.map +0 -1
- package/dist/chunk-YL5XFHR3.js.map +0 -1
- package/dist/chunk-ZGOHARPV.js.map +0 -1
- package/dist/claude-adapter-QMLFMSP3.js +0 -6
- package/dist/claude-login-5WELXPKT.js.map +0 -1
- package/dist/codex-login-DDJBCT43.js.map +0 -1
- package/dist/config-store-W6FBCQAQ.js +0 -6
- package/dist/executor-6RIKIGXK.js +0 -4
- package/dist/gemini-adapter-6JIHZ7WI.js +0 -6
- package/dist/gemini-login-YEPK6GGW.js.map +0 -1
- package/dist/kimi-adapter-JN4HFFHU.js +0 -6
- package/dist/kimi-login-ZR74MIY4.js.map +0 -1
- package/dist/native-cli-adapters-OLW3XX57.js +0 -6
- package/dist/ollama-adapter-OJQ3FKWK.js +0 -6
- package/dist/openai-adapter-XU46EN7B.js +0 -6
- package/dist/registry-H7B3AHPQ.js +0 -5
- package/dist/registry-OYWYT7WL.js +0 -6
- package/dist/server-manager-PTGBHCLS.js +0 -5
- package/dist/session-manager-NYB2RKMS.js +0 -12
- package/dist/team-manager-HC4XGCFY.js +0 -11
- package/dist/tmux-manager-GPYZ3WQH.js +0 -6
- package/dist/tools-TSMXMHIF.js +0 -6
package/dist/index.js
CHANGED
|
@@ -1,449 +1,42 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
import
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
import
|
|
29
|
-
|
|
30
|
-
import {
|
|
31
|
-
|
|
1
|
+
export { ToolRegistry, createDefaultRegistry } from './chunk-SOQFMNQC.js';
|
|
2
|
+
export { SkillLoader, SkillRegistry } from './chunk-TDFTX32B.js';
|
|
3
|
+
export { SkillExecutor } from './chunk-QCRK4QEL.js';
|
|
4
|
+
export { SqliteStore } from './chunk-IARA5XYP.js';
|
|
5
|
+
export { ConversationStore } from './chunk-WC72BRHR.js';
|
|
6
|
+
export { LayoutEngine, TmuxManager } from './chunk-LDVY5ELP.js';
|
|
7
|
+
export { ContextManager, CostTracker, PermissionManager, TaskOrchestrator } from './chunk-ONQ4WCUI.js';
|
|
8
|
+
export { OllamaAdapter } from './chunk-2NWNIKBK.js';
|
|
9
|
+
export { AgentProcess, MessageBus, PlanApproval, TaskStore, TeamManager } from './chunk-LCYH4T6N.js';
|
|
10
|
+
import { getEventBus } from './chunk-ROJPFPJ7.js';
|
|
11
|
+
export { getEventBus } from './chunk-ROJPFPJ7.js';
|
|
12
|
+
export { MCPClient, MCPServerManager } from './chunk-2LF7ALGR.js';
|
|
13
|
+
export { ClaudeAdapter } from './chunk-CTFZTARK.js';
|
|
14
|
+
export { ClaudeNativeCLIAdapter, CodexNativeCLIAdapter, GeminiNativeCLIAdapter, KimiNativeCLIAdapter } from './chunk-RYOB3TLZ.js';
|
|
15
|
+
import './chunk-FIC7AK4Q.js';
|
|
16
|
+
export { OpenAIAdapter } from './chunk-P5TKZM3T.js';
|
|
17
|
+
export { GeminiAdapter } from './chunk-25UNNEHN.js';
|
|
18
|
+
import './chunk-ODBY7S4X.js';
|
|
19
|
+
export { KimiAdapter } from './chunk-YPFOE2QJ.js';
|
|
20
|
+
export { ModelRouter, createModelRouter } from './chunk-GU33WKPG.js';
|
|
21
|
+
export { ProviderRegistry } from './chunk-P66WDACW.js';
|
|
22
|
+
export { ConfigStore } from './chunk-5XFSV6PF.js';
|
|
23
|
+
import './chunk-CC7MGWYY.js';
|
|
24
|
+
export { SessionManager } from './chunk-H2SYKIMI.js';
|
|
25
|
+
import './chunk-6GUD7QIM.js';
|
|
26
|
+
export { CredentialStore } from './chunk-AQ23TYSQ.js';
|
|
27
|
+
import { withRetry, sleep } from './chunk-VJNQJALF.js';
|
|
28
|
+
import './chunk-VBLLDY4R.js';
|
|
29
|
+
export { DEFAULT_CONFIG } from './chunk-2GKOK6T7.js';
|
|
30
|
+
import { IPCError, AgentSpawnError, ToolCallError } from './chunk-473JN6M5.js';
|
|
31
|
+
export { AemeathError, AgentSpawnError, AuthenticationError, ContextOverflowError, ExecutionTimeoutError, FileNotFoundError, IPCError, InvalidConfigError, MissingConfigError, ModelNotFoundError, PermissionDeniedError, RateLimitError, ServerConnectionError, ToolCallError } from './chunk-473JN6M5.js';
|
|
32
|
+
export { DEFAULT_MODEL_ID, SUPPORTED_MODELS } from './chunk-62HSGYQD.js';
|
|
33
|
+
import { logger } from './chunk-HEKFAKVH.js';
|
|
34
|
+
import { getIPCSocketPath, ensureSecureDirectory, getIPCSocketDir } from './chunk-BY4DAKUU.js';
|
|
32
35
|
import { execa } from 'execa';
|
|
33
|
-
import {
|
|
36
|
+
import { connect, createServer } from 'net';
|
|
37
|
+
import { createHmac, randomBytes, timingSafeEqual } from 'crypto';
|
|
34
38
|
import { chmod, unlink } from 'fs/promises';
|
|
35
39
|
|
|
36
|
-
// src/storage/migrations/001-initial.ts
|
|
37
|
-
var CREATE_CONVERSATIONS = `
|
|
38
|
-
CREATE TABLE IF NOT EXISTS conversations (
|
|
39
|
-
id TEXT PRIMARY KEY,
|
|
40
|
-
project_root TEXT NOT NULL,
|
|
41
|
-
default_model TEXT,
|
|
42
|
-
created_at TEXT DEFAULT (datetime('now')),
|
|
43
|
-
updated_at TEXT DEFAULT (datetime('now')),
|
|
44
|
-
metadata TEXT DEFAULT '{}'
|
|
45
|
-
)`;
|
|
46
|
-
var CREATE_MESSAGES = `
|
|
47
|
-
CREATE TABLE IF NOT EXISTS messages (
|
|
48
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
49
|
-
conversation_id TEXT NOT NULL REFERENCES conversations(id) ON DELETE CASCADE,
|
|
50
|
-
role TEXT NOT NULL,
|
|
51
|
-
model TEXT,
|
|
52
|
-
provider TEXT,
|
|
53
|
-
content TEXT NOT NULL,
|
|
54
|
-
tool_calls TEXT,
|
|
55
|
-
token_usage TEXT,
|
|
56
|
-
created_at TEXT DEFAULT (datetime('now'))
|
|
57
|
-
)`;
|
|
58
|
-
var CREATE_FILE_CONTEXT = `
|
|
59
|
-
CREATE TABLE IF NOT EXISTS file_context (
|
|
60
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
61
|
-
conversation_id TEXT NOT NULL REFERENCES conversations(id) ON DELETE CASCADE,
|
|
62
|
-
file_path TEXT NOT NULL,
|
|
63
|
-
content_hash TEXT,
|
|
64
|
-
token_count INTEGER,
|
|
65
|
-
added_at TEXT DEFAULT (datetime('now'))
|
|
66
|
-
)`;
|
|
67
|
-
var CREATE_COST_TRACKING = `
|
|
68
|
-
CREATE TABLE IF NOT EXISTS cost_tracking (
|
|
69
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
70
|
-
conversation_id TEXT NOT NULL REFERENCES conversations(id) ON DELETE CASCADE,
|
|
71
|
-
provider TEXT NOT NULL,
|
|
72
|
-
model TEXT NOT NULL,
|
|
73
|
-
role TEXT,
|
|
74
|
-
input_tokens INTEGER,
|
|
75
|
-
output_tokens INTEGER,
|
|
76
|
-
cost_usd REAL,
|
|
77
|
-
created_at TEXT DEFAULT (datetime('now'))
|
|
78
|
-
)`;
|
|
79
|
-
var CREATE_TEAMS = `
|
|
80
|
-
CREATE TABLE IF NOT EXISTS teams (
|
|
81
|
-
id TEXT PRIMARY KEY,
|
|
82
|
-
name TEXT NOT NULL,
|
|
83
|
-
status TEXT DEFAULT 'active',
|
|
84
|
-
config TEXT,
|
|
85
|
-
created_at TEXT DEFAULT (datetime('now'))
|
|
86
|
-
)`;
|
|
87
|
-
var CREATE_INDEXES = [
|
|
88
|
-
"CREATE INDEX IF NOT EXISTS idx_messages_conversation ON messages(conversation_id)",
|
|
89
|
-
"CREATE INDEX IF NOT EXISTS idx_cost_conversation ON cost_tracking(conversation_id)",
|
|
90
|
-
"CREATE INDEX IF NOT EXISTS idx_cost_provider ON cost_tracking(provider)",
|
|
91
|
-
"CREATE INDEX IF NOT EXISTS idx_file_context_conversation ON file_context(conversation_id)"
|
|
92
|
-
];
|
|
93
|
-
function up(db) {
|
|
94
|
-
db.transaction(() => {
|
|
95
|
-
db.exec(CREATE_CONVERSATIONS);
|
|
96
|
-
db.exec(CREATE_MESSAGES);
|
|
97
|
-
db.exec(CREATE_FILE_CONTEXT);
|
|
98
|
-
db.exec(CREATE_COST_TRACKING);
|
|
99
|
-
db.exec(CREATE_TEAMS);
|
|
100
|
-
for (const sql of CREATE_INDEXES) {
|
|
101
|
-
db.exec(sql);
|
|
102
|
-
}
|
|
103
|
-
})();
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// src/storage/sqlite-store.ts
|
|
107
|
-
var MIGRATIONS_TABLE_DDL = `
|
|
108
|
-
CREATE TABLE IF NOT EXISTS _migrations (
|
|
109
|
-
id TEXT PRIMARY KEY,
|
|
110
|
-
applied_at TEXT DEFAULT (datetime('now'))
|
|
111
|
-
)`;
|
|
112
|
-
var MIGRATIONS = [
|
|
113
|
-
{ id: "001-initial", up }
|
|
114
|
-
];
|
|
115
|
-
var SqliteStore = class {
|
|
116
|
-
db;
|
|
117
|
-
closed = false;
|
|
118
|
-
get database() {
|
|
119
|
-
if (this.closed || !this.db) {
|
|
120
|
-
throw new Error("SqliteStore is closed or not initialized");
|
|
121
|
-
}
|
|
122
|
-
return this.db;
|
|
123
|
-
}
|
|
124
|
-
open(dbPath) {
|
|
125
|
-
if (this.db) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
const resolvedPath = dbPath ?? getDatabasePath();
|
|
129
|
-
ensureDirectory(getDatabaseDir());
|
|
130
|
-
logger.info({ path: resolvedPath }, "Opening SQLite database");
|
|
131
|
-
this.db = new Database(resolvedPath);
|
|
132
|
-
this.db.pragma("journal_mode = WAL");
|
|
133
|
-
this.db.pragma("busy_timeout = 5000");
|
|
134
|
-
this.db.pragma("foreign_keys = ON");
|
|
135
|
-
this.db.pragma("synchronous = NORMAL");
|
|
136
|
-
try {
|
|
137
|
-
chmodSync(resolvedPath, 384);
|
|
138
|
-
} catch {
|
|
139
|
-
logger.warn(
|
|
140
|
-
{ path: resolvedPath },
|
|
141
|
-
"Could not set database file permissions to 600"
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
this.runMigrations();
|
|
145
|
-
this.registerCleanupHandlers();
|
|
146
|
-
}
|
|
147
|
-
runMigrations() {
|
|
148
|
-
const db = this.database;
|
|
149
|
-
db.exec(MIGRATIONS_TABLE_DDL);
|
|
150
|
-
const appliedStmt = db.prepare(
|
|
151
|
-
"SELECT id FROM _migrations WHERE id = ?"
|
|
152
|
-
);
|
|
153
|
-
const insertStmt = db.prepare(
|
|
154
|
-
"INSERT INTO _migrations (id) VALUES (?)"
|
|
155
|
-
);
|
|
156
|
-
for (const migration of MIGRATIONS) {
|
|
157
|
-
const existing = appliedStmt.get(migration.id);
|
|
158
|
-
if (!existing) {
|
|
159
|
-
logger.info({ migrationId: migration.id }, "Running migration");
|
|
160
|
-
db.transaction(() => {
|
|
161
|
-
migration.up(db);
|
|
162
|
-
insertStmt.run(migration.id);
|
|
163
|
-
})();
|
|
164
|
-
logger.info({ migrationId: migration.id }, "Migration applied");
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
prepare(sql) {
|
|
169
|
-
return this.database.prepare(sql);
|
|
170
|
-
}
|
|
171
|
-
run(sql, ...params) {
|
|
172
|
-
return this.database.prepare(sql).run(...params);
|
|
173
|
-
}
|
|
174
|
-
get(sql, ...params) {
|
|
175
|
-
return this.database.prepare(sql).get(...params);
|
|
176
|
-
}
|
|
177
|
-
all(sql, ...params) {
|
|
178
|
-
return this.database.prepare(sql).all(...params);
|
|
179
|
-
}
|
|
180
|
-
transaction(fn) {
|
|
181
|
-
return this.database.transaction(fn)();
|
|
182
|
-
}
|
|
183
|
-
close() {
|
|
184
|
-
if (this.closed || !this.db) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
logger.info("Closing SQLite database");
|
|
188
|
-
this.closed = true;
|
|
189
|
-
try {
|
|
190
|
-
this.db.pragma("wal_checkpoint(TRUNCATE)");
|
|
191
|
-
this.db.close();
|
|
192
|
-
} catch (error) {
|
|
193
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
194
|
-
logger.error({ error: message }, "Error closing database");
|
|
195
|
-
}
|
|
196
|
-
this.db = void 0;
|
|
197
|
-
}
|
|
198
|
-
registerCleanupHandlers() {
|
|
199
|
-
const cleanup = () => {
|
|
200
|
-
this.close();
|
|
201
|
-
};
|
|
202
|
-
process.on("exit", cleanup);
|
|
203
|
-
process.on("SIGINT", () => {
|
|
204
|
-
cleanup();
|
|
205
|
-
process.exit(130);
|
|
206
|
-
});
|
|
207
|
-
process.on("SIGTERM", () => {
|
|
208
|
-
cleanup();
|
|
209
|
-
process.exit(143);
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
var ConversationStore = class {
|
|
214
|
-
store;
|
|
215
|
-
constructor(store) {
|
|
216
|
-
this.store = store;
|
|
217
|
-
}
|
|
218
|
-
createConversation(projectRoot, defaultModel, metadata) {
|
|
219
|
-
const id = randomUUID();
|
|
220
|
-
const metadataJson = JSON.stringify(metadata ?? {});
|
|
221
|
-
this.store.run(
|
|
222
|
-
`INSERT INTO conversations (id, project_root, default_model, metadata)
|
|
223
|
-
VALUES (?, ?, ?, ?)`,
|
|
224
|
-
id,
|
|
225
|
-
projectRoot,
|
|
226
|
-
defaultModel ?? null,
|
|
227
|
-
metadataJson
|
|
228
|
-
);
|
|
229
|
-
logger.info({ conversationId: id, projectRoot }, "Conversation created");
|
|
230
|
-
const row = this.store.get(
|
|
231
|
-
"SELECT * FROM conversations WHERE id = ?",
|
|
232
|
-
id
|
|
233
|
-
);
|
|
234
|
-
if (!row) {
|
|
235
|
-
throw new Error(`Failed to retrieve created conversation: ${id}`);
|
|
236
|
-
}
|
|
237
|
-
return this.mapConversationRow(row);
|
|
238
|
-
}
|
|
239
|
-
getConversation(id) {
|
|
240
|
-
const row = this.store.get(
|
|
241
|
-
"SELECT * FROM conversations WHERE id = ?",
|
|
242
|
-
id
|
|
243
|
-
);
|
|
244
|
-
return row ? this.mapConversationRow(row) : void 0;
|
|
245
|
-
}
|
|
246
|
-
listConversations(projectRoot) {
|
|
247
|
-
const rows = projectRoot ? this.store.all(
|
|
248
|
-
"SELECT * FROM conversations WHERE project_root = ? ORDER BY updated_at DESC",
|
|
249
|
-
projectRoot
|
|
250
|
-
) : this.store.all(
|
|
251
|
-
"SELECT * FROM conversations ORDER BY updated_at DESC"
|
|
252
|
-
);
|
|
253
|
-
return rows.map((row) => this.mapConversationRow(row));
|
|
254
|
-
}
|
|
255
|
-
deleteConversation(id) {
|
|
256
|
-
this.store.run("DELETE FROM conversations WHERE id = ?", id);
|
|
257
|
-
logger.info({ conversationId: id }, "Conversation deleted");
|
|
258
|
-
}
|
|
259
|
-
addMessage(params) {
|
|
260
|
-
const toolCallsJson = params.toolCalls ? JSON.stringify(params.toolCalls) : null;
|
|
261
|
-
const tokenUsageJson = params.tokenUsage ? JSON.stringify(params.tokenUsage) : null;
|
|
262
|
-
const result = this.store.run(
|
|
263
|
-
`INSERT INTO messages
|
|
264
|
-
(conversation_id, role, model, provider, content, tool_calls, token_usage)
|
|
265
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
|
266
|
-
params.conversationId,
|
|
267
|
-
params.role,
|
|
268
|
-
params.model ?? null,
|
|
269
|
-
params.provider ?? null,
|
|
270
|
-
params.content,
|
|
271
|
-
toolCallsJson,
|
|
272
|
-
tokenUsageJson
|
|
273
|
-
);
|
|
274
|
-
this.store.run(
|
|
275
|
-
"UPDATE conversations SET updated_at = datetime('now') WHERE id = ?",
|
|
276
|
-
params.conversationId
|
|
277
|
-
);
|
|
278
|
-
const row = this.store.get(
|
|
279
|
-
"SELECT * FROM messages WHERE id = ?",
|
|
280
|
-
result.lastInsertRowid
|
|
281
|
-
);
|
|
282
|
-
if (!row) {
|
|
283
|
-
throw new Error("Failed to retrieve created message");
|
|
284
|
-
}
|
|
285
|
-
return this.mapMessageRow(row);
|
|
286
|
-
}
|
|
287
|
-
getMessages(conversationId, pagination) {
|
|
288
|
-
const limit = pagination?.limit ?? 100;
|
|
289
|
-
const offset = pagination?.offset ?? 0;
|
|
290
|
-
const rows = this.store.all(
|
|
291
|
-
`SELECT * FROM messages
|
|
292
|
-
WHERE conversation_id = ?
|
|
293
|
-
ORDER BY created_at ASC
|
|
294
|
-
LIMIT ? OFFSET ?`,
|
|
295
|
-
conversationId,
|
|
296
|
-
limit,
|
|
297
|
-
offset
|
|
298
|
-
);
|
|
299
|
-
return rows.map((row) => this.mapMessageRow(row));
|
|
300
|
-
}
|
|
301
|
-
getMessageCount(conversationId) {
|
|
302
|
-
const result = this.store.get(
|
|
303
|
-
"SELECT COUNT(*) as count FROM messages WHERE conversation_id = ?",
|
|
304
|
-
conversationId
|
|
305
|
-
);
|
|
306
|
-
return result?.count ?? 0;
|
|
307
|
-
}
|
|
308
|
-
addFileContext(params) {
|
|
309
|
-
const result = this.store.run(
|
|
310
|
-
`INSERT INTO file_context
|
|
311
|
-
(conversation_id, file_path, content_hash, token_count)
|
|
312
|
-
VALUES (?, ?, ?, ?)`,
|
|
313
|
-
params.conversationId,
|
|
314
|
-
params.filePath,
|
|
315
|
-
params.contentHash ?? null,
|
|
316
|
-
params.tokenCount ?? null
|
|
317
|
-
);
|
|
318
|
-
const row = this.store.get(
|
|
319
|
-
"SELECT * FROM file_context WHERE id = ?",
|
|
320
|
-
result.lastInsertRowid
|
|
321
|
-
);
|
|
322
|
-
if (!row) {
|
|
323
|
-
throw new Error("Failed to retrieve created file context");
|
|
324
|
-
}
|
|
325
|
-
return this.mapFileContextRow(row);
|
|
326
|
-
}
|
|
327
|
-
getFileContext(conversationId) {
|
|
328
|
-
const rows = this.store.all(
|
|
329
|
-
"SELECT * FROM file_context WHERE conversation_id = ? ORDER BY added_at DESC",
|
|
330
|
-
conversationId
|
|
331
|
-
);
|
|
332
|
-
return rows.map((row) => this.mapFileContextRow(row));
|
|
333
|
-
}
|
|
334
|
-
removeFileContext(conversationId, filePath) {
|
|
335
|
-
this.store.run(
|
|
336
|
-
"DELETE FROM file_context WHERE conversation_id = ? AND file_path = ?",
|
|
337
|
-
conversationId,
|
|
338
|
-
filePath
|
|
339
|
-
);
|
|
340
|
-
}
|
|
341
|
-
addCost(params) {
|
|
342
|
-
const result = this.store.run(
|
|
343
|
-
`INSERT INTO cost_tracking
|
|
344
|
-
(conversation_id, provider, model, role, input_tokens, output_tokens, cost_usd)
|
|
345
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
|
346
|
-
params.conversationId,
|
|
347
|
-
params.provider,
|
|
348
|
-
params.model,
|
|
349
|
-
params.role ?? null,
|
|
350
|
-
params.inputTokens ?? null,
|
|
351
|
-
params.outputTokens ?? null,
|
|
352
|
-
params.costUsd ?? null
|
|
353
|
-
);
|
|
354
|
-
const row = this.store.get(
|
|
355
|
-
"SELECT * FROM cost_tracking WHERE id = ?",
|
|
356
|
-
result.lastInsertRowid
|
|
357
|
-
);
|
|
358
|
-
if (!row) {
|
|
359
|
-
throw new Error("Failed to retrieve created cost entry");
|
|
360
|
-
}
|
|
361
|
-
return this.mapCostRow(row);
|
|
362
|
-
}
|
|
363
|
-
getConversationCost(conversationId) {
|
|
364
|
-
const result = this.store.get(
|
|
365
|
-
"SELECT SUM(cost_usd) as total FROM cost_tracking WHERE conversation_id = ?",
|
|
366
|
-
conversationId
|
|
367
|
-
);
|
|
368
|
-
return result?.total ?? 0;
|
|
369
|
-
}
|
|
370
|
-
getCostBreakdown(conversationId) {
|
|
371
|
-
const rows = this.store.all(
|
|
372
|
-
"SELECT * FROM cost_tracking WHERE conversation_id = ? ORDER BY created_at ASC",
|
|
373
|
-
conversationId
|
|
374
|
-
);
|
|
375
|
-
return rows.map((row) => this.mapCostRow(row));
|
|
376
|
-
}
|
|
377
|
-
// ── Private row mappers ─────────────────────────────────────────────
|
|
378
|
-
mapConversationRow(row) {
|
|
379
|
-
let metadata = {};
|
|
380
|
-
try {
|
|
381
|
-
metadata = JSON.parse(row.metadata);
|
|
382
|
-
} catch {
|
|
383
|
-
metadata = {};
|
|
384
|
-
}
|
|
385
|
-
return {
|
|
386
|
-
id: row.id,
|
|
387
|
-
projectRoot: row.project_root,
|
|
388
|
-
defaultModel: row.default_model,
|
|
389
|
-
createdAt: row.created_at,
|
|
390
|
-
updatedAt: row.updated_at,
|
|
391
|
-
metadata
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
mapMessageRow(row) {
|
|
395
|
-
let toolCalls = null;
|
|
396
|
-
if (row.tool_calls) {
|
|
397
|
-
try {
|
|
398
|
-
toolCalls = JSON.parse(row.tool_calls);
|
|
399
|
-
} catch {
|
|
400
|
-
toolCalls = null;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
let tokenUsage = null;
|
|
404
|
-
if (row.token_usage) {
|
|
405
|
-
try {
|
|
406
|
-
tokenUsage = JSON.parse(row.token_usage);
|
|
407
|
-
} catch {
|
|
408
|
-
tokenUsage = null;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
return {
|
|
412
|
-
id: row.id,
|
|
413
|
-
conversationId: row.conversation_id,
|
|
414
|
-
role: row.role,
|
|
415
|
-
model: row.model,
|
|
416
|
-
provider: row.provider,
|
|
417
|
-
content: row.content,
|
|
418
|
-
toolCalls,
|
|
419
|
-
tokenUsage,
|
|
420
|
-
createdAt: row.created_at
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
mapFileContextRow(row) {
|
|
424
|
-
return {
|
|
425
|
-
id: row.id,
|
|
426
|
-
conversationId: row.conversation_id,
|
|
427
|
-
filePath: row.file_path,
|
|
428
|
-
contentHash: row.content_hash,
|
|
429
|
-
tokenCount: row.token_count,
|
|
430
|
-
addedAt: row.added_at
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
mapCostRow(row) {
|
|
434
|
-
return {
|
|
435
|
-
id: row.id,
|
|
436
|
-
conversationId: row.conversation_id,
|
|
437
|
-
provider: row.provider,
|
|
438
|
-
model: row.model,
|
|
439
|
-
role: row.role,
|
|
440
|
-
inputTokens: row.input_tokens,
|
|
441
|
-
outputTokens: row.output_tokens,
|
|
442
|
-
costUsd: row.cost_usd,
|
|
443
|
-
createdAt: row.created_at
|
|
444
|
-
};
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
40
|
var ROLE_PROFILES = {
|
|
448
41
|
planning: { backgroundColor: "#1a1a2e", badgeText: "Planner" },
|
|
449
42
|
coding: { backgroundColor: "#162447", badgeText: "Coder" },
|
|
@@ -725,19 +318,23 @@ var IPCHub = class {
|
|
|
725
318
|
ensureSecureDirectory(getIPCSocketDir());
|
|
726
319
|
await this.removeStaleSocket();
|
|
727
320
|
return new Promise((resolve, reject) => {
|
|
728
|
-
this.server = createServer((socket) =>
|
|
321
|
+
this.server = createServer((socket) => {
|
|
322
|
+
this.handleConnection(socket);
|
|
323
|
+
});
|
|
729
324
|
this.server.on("error", (err) => {
|
|
730
325
|
logger.error({ error: err.message }, "IPC server error");
|
|
731
326
|
reject(new IPCError(`Server error: ${err.message}`));
|
|
732
327
|
});
|
|
733
|
-
this.server.listen(this.socketPath,
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
328
|
+
this.server.listen(this.socketPath, () => {
|
|
329
|
+
void (async () => {
|
|
330
|
+
try {
|
|
331
|
+
await chmod(this.socketPath, SOCKET_PERMS);
|
|
332
|
+
} catch {
|
|
333
|
+
}
|
|
334
|
+
logger.info({ socketPath: this.socketPath }, "IPC hub listening");
|
|
335
|
+
this.setupProcessCleanup();
|
|
336
|
+
resolve();
|
|
337
|
+
})();
|
|
741
338
|
});
|
|
742
339
|
});
|
|
743
340
|
}
|
|
@@ -780,8 +377,11 @@ var IPCHub = class {
|
|
|
780
377
|
}
|
|
781
378
|
this.clients.clear();
|
|
782
379
|
if (this.server) {
|
|
783
|
-
|
|
784
|
-
|
|
380
|
+
const server = this.server;
|
|
381
|
+
await new Promise((resolve) => {
|
|
382
|
+
server.close(() => {
|
|
383
|
+
resolve();
|
|
384
|
+
});
|
|
785
385
|
});
|
|
786
386
|
this.server = void 0;
|
|
787
387
|
}
|
|
@@ -833,12 +433,13 @@ var IPCHub = class {
|
|
|
833
433
|
return void 0;
|
|
834
434
|
}
|
|
835
435
|
const { message, hmac } = parsed;
|
|
436
|
+
const requestId = this.getRequestId(message);
|
|
836
437
|
if (!this.verifyHmac(message, hmac)) {
|
|
837
|
-
this.sendError(socket,
|
|
438
|
+
this.sendError(socket, requestId, RPC_AUTH_ERROR, "Authentication failed");
|
|
838
439
|
return void 0;
|
|
839
440
|
}
|
|
840
|
-
if (
|
|
841
|
-
this.sendError(socket,
|
|
441
|
+
if (!this.isIPCMessage(message)) {
|
|
442
|
+
this.sendError(socket, requestId, RPC_INVALID_REQ, "Invalid JSON-RPC 2.0");
|
|
842
443
|
return void 0;
|
|
843
444
|
}
|
|
844
445
|
const handler = this.handlers.get(message.method);
|
|
@@ -858,7 +459,7 @@ var IPCHub = class {
|
|
|
858
459
|
}
|
|
859
460
|
// ── Default Handlers ──────────────────────────────────────────────
|
|
860
461
|
registerDefaultHandlers() {
|
|
861
|
-
this.handlers.set("agent.register",
|
|
462
|
+
this.handlers.set("agent.register", (_cid, params, _id, socket) => {
|
|
862
463
|
const agentId = params["agentId"];
|
|
863
464
|
const agentName = params["agentName"];
|
|
864
465
|
if (!agentId || !agentName) throw new IPCError("agent.register requires agentId and agentName");
|
|
@@ -866,20 +467,20 @@ var IPCHub = class {
|
|
|
866
467
|
logger.info({ agentId, agentName }, "Agent registered");
|
|
867
468
|
return { registered: true, agentId };
|
|
868
469
|
});
|
|
869
|
-
this.handlers.set("agent.streamChunk",
|
|
470
|
+
this.handlers.set("agent.streamChunk", (_cid, params) => {
|
|
870
471
|
getEventBus().emit("model:stream:chunk", {
|
|
871
472
|
model: params["model"] ?? "unknown",
|
|
872
473
|
content: params["content"] ?? ""
|
|
873
474
|
});
|
|
874
475
|
return { received: true };
|
|
875
476
|
});
|
|
876
|
-
this.handlers.set("agent.taskUpdate",
|
|
477
|
+
this.handlers.set("agent.taskUpdate", (_cid, params) => {
|
|
877
478
|
const taskId = params["taskId"];
|
|
878
479
|
const status = params["status"];
|
|
879
480
|
if (taskId && status) getEventBus().emit("task:updated", { taskId, status });
|
|
880
481
|
return { received: true };
|
|
881
482
|
});
|
|
882
|
-
this.handlers.set("agent.message",
|
|
483
|
+
this.handlers.set("agent.message", (_cid, params) => {
|
|
883
484
|
const to = params["to"];
|
|
884
485
|
const content = params["content"];
|
|
885
486
|
const from = params["from"];
|
|
@@ -892,7 +493,7 @@ var IPCHub = class {
|
|
|
892
493
|
}
|
|
893
494
|
return { delivered: this.clients.has(to ?? "") };
|
|
894
495
|
});
|
|
895
|
-
this.handlers.set("hub.taskAssign",
|
|
496
|
+
this.handlers.set("hub.taskAssign", (_cid, params) => {
|
|
896
497
|
const agentId = params["agentId"];
|
|
897
498
|
const taskId = params["taskId"];
|
|
898
499
|
if (agentId && taskId) {
|
|
@@ -901,7 +502,7 @@ var IPCHub = class {
|
|
|
901
502
|
}
|
|
902
503
|
return { assigned: this.clients.has(agentId ?? "") };
|
|
903
504
|
});
|
|
904
|
-
this.handlers.set("hub.shutdown",
|
|
505
|
+
this.handlers.set("hub.shutdown", (_cid, params) => {
|
|
905
506
|
const agentId = params["agentId"];
|
|
906
507
|
if (agentId) {
|
|
907
508
|
const target = this.clients.get(agentId);
|
|
@@ -927,6 +528,16 @@ var IPCHub = class {
|
|
|
927
528
|
const o = v;
|
|
928
529
|
return typeof o["hmac"] === "string" && typeof o["message"] === "object" && o["message"] !== null;
|
|
929
530
|
}
|
|
531
|
+
isIPCMessage(v) {
|
|
532
|
+
if (typeof v !== "object" || v === null) return false;
|
|
533
|
+
const o = v;
|
|
534
|
+
return o["jsonrpc"] === "2.0" && typeof o["method"] === "string" && typeof o["params"] === "object" && o["params"] !== null;
|
|
535
|
+
}
|
|
536
|
+
getRequestId(v) {
|
|
537
|
+
if (typeof v !== "object" || v === null) return void 0;
|
|
538
|
+
const o = v;
|
|
539
|
+
return typeof o["id"] === "number" ? o["id"] : void 0;
|
|
540
|
+
}
|
|
930
541
|
// ── I/O ───────────────────────────────────────────────────────────
|
|
931
542
|
write(socket, msg) {
|
|
932
543
|
if (!socket.destroyed) socket.write(JSON.stringify(msg) + "\n");
|
|
@@ -961,7 +572,8 @@ var DEFAULT_HEARTBEAT_MS = 15e3;
|
|
|
961
572
|
var DEFAULT_RECONNECT_RETRIES = 5;
|
|
962
573
|
var REQUEST_TIMEOUT_MS = 3e4;
|
|
963
574
|
var NEWLINE2 = 10;
|
|
964
|
-
var PaneProcess = class {
|
|
575
|
+
var PaneProcess = class _PaneProcess {
|
|
576
|
+
static resolvedPromise = Promise.resolve();
|
|
965
577
|
agentId;
|
|
966
578
|
agentName;
|
|
967
579
|
socketPath;
|
|
@@ -1038,8 +650,10 @@ var PaneProcess = class {
|
|
|
1038
650
|
return this.connected && !this.disposed;
|
|
1039
651
|
}
|
|
1040
652
|
/** Gracefully disconnect from the hub. */
|
|
1041
|
-
|
|
1042
|
-
if (this.disposed)
|
|
653
|
+
disconnect() {
|
|
654
|
+
if (this.disposed) {
|
|
655
|
+
return _PaneProcess.resolvedPromise;
|
|
656
|
+
}
|
|
1043
657
|
this.disposed = true;
|
|
1044
658
|
this.stopHeartbeat();
|
|
1045
659
|
this.rejectAll();
|
|
@@ -1049,6 +663,7 @@ var PaneProcess = class {
|
|
|
1049
663
|
}
|
|
1050
664
|
this.connected = false;
|
|
1051
665
|
logger.info({ agentId: this.agentId }, "PaneProcess disconnected");
|
|
666
|
+
return _PaneProcess.resolvedPromise;
|
|
1052
667
|
}
|
|
1053
668
|
// ── Connection ────────────────────────────────────────────────────
|
|
1054
669
|
async establish() {
|
|
@@ -1081,7 +696,7 @@ var PaneProcess = class {
|
|
|
1081
696
|
this.connected = false;
|
|
1082
697
|
if (!this.disposed) {
|
|
1083
698
|
logger.warn({ agentId: this.agentId }, "Connection lost, reconnecting");
|
|
1084
|
-
this.attemptReconnect();
|
|
699
|
+
void this.attemptReconnect();
|
|
1085
700
|
}
|
|
1086
701
|
});
|
|
1087
702
|
socket.on("error", (err) => {
|
|
@@ -1150,7 +765,7 @@ var PaneProcess = class {
|
|
|
1150
765
|
this.notify("agent.streamChunk", { content: "", model: "heartbeat", heartbeat: true });
|
|
1151
766
|
}
|
|
1152
767
|
}, this.heartbeatMs);
|
|
1153
|
-
|
|
768
|
+
this.heartbeatTimer.unref();
|
|
1154
769
|
}
|
|
1155
770
|
stopHeartbeat() {
|
|
1156
771
|
if (this.heartbeatTimer) {
|
|
@@ -1399,8 +1014,8 @@ var MCPToolBridge = class {
|
|
|
1399
1014
|
return {
|
|
1400
1015
|
definition,
|
|
1401
1016
|
category: MCP_CATEGORY,
|
|
1402
|
-
requiresApproval: (
|
|
1403
|
-
return
|
|
1017
|
+
requiresApproval: (context, _args) => {
|
|
1018
|
+
return context.permissionMode === "strict";
|
|
1404
1019
|
},
|
|
1405
1020
|
execute: async (args) => {
|
|
1406
1021
|
const call = {
|
|
@@ -1414,6 +1029,6 @@ var MCPToolBridge = class {
|
|
|
1414
1029
|
}
|
|
1415
1030
|
};
|
|
1416
1031
|
|
|
1417
|
-
export {
|
|
1032
|
+
export { IPCHub, ITerm2Manager, MCPToolBridge, PaneProcess };
|
|
1418
1033
|
//# sourceMappingURL=index.js.map
|
|
1419
1034
|
//# sourceMappingURL=index.js.map
|