247-cli 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -0
- package/agent/dist/config.d.ts +29 -0
- package/agent/dist/config.d.ts.map +1 -0
- package/agent/dist/config.js +56 -0
- package/agent/dist/config.js.map +1 -0
- package/agent/dist/db/environments.d.ts +60 -0
- package/agent/dist/db/environments.d.ts.map +1 -0
- package/agent/dist/db/environments.js +235 -0
- package/agent/dist/db/environments.js.map +1 -0
- package/agent/dist/db/history.d.ts +37 -0
- package/agent/dist/db/history.d.ts.map +1 -0
- package/agent/dist/db/history.js +98 -0
- package/agent/dist/db/history.js.map +1 -0
- package/agent/dist/db/index.d.ts +37 -0
- package/agent/dist/db/index.d.ts.map +1 -0
- package/agent/dist/db/index.js +225 -0
- package/agent/dist/db/index.js.map +1 -0
- package/agent/dist/db/schema.d.ts +70 -0
- package/agent/dist/db/schema.d.ts.map +1 -0
- package/agent/dist/db/schema.js +79 -0
- package/agent/dist/db/schema.js.map +1 -0
- package/agent/dist/db/sessions.d.ts +75 -0
- package/agent/dist/db/sessions.d.ts.map +1 -0
- package/agent/dist/db/sessions.js +244 -0
- package/agent/dist/db/sessions.js.map +1 -0
- package/agent/dist/editor.d.ts +18 -0
- package/agent/dist/editor.d.ts.map +1 -0
- package/agent/dist/editor.js +222 -0
- package/agent/dist/editor.js.map +1 -0
- package/agent/dist/environments.d.ts +59 -0
- package/agent/dist/environments.d.ts.map +1 -0
- package/agent/dist/environments.js +229 -0
- package/agent/dist/environments.js.map +1 -0
- package/agent/dist/git.d.ts +39 -0
- package/agent/dist/git.d.ts.map +1 -0
- package/agent/dist/git.js +436 -0
- package/agent/dist/git.js.map +1 -0
- package/agent/dist/index.d.ts +2 -0
- package/agent/dist/index.d.ts.map +1 -0
- package/agent/dist/index.js +18 -0
- package/agent/dist/index.js.map +1 -0
- package/agent/dist/logger.d.ts +15 -0
- package/agent/dist/logger.d.ts.map +1 -0
- package/agent/dist/logger.js +44 -0
- package/agent/dist/logger.js.map +1 -0
- package/agent/dist/routes/editor.d.ts +9 -0
- package/agent/dist/routes/editor.d.ts.map +1 -0
- package/agent/dist/routes/editor.js +63 -0
- package/agent/dist/routes/editor.js.map +1 -0
- package/agent/dist/routes/environments.d.ts +6 -0
- package/agent/dist/routes/environments.d.ts.map +1 -0
- package/agent/dist/routes/environments.js +94 -0
- package/agent/dist/routes/environments.js.map +1 -0
- package/agent/dist/routes/files.d.ts +6 -0
- package/agent/dist/routes/files.d.ts.map +1 -0
- package/agent/dist/routes/files.js +84 -0
- package/agent/dist/routes/files.js.map +1 -0
- package/agent/dist/routes/hooks.d.ts +6 -0
- package/agent/dist/routes/hooks.d.ts.map +1 -0
- package/agent/dist/routes/hooks.js +80 -0
- package/agent/dist/routes/hooks.js.map +1 -0
- package/agent/dist/routes/index.d.ts +10 -0
- package/agent/dist/routes/index.d.ts.map +1 -0
- package/agent/dist/routes/index.js +10 -0
- package/agent/dist/routes/index.js.map +1 -0
- package/agent/dist/routes/projects.d.ts +6 -0
- package/agent/dist/routes/projects.d.ts.map +1 -0
- package/agent/dist/routes/projects.js +69 -0
- package/agent/dist/routes/projects.js.map +1 -0
- package/agent/dist/routes/sessions.d.ts +6 -0
- package/agent/dist/routes/sessions.d.ts.map +1 -0
- package/agent/dist/routes/sessions.js +194 -0
- package/agent/dist/routes/sessions.js.map +1 -0
- package/agent/dist/server.d.ts +6 -0
- package/agent/dist/server.d.ts.map +1 -0
- package/agent/dist/server.js +129 -0
- package/agent/dist/server.js.map +1 -0
- package/agent/dist/status.d.ts +42 -0
- package/agent/dist/status.d.ts.map +1 -0
- package/agent/dist/status.js +134 -0
- package/agent/dist/status.js.map +1 -0
- package/agent/dist/terminal.d.ts +15 -0
- package/agent/dist/terminal.d.ts.map +1 -0
- package/agent/dist/terminal.js +135 -0
- package/agent/dist/terminal.js.map +1 -0
- package/agent/dist/websocket-handlers.d.ts +13 -0
- package/agent/dist/websocket-handlers.d.ts.map +1 -0
- package/agent/dist/websocket-handlers.js +266 -0
- package/agent/dist/websocket-handlers.js.map +1 -0
- package/agent/node_modules/247-shared/dist/index.d.ts +2 -0
- package/agent/node_modules/247-shared/dist/index.d.ts.map +1 -0
- package/agent/node_modules/247-shared/dist/index.js +2 -0
- package/agent/node_modules/247-shared/dist/index.js.map +1 -0
- package/agent/node_modules/247-shared/dist/types/index.d.ts +215 -0
- package/agent/node_modules/247-shared/dist/types/index.d.ts.map +1 -0
- package/agent/node_modules/247-shared/dist/types/index.js +48 -0
- package/agent/node_modules/247-shared/dist/types/index.js.map +1 -0
- package/agent/node_modules/247-shared/package.json +29 -0
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +279 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/hooks.d.ts +3 -0
- package/dist/commands/hooks.d.ts.map +1 -0
- package/dist/commands/hooks.js +127 -0
- package/dist/commands/hooks.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +130 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/logs.d.ts +3 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +38 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/profile.d.ts +3 -0
- package/dist/commands/profile.d.ts.map +1 -0
- package/dist/commands/profile.js +156 -0
- package/dist/commands/profile.js.map +1 -0
- package/dist/commands/service.d.ts +3 -0
- package/dist/commands/service.d.ts.map +1 -0
- package/dist/commands/service.js +235 -0
- package/dist/commands/service.js.map +1 -0
- package/dist/commands/start.d.ts +3 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +120 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +62 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/stop.d.ts +3 -0
- package/dist/commands/stop.d.ts.map +1 -0
- package/dist/commands/stop.js +23 -0
- package/dist/commands/stop.js.map +1 -0
- package/dist/commands/update.d.ts +3 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +121 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/hooks/installer.d.ts +36 -0
- package/dist/hooks/installer.d.ts.map +1 -0
- package/dist/hooks/installer.js +175 -0
- package/dist/hooks/installer.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/config.d.ts +71 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +161 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/paths.d.ts +34 -0
- package/dist/lib/paths.d.ts.map +1 -0
- package/dist/lib/paths.js +76 -0
- package/dist/lib/paths.js.map +1 -0
- package/dist/lib/prerequisites.d.ts +36 -0
- package/dist/lib/prerequisites.d.ts.map +1 -0
- package/dist/lib/prerequisites.js +181 -0
- package/dist/lib/prerequisites.js.map +1 -0
- package/dist/lib/process.d.ts +40 -0
- package/dist/lib/process.d.ts.map +1 -0
- package/dist/lib/process.js +192 -0
- package/dist/lib/process.js.map +1 -0
- package/dist/service/index.d.ts +44 -0
- package/dist/service/index.d.ts.map +1 -0
- package/dist/service/index.js +18 -0
- package/dist/service/index.js.map +1 -0
- package/dist/service/launchd.d.ts +18 -0
- package/dist/service/launchd.d.ts.map +1 -0
- package/dist/service/launchd.js +208 -0
- package/dist/service/launchd.js.map +1 -0
- package/dist/service/systemd.d.ts +18 -0
- package/dist/service/systemd.d.ts.map +1 -0
- package/dist/service/systemd.js +196 -0
- package/dist/service/systemd.js.map +1 -0
- package/hooks/.claude-plugin/plugin.json +5 -0
- package/hooks/hooks/hooks.json +66 -0
- package/hooks/scripts/check-duplication.sh +91 -0
- package/hooks/scripts/notify-status.sh +89 -0
- package/package.json +77 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync, readdirSync, unlinkSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { randomUUID } from 'crypto';
|
|
4
|
+
import { getAgentPaths, ensureDirectories } from './paths.js';
|
|
5
|
+
const DEFAULT_CONFIG = {
|
|
6
|
+
machine: {
|
|
7
|
+
id: '',
|
|
8
|
+
name: '',
|
|
9
|
+
},
|
|
10
|
+
agent: {
|
|
11
|
+
port: 4678,
|
|
12
|
+
},
|
|
13
|
+
projects: {
|
|
14
|
+
basePath: '~/Dev',
|
|
15
|
+
whitelist: [],
|
|
16
|
+
},
|
|
17
|
+
editor: {
|
|
18
|
+
enabled: false,
|
|
19
|
+
portRange: { start: 4680, end: 4699 },
|
|
20
|
+
idleTimeout: 1800000,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Get the profiles directory path
|
|
25
|
+
*/
|
|
26
|
+
export function getProfilesDir() {
|
|
27
|
+
const paths = getAgentPaths();
|
|
28
|
+
return join(paths.configDir, 'profiles');
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get the config file path for a specific profile
|
|
32
|
+
* @param profileName - Profile name, or undefined/null/'default' for default config
|
|
33
|
+
*/
|
|
34
|
+
export function getProfilePath(profileName) {
|
|
35
|
+
const paths = getAgentPaths();
|
|
36
|
+
if (!profileName || profileName === 'default') {
|
|
37
|
+
return paths.configPath;
|
|
38
|
+
}
|
|
39
|
+
return join(getProfilesDir(), `${profileName}.json`);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* List all available profiles
|
|
43
|
+
*/
|
|
44
|
+
export function listProfiles() {
|
|
45
|
+
const paths = getAgentPaths();
|
|
46
|
+
const profilesDir = getProfilesDir();
|
|
47
|
+
const profiles = [];
|
|
48
|
+
// Add default profile if it exists
|
|
49
|
+
if (existsSync(paths.configPath)) {
|
|
50
|
+
profiles.push('default');
|
|
51
|
+
}
|
|
52
|
+
// Add named profiles
|
|
53
|
+
if (existsSync(profilesDir)) {
|
|
54
|
+
const files = readdirSync(profilesDir);
|
|
55
|
+
for (const file of files) {
|
|
56
|
+
if (file.endsWith('.json')) {
|
|
57
|
+
profiles.push(file.replace('.json', ''));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return profiles;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Check if a profile exists
|
|
65
|
+
*/
|
|
66
|
+
export function profileExists(profileName) {
|
|
67
|
+
const configPath = getProfilePath(profileName);
|
|
68
|
+
return existsSync(configPath);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Delete a profile
|
|
72
|
+
*/
|
|
73
|
+
export function deleteProfile(profileName) {
|
|
74
|
+
if (!profileName || profileName === 'default') {
|
|
75
|
+
throw new Error('Cannot delete default profile');
|
|
76
|
+
}
|
|
77
|
+
const configPath = getProfilePath(profileName);
|
|
78
|
+
if (!existsSync(configPath)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
unlinkSync(configPath);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Load configuration from ~/.247/config.json or a profile
|
|
86
|
+
* @param profileName - Profile name to load, or undefined for default
|
|
87
|
+
*/
|
|
88
|
+
export function loadConfig(profileName) {
|
|
89
|
+
const configPath = getProfilePath(profileName);
|
|
90
|
+
if (!existsSync(configPath)) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const content = readFileSync(configPath, 'utf-8');
|
|
95
|
+
const config = JSON.parse(content);
|
|
96
|
+
// Apply environment overrides
|
|
97
|
+
if (process.env.AGENT_247_PORT) {
|
|
98
|
+
config.agent.port = parseInt(process.env.AGENT_247_PORT, 10);
|
|
99
|
+
}
|
|
100
|
+
if (process.env.AGENT_247_PROJECTS) {
|
|
101
|
+
config.projects.basePath = process.env.AGENT_247_PROJECTS;
|
|
102
|
+
}
|
|
103
|
+
return config;
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
console.error(`Failed to load config: ${err.message}`);
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Save configuration to ~/.247/config.json or a profile
|
|
112
|
+
* @param config - Configuration to save
|
|
113
|
+
* @param profileName - Profile name to save to, or undefined for default
|
|
114
|
+
*/
|
|
115
|
+
export function saveConfig(config, profileName) {
|
|
116
|
+
const configPath = getProfilePath(profileName);
|
|
117
|
+
ensureDirectories();
|
|
118
|
+
// Ensure profiles directory exists for named profiles
|
|
119
|
+
if (profileName && profileName !== 'default') {
|
|
120
|
+
const profilesDir = getProfilesDir();
|
|
121
|
+
if (!existsSync(profilesDir)) {
|
|
122
|
+
mkdirSync(profilesDir, { recursive: true });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const content = JSON.stringify(config, null, 2);
|
|
126
|
+
writeFileSync(configPath, content, 'utf-8');
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Create a new configuration with defaults
|
|
130
|
+
*/
|
|
131
|
+
export function createConfig(options) {
|
|
132
|
+
return {
|
|
133
|
+
...DEFAULT_CONFIG,
|
|
134
|
+
machine: {
|
|
135
|
+
id: randomUUID(),
|
|
136
|
+
name: options.machineName,
|
|
137
|
+
},
|
|
138
|
+
agent: {
|
|
139
|
+
port: options.port ?? DEFAULT_CONFIG.agent.port,
|
|
140
|
+
},
|
|
141
|
+
projects: {
|
|
142
|
+
basePath: options.projectsPath ?? DEFAULT_CONFIG.projects.basePath,
|
|
143
|
+
whitelist: [],
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Check if configuration exists
|
|
149
|
+
* @param profileName - Profile name to check, or undefined for default
|
|
150
|
+
*/
|
|
151
|
+
export function configExists(profileName) {
|
|
152
|
+
const configPath = getProfilePath(profileName);
|
|
153
|
+
return existsSync(configPath);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get default configuration
|
|
157
|
+
*/
|
|
158
|
+
export function getDefaultConfig() {
|
|
159
|
+
return { ...DEFAULT_CONFIG };
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AACjG,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAqB9D,MAAM,cAAc,GAAgB;IAClC,OAAO,EAAE;QACP,EAAE,EAAE,EAAE;QACN,IAAI,EAAE,EAAE;KACT;IACD,KAAK,EAAE;QACL,IAAI,EAAE,IAAI;KACX;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,OAAO;QACjB,SAAS,EAAE,EAAE;KACd;IACD,MAAM,EAAE;QACN,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE;QACrC,WAAW,EAAE,OAAO;KACrB;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,KAAK,GAAG,aAAa,EAAE,CAAC;IAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,WAA2B;IACxD,MAAM,KAAK,GAAG,aAAa,EAAE,CAAC;IAE9B,IAAI,CAAC,WAAW,IAAI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AAK,SAAS,EAAE,CAAC;QAC7C,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;QACrC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;YAC7B,SAAS,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAChD,aAAa,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,OAI5B;IACC,OAAO;QACL,GAAG,cAAc;QACjB,OAAO,EAAE;YACP,EAAE,EAAE,UAAU,EAAE;YAChB,IAAI,EAAE,OAAO,CAAC,WAAW;SAC1B;QACD,KAAK,EAAE;YACL,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI;SAChD;QACD,QAAQ,EAAE;YACR,QAAQ,EAAE,OAAO,CAAC,YAAY,IAAI,cAAc,CAAC,QAAQ,CAAC,QAAQ;YAClE,SAAS,EAAE,EAAE;SACd;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,WAA2B;IACtD,MAAM,UAAU,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IAC/C,OAAO,UAAU,CAAC,UAAU,CAAC,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,EAAE,GAAG,cAAc,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface AgentPaths {
|
|
2
|
+
/** Where the CLI package is installed */
|
|
3
|
+
cliRoot: string;
|
|
4
|
+
/** Where the agent server code is located */
|
|
5
|
+
agentRoot: string;
|
|
6
|
+
/** Where the hooks package source is located */
|
|
7
|
+
hooksSource: string;
|
|
8
|
+
/** Where hooks should be installed for Claude Code */
|
|
9
|
+
hooksDestination: string;
|
|
10
|
+
/** Configuration directory (~/.247/) */
|
|
11
|
+
configDir: string;
|
|
12
|
+
/** Configuration file path */
|
|
13
|
+
configPath: string;
|
|
14
|
+
/** Data directory for SQLite */
|
|
15
|
+
dataDir: string;
|
|
16
|
+
/** Log directory */
|
|
17
|
+
logDir: string;
|
|
18
|
+
/** PID file path */
|
|
19
|
+
pidFile: string;
|
|
20
|
+
/** Node binary path */
|
|
21
|
+
nodePath: string;
|
|
22
|
+
/** Is this a development install? */
|
|
23
|
+
isDev: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare function getAgentPaths(): AgentPaths;
|
|
26
|
+
/**
|
|
27
|
+
* Ensure all required directories exist
|
|
28
|
+
*/
|
|
29
|
+
export declare function ensureDirectories(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Clear cached paths (useful for testing)
|
|
32
|
+
*/
|
|
33
|
+
export declare function clearPathsCache(): void;
|
|
34
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/lib/paths.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,UAAU;IACzB,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAEhB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAElB,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAC;IAEpB,sDAAsD;IACtD,gBAAgB,EAAE,MAAM,CAAC;IAEzB,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAElB,8BAA8B;IAC9B,UAAU,EAAE,MAAM,CAAC;IAEnB,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAEhB,oBAAoB;IACpB,MAAM,EAAE,MAAM,CAAC;IAEf,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;IAEhB,uBAAuB;IACvB,QAAQ,EAAE,MAAM,CAAC;IAEjB,qCAAqC;IACrC,KAAK,EAAE,OAAO,CAAC;CAChB;AAID,wBAAgB,aAAa,IAAI,UAAU,CAmD1C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAcxC;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAEtC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { dirname, join, resolve } from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { existsSync, mkdirSync } from 'fs';
|
|
4
|
+
import { homedir, platform } from 'os';
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
let cachedPaths = null;
|
|
7
|
+
export function getAgentPaths() {
|
|
8
|
+
if (cachedPaths)
|
|
9
|
+
return cachedPaths;
|
|
10
|
+
// CLI root is 2 levels up from lib/ (dist/lib -> dist -> cli root)
|
|
11
|
+
const cliRoot = resolve(__dirname, '..', '..');
|
|
12
|
+
// Check if running from source (monorepo) or installed (npm global)
|
|
13
|
+
// In monorepo: cliRoot is packages/cli, parent has pnpm-workspace.yaml
|
|
14
|
+
const monorepoRoot = resolve(cliRoot, '..', '..');
|
|
15
|
+
const isDev = existsSync(join(monorepoRoot, 'pnpm-workspace.yaml'));
|
|
16
|
+
let agentRoot;
|
|
17
|
+
let hooksSource;
|
|
18
|
+
if (isDev) {
|
|
19
|
+
// Development: agent and hooks are in the monorepo
|
|
20
|
+
agentRoot = resolve(monorepoRoot, 'apps', 'agent');
|
|
21
|
+
hooksSource = resolve(monorepoRoot, 'packages', 'hooks');
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
// Production: agent code is bundled with CLI
|
|
25
|
+
agentRoot = join(cliRoot, 'agent');
|
|
26
|
+
hooksSource = join(cliRoot, 'hooks');
|
|
27
|
+
}
|
|
28
|
+
// Configuration directory
|
|
29
|
+
const configDir = join(homedir(), '.247');
|
|
30
|
+
// Log directory varies by platform
|
|
31
|
+
const os = platform();
|
|
32
|
+
let logDir;
|
|
33
|
+
if (os === 'darwin') {
|
|
34
|
+
logDir = join(homedir(), 'Library', 'Logs', '247-agent');
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
logDir = join(homedir(), '.local', 'log', '247-agent');
|
|
38
|
+
}
|
|
39
|
+
cachedPaths = {
|
|
40
|
+
cliRoot,
|
|
41
|
+
agentRoot,
|
|
42
|
+
hooksSource,
|
|
43
|
+
hooksDestination: join(homedir(), '.claude-plugins', '247-hooks'),
|
|
44
|
+
configDir,
|
|
45
|
+
configPath: join(configDir, 'config.json'),
|
|
46
|
+
dataDir: join(configDir, 'data'),
|
|
47
|
+
logDir,
|
|
48
|
+
pidFile: join(configDir, 'agent.pid'),
|
|
49
|
+
nodePath: process.execPath,
|
|
50
|
+
isDev,
|
|
51
|
+
};
|
|
52
|
+
return cachedPaths;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Ensure all required directories exist
|
|
56
|
+
*/
|
|
57
|
+
export function ensureDirectories() {
|
|
58
|
+
const paths = getAgentPaths();
|
|
59
|
+
const dirs = [
|
|
60
|
+
paths.configDir,
|
|
61
|
+
paths.dataDir,
|
|
62
|
+
paths.logDir,
|
|
63
|
+
];
|
|
64
|
+
for (const dir of dirs) {
|
|
65
|
+
if (!existsSync(dir)) {
|
|
66
|
+
mkdirSync(dir, { recursive: true });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Clear cached paths (useful for testing)
|
|
72
|
+
*/
|
|
73
|
+
export function clearPathsCache() {
|
|
74
|
+
cachedPaths = null;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/lib/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAA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|
|
2
|
+
name: string;
|
|
3
|
+
status: 'ok' | 'warn' | 'error';
|
|
4
|
+
message: string;
|
|
5
|
+
required: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Check if Node.js version is sufficient
|
|
9
|
+
*/
|
|
10
|
+
export declare function checkNodeVersion(): PrerequisiteCheck;
|
|
11
|
+
/**
|
|
12
|
+
* Check if tmux is installed
|
|
13
|
+
*/
|
|
14
|
+
export declare function checkTmux(): PrerequisiteCheck;
|
|
15
|
+
/**
|
|
16
|
+
* Check platform compatibility
|
|
17
|
+
*/
|
|
18
|
+
export declare function checkPlatform(): PrerequisiteCheck;
|
|
19
|
+
/**
|
|
20
|
+
* Check if a port is available
|
|
21
|
+
*/
|
|
22
|
+
export declare function checkPort(port: number): Promise<PrerequisiteCheck>;
|
|
23
|
+
/**
|
|
24
|
+
* Run all prerequisite checks
|
|
25
|
+
*/
|
|
26
|
+
export declare function checkAllPrerequisites(port?: number): Promise<PrerequisiteCheck[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Check if all required prerequisites are met
|
|
29
|
+
*/
|
|
30
|
+
export declare function allRequiredMet(checks: PrerequisiteCheck[]): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Check native dependencies (node-pty, better-sqlite3)
|
|
33
|
+
*/
|
|
34
|
+
export declare function checkNativeDeps(): Promise<PrerequisiteCheck>;
|
|
35
|
+
export declare const checkNode: typeof checkNodeVersion;
|
|
36
|
+
//# sourceMappingURL=prerequisites.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prerequisites.d.ts","sourceRoot":"","sources":["../../src/lib/prerequisites.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,iBAAiB,CA4BpD;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,iBAAiB,CAsB7C;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,iBAAiB,CA2BjD;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAkCxE;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAYvF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAInE;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAgClE;AAGD,eAAO,MAAM,SAAS,yBAAmB,CAAC"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import { platform } from 'os';
|
|
3
|
+
import * as net from 'net';
|
|
4
|
+
/**
|
|
5
|
+
* Check if Node.js version is sufficient
|
|
6
|
+
*/
|
|
7
|
+
export function checkNodeVersion() {
|
|
8
|
+
const version = process.version;
|
|
9
|
+
const major = parseInt(version.slice(1).split('.')[0], 10);
|
|
10
|
+
if (major >= 22) {
|
|
11
|
+
return {
|
|
12
|
+
name: 'Node.js',
|
|
13
|
+
status: 'ok',
|
|
14
|
+
message: version,
|
|
15
|
+
required: true,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
if (major >= 18) {
|
|
19
|
+
return {
|
|
20
|
+
name: 'Node.js',
|
|
21
|
+
status: 'warn',
|
|
22
|
+
message: `${version} (recommended: >=22)`,
|
|
23
|
+
required: true,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
name: 'Node.js',
|
|
28
|
+
status: 'error',
|
|
29
|
+
message: `${version} (required: >=22)`,
|
|
30
|
+
required: true,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Check if tmux is installed
|
|
35
|
+
*/
|
|
36
|
+
export function checkTmux() {
|
|
37
|
+
try {
|
|
38
|
+
const output = execSync('tmux -V', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] });
|
|
39
|
+
return {
|
|
40
|
+
name: 'tmux',
|
|
41
|
+
status: 'ok',
|
|
42
|
+
message: output.trim(),
|
|
43
|
+
required: true,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
const os = platform();
|
|
48
|
+
const installCmd = os === 'darwin'
|
|
49
|
+
? 'brew install tmux'
|
|
50
|
+
: 'sudo apt install tmux';
|
|
51
|
+
return {
|
|
52
|
+
name: 'tmux',
|
|
53
|
+
status: 'error',
|
|
54
|
+
message: `Not installed. Run: ${installCmd}`,
|
|
55
|
+
required: true,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Check platform compatibility
|
|
61
|
+
*/
|
|
62
|
+
export function checkPlatform() {
|
|
63
|
+
const os = platform();
|
|
64
|
+
if (os === 'darwin') {
|
|
65
|
+
return {
|
|
66
|
+
name: 'Platform',
|
|
67
|
+
status: 'ok',
|
|
68
|
+
message: 'macOS',
|
|
69
|
+
required: true,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (os === 'linux') {
|
|
73
|
+
return {
|
|
74
|
+
name: 'Platform',
|
|
75
|
+
status: 'ok',
|
|
76
|
+
message: 'Linux',
|
|
77
|
+
required: true,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
name: 'Platform',
|
|
82
|
+
status: 'error',
|
|
83
|
+
message: `Unsupported: ${os}. Only macOS and Linux are supported.`,
|
|
84
|
+
required: true,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Check if a port is available
|
|
89
|
+
*/
|
|
90
|
+
export async function checkPort(port) {
|
|
91
|
+
return new Promise((resolve) => {
|
|
92
|
+
const server = net.createServer();
|
|
93
|
+
server.once('error', (err) => {
|
|
94
|
+
if (err.code === 'EADDRINUSE') {
|
|
95
|
+
resolve({
|
|
96
|
+
name: `Port ${port}`,
|
|
97
|
+
status: 'error',
|
|
98
|
+
message: 'Port is already in use',
|
|
99
|
+
required: false,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
resolve({
|
|
104
|
+
name: `Port ${port}`,
|
|
105
|
+
status: 'warn',
|
|
106
|
+
message: `Could not check: ${err.message}`,
|
|
107
|
+
required: false,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
server.once('listening', () => {
|
|
112
|
+
server.close();
|
|
113
|
+
resolve({
|
|
114
|
+
name: `Port ${port}`,
|
|
115
|
+
status: 'ok',
|
|
116
|
+
message: 'Available',
|
|
117
|
+
required: false,
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
server.listen(port, '127.0.0.1');
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Run all prerequisite checks
|
|
125
|
+
*/
|
|
126
|
+
export async function checkAllPrerequisites(port) {
|
|
127
|
+
const checks = [
|
|
128
|
+
checkPlatform(),
|
|
129
|
+
checkNodeVersion(),
|
|
130
|
+
checkTmux(),
|
|
131
|
+
];
|
|
132
|
+
if (port) {
|
|
133
|
+
checks.push(await checkPort(port));
|
|
134
|
+
}
|
|
135
|
+
return checks;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Check if all required prerequisites are met
|
|
139
|
+
*/
|
|
140
|
+
export function allRequiredMet(checks) {
|
|
141
|
+
return checks
|
|
142
|
+
.filter(c => c.required)
|
|
143
|
+
.every(c => c.status !== 'error');
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Check native dependencies (node-pty, better-sqlite3)
|
|
147
|
+
*/
|
|
148
|
+
export async function checkNativeDeps() {
|
|
149
|
+
const issues = [];
|
|
150
|
+
// Check node-pty
|
|
151
|
+
try {
|
|
152
|
+
await import('@homebridge/node-pty-prebuilt-multiarch');
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
issues.push('node-pty');
|
|
156
|
+
}
|
|
157
|
+
// Check better-sqlite3
|
|
158
|
+
try {
|
|
159
|
+
await import('better-sqlite3');
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
issues.push('better-sqlite3');
|
|
163
|
+
}
|
|
164
|
+
if (issues.length === 0) {
|
|
165
|
+
return {
|
|
166
|
+
name: 'Native modules',
|
|
167
|
+
status: 'ok',
|
|
168
|
+
message: 'All native modules loaded successfully',
|
|
169
|
+
required: true,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
name: 'Native modules',
|
|
174
|
+
status: 'error',
|
|
175
|
+
message: `Failed to load: ${issues.join(', ')}`,
|
|
176
|
+
required: true,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
// Aliases for backwards compatibility
|
|
180
|
+
export const checkNode = checkNodeVersion;
|
|
181
|
+
//# sourceMappingURL=prerequisites.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prerequisites.js","sourceRoot":"","sources":["../../src/lib/prerequisites.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAS3B;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAChC,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,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,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAChC,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO;YACL,IAAI,EAAE,gBAAgB;YACtB,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE,wCAAwC;YACjD,QAAQ,EAAE,IAAI;SACf,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,MAAM,EAAE,OAAO;QACf,OAAO,EAAE,mBAAmB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAC/C,QAAQ,EAAE,IAAI;KACf,CAAC;AACJ,CAAC;AAED,sCAAsC;AACtC,MAAM,CAAC,MAAM,SAAS,GAAG,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the agent process is running
|
|
3
|
+
*/
|
|
4
|
+
export declare function isAgentRunning(): {
|
|
5
|
+
running: boolean;
|
|
6
|
+
pid?: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Start the agent as a background daemon
|
|
10
|
+
* @param profileName - Optional profile name to use
|
|
11
|
+
*/
|
|
12
|
+
export declare function startAgentDaemon(profileName?: string | null): Promise<{
|
|
13
|
+
success: boolean;
|
|
14
|
+
pid?: number;
|
|
15
|
+
error?: string;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Stop the running agent
|
|
19
|
+
*/
|
|
20
|
+
export declare function stopAgent(): {
|
|
21
|
+
success: boolean;
|
|
22
|
+
error?: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Restart the agent
|
|
26
|
+
*/
|
|
27
|
+
export declare function restartAgent(): Promise<{
|
|
28
|
+
success: boolean;
|
|
29
|
+
pid?: number;
|
|
30
|
+
error?: string;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Get agent health status by checking the API
|
|
34
|
+
*/
|
|
35
|
+
export declare function getAgentHealth(port: number): Promise<{
|
|
36
|
+
healthy: boolean;
|
|
37
|
+
sessions?: number;
|
|
38
|
+
error?: string;
|
|
39
|
+
}>;
|
|
40
|
+
//# sourceMappingURL=process.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/lib/process.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,cAAc,IAAI;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CA+BnE;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAgF/H;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAqDhE;AAED;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAUhG;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1D,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CAWD"}
|