@yeaft/webchat-agent 1.0.270 → 1.0.271
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/cli.js +16 -9
- package/index.js +6 -5
- package/local-run.js +4 -7
- package/local-runtime/version.json +1 -1
- package/package.json +1 -1
- package/service/config.js +71 -30
- package/service/doctor.js +11 -10
- package/service/index.js +11 -7
- package/service.js +4 -0
package/cli.js
CHANGED
|
@@ -48,7 +48,7 @@ const subArgs = args.slice(1);
|
|
|
48
48
|
const SERVICE_COMMANDS = ['install', 'uninstall', 'start', 'stop', 'restart', 'status', 'logs'];
|
|
49
49
|
|
|
50
50
|
if (command === 'doctor') {
|
|
51
|
-
await handleDoctorCommand();
|
|
51
|
+
await handleDoctorCommand(subArgs);
|
|
52
52
|
} else if (command === 'llm') {
|
|
53
53
|
await handleLlmCommand(subArgs);
|
|
54
54
|
} else if (command === 'local') {
|
|
@@ -78,7 +78,7 @@ function printHelp() {
|
|
|
78
78
|
|
|
79
79
|
Usage:
|
|
80
80
|
yeaft-agent [options] Run agent in foreground
|
|
81
|
-
yeaft-agent local
|
|
81
|
+
yeaft-agent local [options] Run local Web UI, server, and agent
|
|
82
82
|
yeaft-agent install [options] Install as system service
|
|
83
83
|
yeaft-agent uninstall [options] Remove system service
|
|
84
84
|
yeaft-agent start [options] Start installed service
|
|
@@ -94,7 +94,7 @@ function printHelp() {
|
|
|
94
94
|
Options:
|
|
95
95
|
--instance <id> Deprecated alias for the local service instance id
|
|
96
96
|
--server <url> WebSocket server URL (default: ws://localhost:3456)
|
|
97
|
-
--name <name> Agent name and instance id (
|
|
97
|
+
--name <name> Agent name and instance id (default: computer name; invalid chars become -)
|
|
98
98
|
--port <port> Local server port (local command only; default: 6868)
|
|
99
99
|
--secret <secret> Agent secret for authentication
|
|
100
100
|
--work-dir <dir> Default working directory (default: cwd)
|
|
@@ -104,13 +104,13 @@ function printHelp() {
|
|
|
104
104
|
Environment variables (alternative to flags):
|
|
105
105
|
YEAFT_AGENT_INSTANCE Deprecated local service instance id override
|
|
106
106
|
SERVER_URL WebSocket server URL
|
|
107
|
-
AGENT_NAME Agent name and instance id
|
|
107
|
+
AGENT_NAME Agent name and instance id override
|
|
108
108
|
AGENT_SECRET Agent secret
|
|
109
109
|
WORK_DIR Working directory
|
|
110
110
|
YEAFT_DIR Yeaft data directory
|
|
111
111
|
|
|
112
112
|
Examples:
|
|
113
|
-
yeaft-agent local
|
|
113
|
+
yeaft-agent local
|
|
114
114
|
yeaft-agent local --name my-worker --port 7000
|
|
115
115
|
yeaft-agent --server wss://your-server.com --name my-worker --secret xxx
|
|
116
116
|
yeaft-agent install --server wss://your-server.com --name my-worker --secret xxx
|
|
@@ -415,14 +415,21 @@ async function handleServiceCommand(command, args) {
|
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
417
|
|
|
418
|
-
async function handleDoctorCommand() {
|
|
418
|
+
async function handleDoctorCommand(args) {
|
|
419
|
+
warnDeprecatedInstanceArg(args);
|
|
419
420
|
const { doctor } = await import('./service.js');
|
|
420
|
-
doctor();
|
|
421
|
+
doctor(args);
|
|
421
422
|
}
|
|
422
423
|
|
|
423
424
|
function parseAndStart(args) {
|
|
424
|
-
|
|
425
|
-
|
|
425
|
+
try {
|
|
426
|
+
warnDeprecatedInstanceArg(args);
|
|
427
|
+
applyAgentIdentityToEnv(args);
|
|
428
|
+
} catch (err) {
|
|
429
|
+
console.error(`Error: ${err.message}`);
|
|
430
|
+
process.exit(1);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
426
433
|
|
|
427
434
|
// Parse non-identity flags. Saved environment remains the fallback for these options.
|
|
428
435
|
for (let i = 0; i < args.length; i++) {
|
package/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { assertNodeVersion } from './check-node-version.js';
|
|
|
2
2
|
assertNodeVersion({ component: '@yeaft/webchat-agent' });
|
|
3
3
|
|
|
4
4
|
import 'dotenv/config';
|
|
5
|
-
import {
|
|
5
|
+
import { homedir } from 'os';
|
|
6
6
|
import { createAssetOutbox } from './yeaft/asset-outbox.js';
|
|
7
7
|
import { existsSync, readFileSync, writeFileSync, mkdirSync, cpSync, chmodSync, readdirSync } from 'fs';
|
|
8
8
|
import { join, dirname } from 'path';
|
|
@@ -10,7 +10,7 @@ import { exec } from 'child_process';
|
|
|
10
10
|
import { promisify } from 'util';
|
|
11
11
|
import { fileURLToPath } from 'url';
|
|
12
12
|
import ctx from './context.js';
|
|
13
|
-
import {
|
|
13
|
+
import { getDefaultAgentName, getDefaultYeaftDir, resolveRuntimeIdentity, getConfigPath, loadServiceConfig } from './service.js';
|
|
14
14
|
import { loadNodePty } from './terminal.js';
|
|
15
15
|
import { connect } from './connection.js';
|
|
16
16
|
import { loadMcpServers } from './mcp.js';
|
|
@@ -33,12 +33,13 @@ ctx.pkgName = pkg.name;
|
|
|
33
33
|
// 配置文件路径(向后兼容:先查当前目录 .claude-agent.json)
|
|
34
34
|
const LOCAL_CONFIG_FILE = join(process.cwd(), '.claude-agent.json');
|
|
35
35
|
const IS_LOCAL_RUN = process.env.YEAFT_LOCAL_RUN === 'true';
|
|
36
|
+
const DEFAULT_AGENT_NAME = getDefaultAgentName();
|
|
36
37
|
|
|
37
38
|
// 加载或创建配置
|
|
38
39
|
function loadConfig() {
|
|
39
40
|
const defaults = {
|
|
40
41
|
serverUrl: 'ws://localhost:3456',
|
|
41
|
-
agentName:
|
|
42
|
+
agentName: DEFAULT_AGENT_NAME,
|
|
42
43
|
workDir: process.cwd(),
|
|
43
44
|
reconnectInterval: 5000,
|
|
44
45
|
agentSecret: 'agent-shared-secret'
|
|
@@ -74,7 +75,7 @@ function saveConfig(config) {
|
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
const fileConfig = loadConfig();
|
|
77
|
-
const INSTANCE_ID =
|
|
78
|
+
const { agentName: AGENT_NAME, instanceId: INSTANCE_ID } = resolveRuntimeIdentity(fileConfig);
|
|
78
79
|
|
|
79
80
|
// task-fix (5-bugs): the Yeaft web-bridge reads `ctx.CONFIG.yeaftDir`
|
|
80
81
|
// for every group / VP / memory operation. If unset, `path.join(undefined, …)`
|
|
@@ -95,7 +96,7 @@ try {
|
|
|
95
96
|
const CONFIG = {
|
|
96
97
|
instanceId: INSTANCE_ID,
|
|
97
98
|
serverUrl: process.env.SERVER_URL || fileConfig.serverUrl,
|
|
98
|
-
agentName:
|
|
99
|
+
agentName: AGENT_NAME,
|
|
99
100
|
workDir: process.env.WORK_DIR || fileConfig.workDir || process.cwd(),
|
|
100
101
|
yeaftDir: YEAFT_DIR,
|
|
101
102
|
reconnectInterval: fileConfig.reconnectInterval,
|
package/local-run.js
CHANGED
|
@@ -5,18 +5,18 @@ import { createServer } from 'net';
|
|
|
5
5
|
import { dirname, join } from 'path';
|
|
6
6
|
import { fileURLToPath } from 'url';
|
|
7
7
|
import { WebSocket } from 'ws';
|
|
8
|
+
import { resolveDisplayName, validateInstanceId } from './service/config.js';
|
|
8
9
|
|
|
9
10
|
const DEFAULT_PORT = 6868;
|
|
10
11
|
const LOCAL_HOST = '127.0.0.1';
|
|
11
12
|
|
|
12
|
-
export function parseLocalArgs(args) {
|
|
13
|
-
const options = { name:
|
|
13
|
+
export function parseLocalArgs(args, env = process.env) {
|
|
14
|
+
const options = { name: resolveDisplayName(args, env), port: DEFAULT_PORT };
|
|
14
15
|
for (let i = 0; i < args.length; i++) {
|
|
15
16
|
const arg = args[i];
|
|
16
17
|
const value = args[i + 1];
|
|
17
18
|
if (arg === '--name') {
|
|
18
19
|
if (!value || value.startsWith('-')) throw new Error('--name requires a value');
|
|
19
|
-
options.name = value;
|
|
20
20
|
i++;
|
|
21
21
|
} else if (arg === '--port') {
|
|
22
22
|
if (!value || value.startsWith('-')) throw new Error('--port requires a value');
|
|
@@ -28,10 +28,7 @@ export function parseLocalArgs(args) {
|
|
|
28
28
|
throw new Error(`Unknown local option: ${arg}`);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
if (!/^[A-Za-z0-9._-]+$/.test(options.name)) {
|
|
33
|
-
throw new Error('Invalid name: use only letters, numbers, dot, underscore, or hyphen');
|
|
34
|
-
}
|
|
31
|
+
validateInstanceId(options.name);
|
|
35
32
|
return options;
|
|
36
33
|
}
|
|
37
34
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.0.
|
|
1
|
+
{"version":"1.0.271"}
|
package/package.json
CHANGED
package/service/config.js
CHANGED
|
@@ -3,13 +3,19 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { existsSync, mkdirSync, writeFileSync, readFileSync } from 'fs';
|
|
5
5
|
import { join, dirname } from 'path';
|
|
6
|
-
import { platform, homedir } from 'os';
|
|
6
|
+
import { platform, homedir, hostname } from 'os';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
|
|
9
9
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
10
|
export const SERVICE_NAME = 'yeaft-agent';
|
|
11
11
|
export const DEFAULT_INSTANCE_ID = 'default';
|
|
12
12
|
|
|
13
|
+
export function getDefaultAgentName(machineName = hostname()) {
|
|
14
|
+
const raw = String(machineName || '');
|
|
15
|
+
if (!raw) return DEFAULT_INSTANCE_ID;
|
|
16
|
+
return raw.replace(/[^A-Za-z0-9._-]/gu, '-');
|
|
17
|
+
}
|
|
18
|
+
|
|
13
19
|
/**
|
|
14
20
|
* Load .env file from agent directory (or cwd) into process.env
|
|
15
21
|
* Only sets vars that are not already set (won't override existing env)
|
|
@@ -58,45 +64,73 @@ export function validateInstanceId(instanceId) {
|
|
|
58
64
|
return normalized;
|
|
59
65
|
}
|
|
60
66
|
|
|
61
|
-
|
|
62
|
-
let
|
|
63
|
-
let
|
|
67
|
+
function readIdentityArgs(args = []) {
|
|
68
|
+
let deprecatedInstanceId = null;
|
|
69
|
+
let explicitName = null;
|
|
64
70
|
for (let i = 0; i < args.length; i++) {
|
|
65
71
|
const arg = args[i];
|
|
66
72
|
const next = args[i + 1];
|
|
67
|
-
if (arg
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
} else if (arg === '--name' && next) {
|
|
71
|
-
agentName = next;
|
|
72
|
-
i++;
|
|
73
|
+
if (arg !== '--instance' && arg !== '--name') continue;
|
|
74
|
+
if (!next || next.startsWith('-')) {
|
|
75
|
+
throw new Error(`${arg} requires a value`);
|
|
73
76
|
}
|
|
77
|
+
if (arg === '--name') {
|
|
78
|
+
explicitName = validateInstanceId(next);
|
|
79
|
+
} else {
|
|
80
|
+
deprecatedInstanceId = validateInstanceId(next);
|
|
81
|
+
}
|
|
82
|
+
i++;
|
|
74
83
|
}
|
|
75
|
-
return
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
return { deprecatedInstanceId, explicitName };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function resolveDisplayName(args = [], env = process.env, fallbackName = getDefaultAgentName()) {
|
|
88
|
+
const { explicitName } = readIdentityArgs(args);
|
|
89
|
+
return explicitName
|
|
79
90
|
|| env.AGENT_NAME
|
|
80
|
-
||
|
|
81
|
-
|
|
91
|
+
|| fallbackName
|
|
92
|
+
|| getDefaultAgentName();
|
|
82
93
|
}
|
|
83
94
|
|
|
84
|
-
export function
|
|
85
|
-
|
|
95
|
+
export function resolveRuntimeIdentity(fileConfig = {}, env = process.env) {
|
|
96
|
+
const agentName = resolveDisplayName([], env, fileConfig.agentName || getDefaultAgentName());
|
|
97
|
+
const instanceId = validateInstanceId(env.YEAFT_AGENT_INSTANCE || fileConfig.instanceId || DEFAULT_INSTANCE_ID);
|
|
98
|
+
return { agentName, instanceId };
|
|
99
|
+
}
|
|
86
100
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
101
|
+
export function resolveServiceInstanceId(args = [], env = process.env, options = {}) {
|
|
102
|
+
const { deprecatedInstanceId, explicitName } = readIdentityArgs(args);
|
|
103
|
+
if (explicitName) return explicitName;
|
|
104
|
+
if (deprecatedInstanceId) return deprecatedInstanceId;
|
|
105
|
+
if (env.YEAFT_AGENT_INSTANCE) return validateInstanceId(env.YEAFT_AGENT_INSTANCE);
|
|
106
|
+
if (options.management) return DEFAULT_INSTANCE_ID;
|
|
107
|
+
if (env.AGENT_NAME) return validateInstanceId(env.AGENT_NAME);
|
|
108
|
+
return validateInstanceId(options.fallbackName || getDefaultAgentName());
|
|
109
|
+
}
|
|
93
110
|
|
|
94
|
-
|
|
111
|
+
/** Legacy alias for resolveServiceInstanceId(). */
|
|
112
|
+
export function getInstanceIdFromArgs(args = [], env = process.env, options = {}) {
|
|
113
|
+
return resolveServiceInstanceId(args, env, options);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function applyAgentIdentityToEnv(args = [], env = process.env) {
|
|
117
|
+
const { deprecatedInstanceId, explicitName } = readIdentityArgs(args);
|
|
118
|
+
if (explicitName) {
|
|
119
|
+
env.YEAFT_AGENT_INSTANCE = explicitName;
|
|
120
|
+
env.AGENT_NAME = explicitName;
|
|
121
|
+
} else if (deprecatedInstanceId) {
|
|
122
|
+
env.YEAFT_AGENT_INSTANCE = deprecatedInstanceId;
|
|
123
|
+
} else if (!env.YEAFT_AGENT_INSTANCE && env.AGENT_NAME) {
|
|
124
|
+
env.YEAFT_AGENT_INSTANCE = validateInstanceId(env.AGENT_NAME);
|
|
125
|
+
} else if (env.YEAFT_AGENT_INSTANCE) {
|
|
126
|
+
env.YEAFT_AGENT_INSTANCE = validateInstanceId(env.YEAFT_AGENT_INSTANCE);
|
|
127
|
+
}
|
|
128
|
+
return env.YEAFT_AGENT_INSTANCE || null;
|
|
95
129
|
}
|
|
96
130
|
|
|
97
131
|
export function warnDeprecatedInstanceArg(args = [], warn = console.warn) {
|
|
98
132
|
if (args.includes('--instance')) {
|
|
99
|
-
warn('Warning: --instance is deprecated; use --name instead.
|
|
133
|
+
warn('Warning: --instance is deprecated; use --name instead. --name takes precedence when both are provided.');
|
|
100
134
|
}
|
|
101
135
|
}
|
|
102
136
|
|
|
@@ -184,12 +218,20 @@ export function parseServiceArgs(args) {
|
|
|
184
218
|
// Load .env if available (for dev / source-based usage)
|
|
185
219
|
loadDotenv();
|
|
186
220
|
|
|
187
|
-
const instanceId =
|
|
221
|
+
const instanceId = resolveServiceInstanceId(args, process.env, { management: true });
|
|
188
222
|
const existing = loadServiceConfig(instanceId) || {};
|
|
223
|
+
const explicitIdentity = args.includes('--name') || args.includes('--instance');
|
|
224
|
+
const fallbackName = explicitIdentity
|
|
225
|
+
? instanceId
|
|
226
|
+
: existing.agentName || getDefaultAgentName();
|
|
189
227
|
const config = {
|
|
190
228
|
instanceId,
|
|
191
229
|
serverUrl: existing.serverUrl || '',
|
|
192
|
-
agentName:
|
|
230
|
+
agentName: resolveDisplayName(
|
|
231
|
+
args,
|
|
232
|
+
explicitIdentity ? { ...process.env, AGENT_NAME: '' } : process.env,
|
|
233
|
+
fallbackName,
|
|
234
|
+
),
|
|
193
235
|
agentSecret: existing.agentSecret || '',
|
|
194
236
|
workDir: existing.workDir || '',
|
|
195
237
|
yeaftDir: existing.yeaftDir || '',
|
|
@@ -197,7 +239,6 @@ export function parseServiceArgs(args) {
|
|
|
197
239
|
|
|
198
240
|
// Environment variables override saved config
|
|
199
241
|
if (process.env.SERVER_URL) config.serverUrl = process.env.SERVER_URL;
|
|
200
|
-
if (process.env.AGENT_NAME) config.agentName = process.env.AGENT_NAME;
|
|
201
242
|
if (process.env.AGENT_SECRET) config.agentSecret = process.env.AGENT_SECRET;
|
|
202
243
|
if (process.env.WORK_DIR) config.workDir = process.env.WORK_DIR;
|
|
203
244
|
if (process.env.YEAFT_DIR) config.yeaftDir = process.env.YEAFT_DIR;
|
|
@@ -209,7 +250,7 @@ export function parseServiceArgs(args) {
|
|
|
209
250
|
switch (arg) {
|
|
210
251
|
case '--instance': if (next) { i++; } break;
|
|
211
252
|
case '--server': if (next) { config.serverUrl = next; i++; } break;
|
|
212
|
-
case '--name': if (next) {
|
|
253
|
+
case '--name': if (next) { i++; } break;
|
|
213
254
|
case '--secret': if (next) { config.agentSecret = next; i++; } break;
|
|
214
255
|
case '--work-dir': if (next) { config.workDir = next; i++; } break;
|
|
215
256
|
case '--yeaft-dir': if (next) { config.yeaftDir = next; i++; } break;
|
package/service/doctor.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { execSync } from 'child_process';
|
|
8
8
|
import { existsSync, readFileSync, statSync } from 'fs';
|
|
9
9
|
import { platform, homedir } from 'os';
|
|
10
|
-
import { getNodePath } from './config.js';
|
|
10
|
+
import { getNodePath, resolveServiceInstanceId } from './config.js';
|
|
11
11
|
import { getLaunchdPlistPath, getMacServiceStatus } from './macos.js';
|
|
12
12
|
import { getSystemdServicePath, getLinuxServiceStatus } from './linux.js';
|
|
13
13
|
import { getEcosystemPath, getWinServiceStatus } from './windows.js';
|
|
@@ -112,8 +112,9 @@ function tildeify(filePath) {
|
|
|
112
112
|
|
|
113
113
|
// ── Main doctor logic ──────────────────────────────────────────────────────
|
|
114
114
|
|
|
115
|
-
export function doctor() {
|
|
115
|
+
export function doctor(args = []) {
|
|
116
116
|
const os = platform();
|
|
117
|
+
const instanceId = resolveServiceInstanceId(args, process.env, { management: true });
|
|
117
118
|
let configPath = null;
|
|
118
119
|
let parsePaths = null;
|
|
119
120
|
let getServiceStatus = null;
|
|
@@ -122,17 +123,17 @@ export function doctor() {
|
|
|
122
123
|
|
|
123
124
|
// 1. Determine platform and config path
|
|
124
125
|
if (os === 'darwin') {
|
|
125
|
-
configPath = getLaunchdPlistPath();
|
|
126
|
+
configPath = getLaunchdPlistPath(instanceId);
|
|
126
127
|
parsePaths = parseMacPaths;
|
|
127
|
-
getServiceStatus = getMacServiceStatus;
|
|
128
|
+
getServiceStatus = () => getMacServiceStatus(instanceId);
|
|
128
129
|
} else if (os === 'linux') {
|
|
129
|
-
configPath = getSystemdServicePath();
|
|
130
|
+
configPath = getSystemdServicePath(instanceId);
|
|
130
131
|
parsePaths = parseLinuxPaths;
|
|
131
|
-
getServiceStatus = getLinuxServiceStatus;
|
|
132
|
+
getServiceStatus = () => getLinuxServiceStatus(instanceId);
|
|
132
133
|
} else if (os === 'win32') {
|
|
133
|
-
configPath = getEcosystemPath();
|
|
134
|
+
configPath = getEcosystemPath(instanceId);
|
|
134
135
|
parsePaths = parseWindowsPaths;
|
|
135
|
-
getServiceStatus = getWinServiceStatus;
|
|
136
|
+
getServiceStatus = () => getWinServiceStatus(instanceId);
|
|
136
137
|
} else {
|
|
137
138
|
console.log(`\u26a0\ufe0f Unsupported platform: ${os}`);
|
|
138
139
|
console.log(` The doctor command supports macOS, Linux, and Windows.`);
|
|
@@ -143,7 +144,7 @@ export function doctor() {
|
|
|
143
144
|
// 2. Check if service config exists
|
|
144
145
|
if (!existsSync(configPath)) {
|
|
145
146
|
console.log(`\u26a0\ufe0f No service configuration found.`);
|
|
146
|
-
console.log(` Run 'yeaft-agent install --server <url> --
|
|
147
|
+
console.log(` Run 'yeaft-agent install --server <url> --secret <secret>' to set up.`);
|
|
147
148
|
console.log('');
|
|
148
149
|
return;
|
|
149
150
|
}
|
|
@@ -209,7 +210,7 @@ export function doctor() {
|
|
|
209
210
|
if (hasErrors) {
|
|
210
211
|
console.log('Fix: Run the following commands:');
|
|
211
212
|
console.log(' npm install -g @yeaft/webchat-agent');
|
|
212
|
-
console.log(' yeaft-agent install --server <your-server-url> --
|
|
213
|
+
console.log(' yeaft-agent install --server <your-server-url> --secret <your-secret>');
|
|
213
214
|
} else {
|
|
214
215
|
console.log('All checks passed.');
|
|
215
216
|
}
|
package/service/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { platform } from 'os';
|
|
|
8
8
|
import {
|
|
9
9
|
getConfigDir, getLogDir, getConfigPath,
|
|
10
10
|
saveServiceConfig, loadServiceConfig,
|
|
11
|
-
parseServiceArgs, validateConfig,
|
|
11
|
+
parseServiceArgs, validateConfig, resolveServiceInstanceId, getDefaultYeaftDir
|
|
12
12
|
} from './config.js';
|
|
13
13
|
import { initYeaftDir } from '../yeaft/init.js';
|
|
14
14
|
import { DEFAULT_GITHUB_COPILOT_MODEL, tryAutoConfigureGitHubCopilot } from '../llm-config-cli.js';
|
|
@@ -25,6 +25,10 @@ export {
|
|
|
25
25
|
export {
|
|
26
26
|
SERVICE_NAME,
|
|
27
27
|
DEFAULT_INSTANCE_ID,
|
|
28
|
+
getDefaultAgentName,
|
|
29
|
+
resolveDisplayName,
|
|
30
|
+
resolveRuntimeIdentity,
|
|
31
|
+
resolveServiceInstanceId,
|
|
28
32
|
normalizeInstanceId,
|
|
29
33
|
isDefaultInstance,
|
|
30
34
|
validateInstanceId,
|
|
@@ -105,7 +109,7 @@ export async function install(args) {
|
|
|
105
109
|
}
|
|
106
110
|
|
|
107
111
|
export function uninstall(args = []) {
|
|
108
|
-
const instanceId =
|
|
112
|
+
const instanceId = resolveServiceInstanceId(args, process.env, { management: true });
|
|
109
113
|
console.log(`Uninstalling yeaft-agent service (${instanceId})...`);
|
|
110
114
|
if (os === 'linux') linuxUninstall(instanceId);
|
|
111
115
|
else if (os === 'darwin') macUninstall(instanceId);
|
|
@@ -114,7 +118,7 @@ export function uninstall(args = []) {
|
|
|
114
118
|
}
|
|
115
119
|
|
|
116
120
|
export function start(args = []) {
|
|
117
|
-
const instanceId =
|
|
121
|
+
const instanceId = resolveServiceInstanceId(args, process.env, { management: true });
|
|
118
122
|
ensureInstalled(instanceId);
|
|
119
123
|
if (os === 'linux') linuxStart(instanceId);
|
|
120
124
|
else if (os === 'darwin') macStart(instanceId);
|
|
@@ -122,7 +126,7 @@ export function start(args = []) {
|
|
|
122
126
|
}
|
|
123
127
|
|
|
124
128
|
export function stop(args = []) {
|
|
125
|
-
const instanceId =
|
|
129
|
+
const instanceId = resolveServiceInstanceId(args, process.env, { management: true });
|
|
126
130
|
ensureInstalled(instanceId);
|
|
127
131
|
if (os === 'linux') linuxStop(instanceId);
|
|
128
132
|
else if (os === 'darwin') macStop(instanceId);
|
|
@@ -130,7 +134,7 @@ export function stop(args = []) {
|
|
|
130
134
|
}
|
|
131
135
|
|
|
132
136
|
export function restart(args = []) {
|
|
133
|
-
const instanceId =
|
|
137
|
+
const instanceId = resolveServiceInstanceId(args, process.env, { management: true });
|
|
134
138
|
ensureInstalled(instanceId);
|
|
135
139
|
if (os === 'linux') linuxRestart(instanceId);
|
|
136
140
|
else if (os === 'darwin') macRestart(instanceId);
|
|
@@ -138,14 +142,14 @@ export function restart(args = []) {
|
|
|
138
142
|
}
|
|
139
143
|
|
|
140
144
|
export function status(args = []) {
|
|
141
|
-
const instanceId =
|
|
145
|
+
const instanceId = resolveServiceInstanceId(args, process.env, { management: true });
|
|
142
146
|
if (os === 'linux') linuxStatus(instanceId);
|
|
143
147
|
else if (os === 'darwin') macStatus(instanceId);
|
|
144
148
|
else if (os === 'win32') winStatus(instanceId);
|
|
145
149
|
}
|
|
146
150
|
|
|
147
151
|
export function logs(args = []) {
|
|
148
|
-
const instanceId =
|
|
152
|
+
const instanceId = resolveServiceInstanceId(args, process.env, { management: true });
|
|
149
153
|
if (os === 'linux') linuxLogs(instanceId);
|
|
150
154
|
else if (os === 'darwin') macLogs(instanceId);
|
|
151
155
|
else if (os === 'win32') winLogs(instanceId);
|
package/service.js
CHANGED